Terraform apply fails with
* module.eks.null_resource.update_config_map_aws_auth: Error running command 'kubectl apply -f ./config-map-aws-auth_beam-eks.yaml --kubeconfig ./kubeconfig_beam-eks': exit status 1. Output: error: unable to recognize "./config-map-aws-auth_beam-eks.yaml": Unauthorized
This is my configuration for the eks module.
I have a really basic vpc created via terraform-aws-modules/vpc/aws.
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = "beam-eks"
subnets = "${module.vpc.public_subnets}"
vpc_id = "${module.vpc.vpc_id}"
}
Apply succeeds
Upon further investigation, it appears that this is only an issue when I have manage_aws_auth set to true. It turns out that my aws provider uses assume_role, and this module uses local exec loses the assumed role and thus isn't able to execute the operation.
Hi @tonyxiao
We also use assumed roles, like this:
$ aws sts get-caller-identity
{
"UserId": "AROAXXXXXXXXXXX:[email protected]",
"Account": "99999999999",
"Arn": "arn:aws:sts::99999999999:assumed-role/sso-xxxxxxx/[email protected]"
}
To get it to work with the kubeconfig from this terraform module I did this:
~/.aws/config:[profile profile1]
region = eu-west-1
google_config.ask_role = True
google_config.duration = 43200
google_config.role_arn = arn:aws:iam::assumed-role/sso-xxxxxxx/[email protected]
google_config.google_username = [email protected]
google_config.keyring = False
module "cluster1" {
source = "[email protected]:terraform-aws-modules/terraform-aws-eks.git?ref=v1.4.0"
cluster_name = "cluster1"
kubeconfig_aws_authenticator_env_variables = {
AWS_PROFILE = "profile1"
}
Then it works seamlessly. I hope that helps!
Ah sweet, I ended up using
kubeconfig_aws_authenticator_additional_args = ["-r", "${var.aws_authenticator_role}"]
and it works like a charm. It would be awesome to add some notes into the doc for multi-account aws architecture support.
Most helpful comment
Ah sweet, I ended up using
and it works like a charm. It would be awesome to add some notes into the doc for multi-account aws architecture support.