Use kubernetes provider to manage aws auth (#355)

This commit changes the way aws auth is managed. Before a local file
was used the generate the template and a null resource to apply it. This
is now switched to the terraform kubernetes provider.
This commit is contained in:
Stijn De Haes
2019-11-28 10:25:13 +01:00
committed by Max Williams
parent b69c8fb759
commit 9363662574
10 changed files with 108 additions and 82 deletions

View File

@@ -18,9 +18,29 @@ Read the [AWS docs on EKS to get connected to the k8s dashboard](https://docs.aw
## Usage example
A full example leveraging other community modules is contained in the [examples/basic directory](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/basic). Here's the gist of using it via the Terraform registry:
A full example leveraging other community modules is contained in the [examples/basic directory](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/basic).
Please do not forget to set the provider to the EKS cluster. This is needed to provision the aws_auth configmap in
kube-system. You can also use this provider to create your own kubernetes resources with the terraform kubernetes
provider.
Here's the gist of using it via the Terraform registry:
```hcl
data "aws_eks_cluster" "cluster" {
name = module.eks.cluster_id
}
data "aws_eks_cluster_auth" "cluster" {
name = module.eks.cluster_id
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
load_config_file = false
version = "~> 1.9"
}
module "my-cluster" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "my-cluster"