Skip to content

Instantly share code, notes, and snippets.

@todd-dsm
Created April 24, 2024 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todd-dsm/2bb6099839cd68ca23210385a2c36d2a to your computer and use it in GitHub Desktop.
Save todd-dsm/2bb6099839cd68ca23210385a2c36d2a to your computer and use it in GitHub Desktop.
AuthN Plumbing to live-build on EKS
/*
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