Skip to content
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

Support MFA on AWS #390

Closed
philk opened this issue Oct 10, 2014 · 8 comments
Closed

Support MFA on AWS #390

philk opened this issue Oct 10, 2014 · 8 comments

Comments

@philk
Copy link
Contributor

philk commented Oct 10, 2014

It looks like Terraform doesn't currently support using Multi-factor Auth for AWS (unless I'm missing something). Not currently a major issue for us but we'd love to be able to use it in the future.

Useful links:

@mitchellh
Copy link
Contributor

What sort of workflow or user experience are you looking for here? It isn't documented but Terraform accepts the AWS_TOKEN environmental variable, which you can use to set the token.

@mitchellh mitchellh added the waiting-response An issue/pull request is waiting for a response from the community label Oct 10, 2014
@philk
Copy link
Contributor Author

philk commented Oct 10, 2014

I didn't see an AWS_TOKEN variable greping through the source or actually any references to tokens in AWS.

As for workflow, if Terraform could automatically detect that MFA is required and ask for the token that would be amazing...but I'm not really sure how you could do that with the AWS APIs without adding a lot of complexity.

I'm kind of imagining something like specifying MFA=true in the provider and having to set your credentials via environment variables or dropping them into a var file before runtime out of band (similar to the way you have to handle keys already), erroring out if session_token isn't set and multifactor_auth is set.

provider "aws" {
    access_key = "${var.access_key}"
    secret_key = "${var.secret_key}"
    session_token = "${var.session_token}"
    multifactor_auth = true
    region = "${var.aws_region}"
}

If Terraform could respond to just multifactor_auth = true and ask the user for a session token at runtime I think that would be an even more seamless workflow.

@mitchellh
Copy link
Contributor

It is possible, but I think MFA is sufficiently rare (for better or worse, another discussion) that the environmental variable will do. I think its already supported so this is likely just a docs change.

@mitchellh mitchellh added core documentation and removed waiting-response An issue/pull request is waiting for a response from the community core labels Oct 10, 2014
@brianwallace
Copy link

Found it in goamz. Looks like the environmental variable name is AWS_SECURITY_TOKEN.

@sciurus
Copy link

sciurus commented Oct 15, 2014

Will terraform use AWS_SESSION_TOKEN? This is the environment variable that tools build on the AWS SDK read when a user has authenticated with MFA. If so, you could run terraform via aws-mfa.

@koendc
Copy link

koendc commented Jan 13, 2015

In order to use the AWS security token, you need to:

  • provide empty strings for access_key and secret_key:
    provider "aws" {
        access_key = ""
        secret_key = ""
    }
  • Make sure you don't have the environment variables set as mentioned in the terraform documentation
  • Use these environment variables instead: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SECURITY_TOKEN.

@mitchellh
Copy link
Contributor

FIxed

yahyapo pushed a commit to yahyapo/terraform that referenced this issue Mar 13, 2015
@ghost
Copy link

ghost commented Apr 7, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants