-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Terraform S3 Remote State using only credential profiles (no default credentials) #8911
Comments
I did some more testing on this - what I've found is that I configured my AWS credentials and config files based on Amazon's documented method for using cross account role assumption. Essentially the access key id and secret key go in the credentials file while the role assumption configuration goes into the config file. Ex: [admin]
aws_access_key_id = <redacted>
aws_secret_access_key = <redacted> ~/.aws/config [default]
region = us-east-1
output = json
[preview]
cloudfront = true
[profile one]
role_arn = <redacted>
source_profile = admin I misunderstood the Terraform AWS provider documentation - I was under the impression that it read both the credentials file and the config file, however my issue noted above is because it only reads the credentials file. Using the assume role configuration block for the AWS provider works properly. It's too bad Terraform can't just read the config file in addition to the credentials file because then I wouldn't have to configure the role assumption as much (once for each Terraform project). Instead I could just configure the AWS CLI and let Terraform use that existing configuration. |
Just ran into this issue when trying to access state from an s3 bucket defined in another AWS account. This would seem like important functionality for another account to export a root output, and be accessible via another account (e.g.: security group IDs or whatever else). I believe the only workaround to this would be to write an IAM policy to allow access to the S3 bucket in the other account with the account/profile from the default aws provider. Not really a solution :( |
This happens in 0.9.2 when just trying to configure S3 Remote State storage as well. The |
@farvour what I ended up doing is setting the
@mikereinhold does this solve your issue as well? |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform remote state S3 backend does not properly retrieve remote state using the profile config option alone if there is no default AWS credentials.
Example, consider a multiple account configuration using assumed administrative roles across accounts. I may not want to have a [default] profile configured in ~/.aws/credentials, set in Terraform, or in environment variables. For example, maybe because I want to prevent accidentally creating resources in the account that has the IAM account when the correct provider is not specified for each resource.
If I only specify the S3 config profile, the data source fails to find AWS credentials. If I add the provider line, terraform complains that the provider does not support terraform_remote_state.
Terraform Version
Terraform v0.7.3
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Terraform should use the specified provider for the Terraform remote state data source.
Alternatively, in order to avoid needing to specify the provider at all, the data source should consult the specific config (in this case S3 config) in order to determine the correct provider. This would probably be preferable for DRY.
Actual Behavior
If no provider is specified, just using the S3 config profile:
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider
If the provider is specified (with or without the S3 config profile):
Steps to Reproduce
Configure a terraform_remote_state as described above, with an S3 config profile (with or without the provider line, pending consideration for which approach is "correct").
Ensure an AWS provider using alias admin exists, referencing an AWS Config profile admin. No default AWS credentials should be found (no env vars, no default AWS config profile / credentials, no default Terraform provider that supplies the creds.
terraform plan
The text was updated successfully, but these errors were encountered: