atlantis: assume_role does not work
The docs on installing and configuring Atlantis are really super thin, and useless. As a result I try to configure assume_role, which then fails at runtime:
Problem
In my Pull Request on Bitbucket server I type this comment
atlantis plan -d sftp
and then I get back the following result:
running "/atlantis-data/bin/terraform0.12.16 plan -input=false -refresh -no-color -out \"/atlantis-data/repos/DevOps/terraform-prod/1/default/sftp/default.tfplan\"" in "/atlantis-data/repos/DevOps/terraform-prod/1/default/sftp": exit status 1
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.
------------------------------------------------------------------------
Error: The role "arn:aws:iam::<account>:role/myrole" cannot be assumed.
There are a number of possible causes of this - the most common are:
* The credentials used in order to assume the role are invalid
* The credentials do not have appropriate permission to assume the role
* The role ARN is not valid
on connections.tf line 1, in provider "aws":
1: provider "aws" {
I am specifying my provider in terraform like this:
provider "aws" {
region = "us-west-2"
assume_role {
role_arn = "arn:aws:iam::<AccountID>:role/myrole"
}
}
The docs https://www.runatlantis.io/docs/provider-credentials.html#aws-specific-info
are pretty useless here and do not provide a clear path forward on how to configure this.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 23 (13 by maintainers)
atlantis plan
@grimm26 I’m having the exact same issue as @mbolek and keep going in circles looking at the different pieces of the configuration to get this to work…
Would you please be able to provide feedback on this configuration? Here is a quick rundown of the configuration I have (I’ve tried quite a few variations) :
Policy assigned to Atlantis Fargate container task execution role, in account 111111111111
Role Trust Policy in the Tenant account 222222222222 (where I want Atlantis to create resources) :
Terraform provider block
Terraform backend block
Any guidance on how you get this to work or any differences you see between our configs would be appreciated.
Thanks
I have role assumption working. Its not a limitation with atlantis. If you create a primary role for atlantis that it assumes by default then create secondary roles in each account that allow the primary role to assume it, then you can use the assume_role block’s role_arn to assume each secondary role.
Amazon has this documented under role chaining
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html
We ran into some assumrole issues recently running Atlantis on EKS and leveraging custom workflows for the assumeroles. We ended up tricking the AWS SDK into thinking it’s not running in AWS by defining
AWS_METADATA_URLenvironment variable to some fake endpointexport AWS_METADATA_URL="http://localhost/not/existent/url"so it would properly prioritize~/.aws/credentialsSee this comment for the AWS provider for more info: https://github.com/terraform-providers/terraform-provider-aws/issues/5018#issuecomment-549601523