尝试在Okta中使用Terragrunt(terraform)

时间:2018-07-24 02:23:22

标签: terraform okta terragrunt

我正在尝试利用Terragrunt中Okta的使用,担任这个角色时我会遇到很多麻烦。 我的〜/ .aws / config文件

aws_saml_url = home/amazon_aws/XXXXXXXXX/XXXXXXXXX

[profile assume-admin]
role_arn = arn:aws:iam::XXXXXXXXX:role/assumeAdmin
region = us-west-2

[profile dev]
source_profile = assume-admin
role_arn = arn:aws:iam::XXXXXXXXX:role/adminUser

没有terragrunt,仅使用Terraform和Okta,我看不到任何问题。

$ aws-okta exec dev -- bash
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.terraform_remote_state.bastion: Refreshing state...
data.terraform_remote_state.vpc: Refreshing state...
data.terraform_remote_state.bastion: Refreshing state...
data.terraform_remote_state.vpc: Refreshing state...
data.aws_caller_identity.current: Refreshing state...

SNIP

Plan: 0 to add, 2 to change, 0 to destroy.

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

现在使用Terragrunt

terragrunt plan
[terragrunt] [/Users/user/dev/infrastructure/terraform/accounts/dev/us-west-2/dev/app] 2018/07/23 17:32:56 Running command: terraform --version
[terragrunt] 2018/07/23 17:32:56 Reading Terragrunt config file at /Users/user/dev/infrastructure/terraform/accounts/dev/us-west-2/dev/app/terraform.tfvars
[terragrunt] 2018/07/23 17:32:56 Backend s3 has not changed.
[terragrunt] 2018/07/23 17:32:56 Error initializing session: SharedConfigAssumeRoleError: failed to load assume role for arn:aws:iam::XXXXXXXXX:role/adminUser, source profile has no shared credentials
[terragrunt] 2018/07/23 17:32:56 Unable to determine underlying exit code, so Terragrunt will exit with error code 1

谢谢。

1 个答案:

答案 0 :(得分:2)

执行AWS_CONFIG_FILE=/dev/null后设置aws-okta exec takt-dev -- bash可以解决此问题,该加载了我的AWS_ *凭证/变量。

使用AWS_PROFILE=PROFILE_NAME或用unset AWS_*定义shell变量将返回上面提到的错误。

仅供参考。我正在运行Terraform v0.11.7