-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
AWS Session Token not working #3243
Comments
I had a similar issue. When I dropped the quotes it worked. Which shouldn't be IMO, but that was the case. Try that to see if it fixes it. |
I tried with quotes, without quotes and single quotes. Still doesn't work. Using 0.6.6 |
Use AWS_SECURITY_TOKEN and NOT AWS_SESSION_TOKEN |
I am experiencing the same bug. Terraform reads my This doesn't work on ubuntu ec2 instance: This does work: All of the above works on my osx box. Versions: $ terraform -v
Terraform v0.6.3
Your version of Terraform is out of date! The latest version
is 0.6.6. You can update by downloading from www.terraform.io
$ aws --version
aws-cli/1.2.9 Python/3.4.0 Linux/3.13.0-48-generic |
If there is a bit of code someone could point me to, I'd me more than happy to attempt a PR. This bug is kind of a bummer. |
Ok so after trying a lot here is the conclusion I have reached... export AWS_ACCESS_KEY_ID=SOMETHING-WITHOUT-QUOTES This seems to work on Macs and Linux with terraform any version. |
Going to merge this back down with #2693 - we'll get this looked at soon. |
In case anybody comes across this, and has a similar situation to me, I find the above language very very confusing, and specifically: A "session token" is that given out by STS in response to an AssumeRole() call. It can be used within Terraform by defining AWS_SESSION_TOKEN environment variable beforehand:
or better still... defining aws_session_token within $HOME/.aws/credentials, using an aws configure line like:
The boto framework seems to use an incorrect terminology (in case anyone is using that in conjunction with terraform like me, and calls it an aws_security_token instead). This can exist in $HOME/.aws/credentials as aws_security_token, but you cannot set it using aws configure as above, because it is not an AWS approved variable-name. Boto seems to be basically wrong in this case (or maybe out of date). You can get it working with the boto framework by setting AWS_SECURITY_TOKEN
(yes I really did mean to set AWS_SECURITY_TOKEN to the value of aws_session_token, thats the massive confusion from the boto framework. And just to confuse matters, Terraform implements its own AWS_SECURITY_TOKEN, which is something else entirely - it is the MFA token you might present if your user login requires an MFA token. I hope this clears up the naming around these variables for someone else. I found it all very confusing.. |
I'm having the exact same problem in 0.6.9. But funny that it wasnt a problem in 0.6.8 or 0.6.7. Anyone else experience this? I'm exporting the following and somehow the new release broke it...
All i get back is the InvalidClientTokenId error. Any clue? |
At some point a feature was added that makes the IAM GetUser call to test for valid credentials. If you are calling terraform with dynamic credentials generated by IAM GetSessionToken, those credentials cannot be used to make IAM calls unless you are using MFA. The AWS docs say: "Cannot call IAM APIs unless MFA information is included with the request." CLI call confirms it:
It would be nice to be able to session tokens if you weren't using terraform to manage AWS IAM resources. I am guessing the appropriate way to address this would be to use AssumeRole and use those credentials. |
Hi, It worked for me when i triggered "aws configure" and setting all the values again. |
it did not work when i saved the creds directly in the config file. But when i set it through the cli using aws configure it started working. |
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. |
Experiencing an issue in which AWS Session Token (STS) works using the aws cli but not via Terraform.
This works:
This doesn't:
I've verified it isn't pulling creds from any other variables (like tfvars or ~/.aws), and that the account/region matches. I've also tried exporting the env vars first instead of inline.
The text was updated successfully, but these errors were encountered: