Created
April 24, 2024 16:08
-
-
Save todd-dsm/2bb6099839cd68ca23210385a2c36d2a to your computer and use it in GitHub Desktop.
AuthN Plumbing to live-build on EKS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
AuthN Configuration for EKS | |
This config solves the issue of pre-configuring cluster credentials before the cluster is built. | |
*/ | |
### Discover the Cluster Token for AuthN | |
data "aws_eks_cluster_auth" "cluster_auth" { | |
name = module.eks.cluster_name | |
} | |
### AuthN: Helm <> EKS | |
# So Helm Can Install Charts | |
provider "helm" { | |
kubernetes { | |
host = module.eks.cluster_endpoint | |
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) | |
token = data.aws_eks_cluster_auth.cluster_auth.token | |
} | |
} | |
### AuthN: Terraform <> EKS | |
# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs | |
# https://github.com/hashicorp/terraform-provider-kubernetes/releases | |
provider "kubernetes" { | |
host = module.eks.cluster_endpoint | |
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) | |
exec { | |
api_version = "client.authentication.k8s.io/v1" | |
command = "aws" | |
# This requires the awscli to be installed locally where Terraform is executed | |
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment