terragrunt: Terragrunt does not support AWS SSO with automatic token refresh
terraform --version
Terraform v1.2.9
on darwin_arm64
+ provider registry.terraform.io/datadog/datadog v3.19.1
+ provider registry.terraform.io/hashicorp/aws v4.45.0
Your version of Terraform is out of date! The latest version
is 1.3.7. You can update by downloading from https://www.terraform.io/downloads.html
terragrunt --version
terragrunt version v0.39.0
~/.aws/config
[profile dev-sso]
sso_session = sso
sso_start_url = https://my-company/start
sso_region = eu-west-1
sso_account_id = 123456789
sso_role_name = AWSAdministratorAccess
[sso-session sso]
sso_region = eu-west-1
sso_start_url = https://my-company/start
sso_registration_scope = sso:account:access
Remote state config
remote_state {
backend = "s3"
config = {
bucket = "${local.env}-my-bucket"
region = "us-east-1"
key = "${path_relative_to_include()}/terraform.tfstate"
encrypt = true
dynamodb_table = "${local.env}-terraform-state-lock"
profile = "dev-sso"
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}
terragrunt init -migrate-state
Initializing the backend...
Backend configuration changed!
Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.
╷
│ Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.
│
│ Please see https://www.terraform.io/docs/language/settings/backends/s3.html
│ for more information about providing credentials.
│
│ Error: NoCredentialProviders: no valid providers in chain. Deprecated.
│ For verbose messaging see aws.Config.CredentialsChainVerboseErrors
│
╵
aws sts get-caller-identity
{
"UserId": "my_user_id",
"Account": "123456789",
"Arn": "arn:aws:sts::123456789:assumed-role-bla-bla-bla
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 7
- Comments: 19 (6 by maintainers)
This should be reopened. The issue in terraform is now fixed in
Terraform v1.6.0-rc1but the issue is still present in terragrunt. You can test that by using agenerateblock instead of aremote_state. When usinggenerateterraform won’t complain about SSO but it is going to complain the S3 bucket does not exist. In order to let terragrunt take care of creating the backend resources you need to switch to using aremote_stateand that is when the issue appears.For me that means there is a problem in the terragrunt auth mechanism with AWS in the bit of code that makes sure the backend resources are created.
The workaround still works by moving
sso_start_urlandsso_regionto the profile entry in aws config. For more details see: https://github.com/hashicorp/terraform/issues/32465Resolved in v0.53.1 release.
Hi @lebenitza, Ah you are right,
terragruntuses AWS for the things you mentioned. Since this issue has been fixed interraform, it makes sense to fix it interragrungas well. The AWS library should be updated interragruntto support SSO, I’ll work on it.Please see my message… The issue is still in terragrunt with the automatic creation of backend S3 store and DynamoDB lock table.
Just want to note it’s working for me. Running v0.53.2 Thanks @levkohimins !
Any info on this? I have a similar config in ~/.aws/coinfig
and when i try to run terragrunt plan I get
@levkoburburas will terraform/terragrunt automatically refresh the authentication tokens when they expire? For reference: https://docs.aws.amazon.com/cli/latest/userguide/sso-configure-profile-token.html