Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy fails when using aws profile #288

Closed
mestuddtc opened this issue Jul 26, 2021 · 4 comments · Fixed by #310
Closed

Deploy fails when using aws profile #288

mestuddtc opened this issue Jul 26, 2021 · 4 comments · Fixed by #310
Assignees

Comments

@mestuddtc
Copy link

Summary

I am following the EKS on AWS setup instructions to evaluate jenkinsx.
I have multiple aws profiles across multiple aws accounts. I set the correct profile to use in the infrastructure repo variables. Running terraform apply fails with an error.

Steps to reproduce the behavior

  1. Set up ~/.aws/credentials with "default" profile in one account and "second" profile in a different account.
  2. Create infrastructure repo https://github.com/jx3-gitops-repositories/jx3-terraform-eks/generate
  3. Set default = "second" for "profile" variable in variables.tf
  4. Run terraform init && terraform apply

Expected behavior

Terraform commands complete successfully.

Actual behavior

Terraform fails with error:

╷
│ Error: local-exec provisioner error
│
│   with module.eks-jx.module.cluster.null_resource.kubeconfig,
│   on .terraform/modules/eks-jx/modules/cluster/main.tf line 150, in resource "null_resource" "kubeconfig":
│  150:   provisioner "local-exec" {
│
│ Error running command 'aws eks update-kubeconfig --name tf-jx-capital-sunfish --region=us-east-1': exit status 254. Output:
│ An error occurred (ResourceNotFoundException) when calling the DescribeCluster operation: No cluster found for name: tf-jx-capital-sunfish.
│

Running aws eks update-kubeconfig --name tf-jx-capital-sunfish --region=us-east-1 --profile second succeeds.

Terraform version

The output of terraform version is:

Terraform v1.0.3
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.51.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/helm v2.2.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.3.2
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

Module version

1.15.37

Operating system

MacOS

@ankitm123
Copy link
Member

ankitm123 commented Jul 30, 2021

We should add the profile argument to that command. You can get around this issue by running:

AWS_PROFILE=second terraform init
AWS_PROFILE=second terraform apply

@mrmarcsmith
Copy link
Contributor

I experienced this same error too, I'm going to throw spaghetti at the wall with a proposed fix and see if it sticks.

ankitm123 pushed a commit that referenced this issue Sep 21, 2021
* added conditional profile

* Add profile variable

* Added profile flag

* Spelling is hard

* removed default to allow ENV override

* add conditional check

* default to null so we can see if it's been set

* Added profile variable to module
@ankitm123
Copy link
Member

This should be fixed now, closing.

@ankitm123 ankitm123 reopened this Sep 21, 2021
@mestuddtc
Copy link
Author

It's working for me now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants