@@ -10,7 +10,7 @@ terraform {
1010 # A "required_providers" block needs to be added to all sub-modules in order to use a custom "source" and "version".
1111 # Otherwise, the sub-module will use defaults, which in our case means an empty provider config.
1212 # https://github.com/hashicorp/terraform/issues/27361
13- kubernetes-released = {
13+ kubernetes = {
1414 source = " hashicorp/kubernetes"
1515 version = " >= 2.0.2"
1616 }
@@ -29,13 +29,12 @@ data "aws_eks_cluster" "default" {
2929 name = module. cluster . cluster_id
3030}
3131
32- # This configuration relies on a plugin binary to fetch the token to the EKS cluster.
33- # The main advantage is that the token will always be up-to-date, even when the `terraform apply` runs for
34- # a longer time than the token TTL. The downside of this approach is that the binary must be present
35- # on the system running terraform, either in $PATH as shown below, or in another location, which can be
36- # specified in the `command`.
37- # See the commented provider blocks below for alternative configuration options.
38- provider "kubernetes-released" {
32+ data "aws_eks_cluster_auth" "default" {
33+ name = module. cluster . cluster_id
34+ }
35+
36+ # Test exec plugin based auth.
37+ provider "kubernetes" {
3938 host = data. aws_eks_cluster . default . endpoint
4039 cluster_ca_certificate = base64decode (data. aws_eks_cluster . default . certificate_authority [0 ]. data )
4140 exec {
@@ -52,15 +51,15 @@ provider "kubernetes-local" {
5251 config_path = module. cluster . kubeconfig_filename
5352}
5453
54+ # Test token data source based auth.
5555provider "helm" {
56+ experiments {
57+ manifest = true
58+ }
5659 kubernetes {
5760 host = data. aws_eks_cluster . default . endpoint
5861 cluster_ca_certificate = base64decode (data. aws_eks_cluster . default . certificate_authority [0 ]. data )
59- exec {
60- api_version = " client.authentication.k8s.io/v1alpha1"
61- args = [" eks" , " get-token" , " --cluster-name" , module . vpc . cluster_name ]
62- command = " aws"
63- }
62+ token = data. aws_eks_cluster_auth . default . token
6463 }
6564}
6665
@@ -72,7 +71,6 @@ module "vpc" {
7271}
7372
7473module "cluster" {
75- providers = {kubernetes = kubernetes- released}
7674 source = " terraform-aws-modules/eks/aws"
7775 version = " 14.0.0"
7876
@@ -83,7 +81,6 @@ module "cluster" {
8381 cluster_version = var. kubernetes_version
8482 manage_aws_auth = true
8583 write_kubeconfig = true
86- kubeconfig_name = " kubeconfig"
8784
8885 # See this file for more options
8986 # https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/local.tf#L28
@@ -107,7 +104,6 @@ module "cluster" {
107104}
108105
109106module "kubernetes-config" {
110- providers = {kubernetes = kubernetes- local}
111107 cluster_name = module. cluster . cluster_id # creates dependency on cluster creation
112108 source = " ./kubernetes-config"
113109 k8s_node_role_arn = module. cluster . worker_iam_role_arn
0 commit comments