-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 AWS CLI v2 AWS Single Sign-On #10851
Comments
Thanks for submitting this issue, @e-moshaya. I'd like to clarify what you're seeing. When you're trying to use the AWS SSO credentials with Terraform, what are the commands you execute on the command line? Does calling |
Hi @gdavison lookslike aws2 sso doesn't use ~/.aws/credentials file at all as all I have in my
The ~/.aws/config has:
The output for
However, the output for aws v1 is not working:
|
As a workaround, if either of the I do see that https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html says that the v2 CLI is not ready for production use, but this is definitely something that needs to be implemented. |
@gdavison both sso and cli are folders with cache files in them.. There are no shared credentials files involved. |
looking forward to it |
FWIW, in the meantime this wrapper exists that will generate temporary credentials using aws2 then export them to the current session
https://github.com/linaro-its/aws2-wrap (found here aws/aws-cli#4668). It works great when you only need a single set of credentials for a deployment, but I haven't figured out a way to generate a second set as needed (e.g. separate profiles for providers and backends). |
AWS CLI v2 is now generally available. https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/ |
Is there any timeline to this feature? Would be cool to see when this feature would be supported natively by terraform aws provider. We have been using https://github.com/ddimitrioglo/aws-saml implementation for various automations, but embedding |
In my cursory looking, its my understanding that the AWS Go SDK will need to first implement support for the That being said, it is very likely that the Terraform AWS Provider cannot (or at least should not) implement the full SSO login workflow via opening a browser on expired SSO tokens unless there is support in the AWS Go SDK for this as well. |
The AWS SDK GO v2 is in a different repo: https://github.com/aws/aws-sdk-go-v2 It doesn't seem to have the same sessions and config stuff as the other sdk. Their example looks pretty different. |
Looks like CLI now supports SSO: https://docs.aws.amazon.com/cli/latest/reference/sso/index.html#cli-aws-sso |
Hi everyone, i read @borrell solution but, the solution from and now i fill I solve my problema until terraform solve this problem like |
I took at stab at writing a credential_process to solve this problem, which means you won't need to call scripts randomly, most applications are already smart enough to properly re-call the process when the credentials expire: https://github.com/flyinprogrammer/aws-sso-fetcher it also does some caching so that sequential calls use a file until the credential expires. |
We had to use terraform with AWS account which supported SSO login only. Since AWS access key and secret expire, we've created a bunch of scripts to workaround the issue. I thought I'd share them here you might find it useful. |
Nice @mknapik Though I recommend you take a look at @flyinprogrammer 's work above yours... basically it is similar to the ecr-cred-helper for docker login. Quite.. a lovely workaround! |
While the workaround is nice, it would be great to have this supported natively. Which project is this awaiting right now and are there any issues we can go vote on ? |
But better than my terraform not functional. |
You should login to an account that allows you to assume roles to both accounts. |
That's not always possible, and not everyone agrees with this point of view. For me, we are not going to ever have that ability - I need to use multiple accounts concurrently. None of the terraform configuration is in the other accounts, and you can't assume-role between those accounts. |
You have SSO right? |
I think you're talking about the other form of SSO where you'd use AssumeRole. This is about AWS SSO, which does not involve AssumeRole to authenticate. You use a specific profile to access an account and a specific permissionset like this:
For me to access resources in account A, I need profile A While technically I suppose I could then do an AssumeRole from Account A to Account B, this would require cross-account trusts/roles that permit this. |
Hi @e-moshaya, as you know, as far as know AWS CLI v2 support for AWS SSO generated temporary credentials under ~/.aws/cli/cache folder which in many cases end up with "credentials not found" issue. I want to share - with people who want to solve this issue - the link to the GitHub repo of the Open Source project my team is working on. With new support to AWS SSO, it allows you to retreive - prior configuration of the Portal URL - a list of IAM Role that the AWS SSO user - you are logging in with - has access to. From this flat list you can generate temporary credentials with a click. Well, there are other details that you can find here |
I am not sure if this has been mentioned before, but this workaround worked for me:
|
@prnvkbr Those credentials, like all SSO credentials, are short lived. While you can do that, others have already provided examples of tools that will also do this. |
While the suggestions of workarounds and tools to make Terraform work with AWS SSO are appreciated, can we focus on the issue at hand, namely that the Terraform provider doesn't support it natively? Maybe by simply updating to a newer aws-go-sdk version? As suggested in #10851 (comment) , aws-go-sdk can handle SSO credentials. Is someone working on this already? |
Another workaround in case it helps anyone:
|
AWS Go SDK version 1.37.0 now includes native SSO cached credential support: aws/aws-sdk-go#3755 Will work on coordinating this dependency update. |
…17340) * build(deps): bump github.com/aws/aws-sdk-go from 1.36.28 to 1.37.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.36.28 to 1.37.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md) - [Commits](aws/aws-sdk-go@v1.36.28...v1.37.0) Signed-off-by: dependabot[bot] <[email protected]> * Update CHANGELOG for #17340 Reference: #10851 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brian Flad <[email protected]>
Support for AWS Single-Sign On (SSO) cached credentials has been merged and will release with version 3.26.0 of the Terraform AWS Provider later today. When the release is available, an automated release comment will be sent to this issue. There are no future plans to support the AWS SSO login flow (e.g. web browser interaction) in Terraform CLI or the Terraform AWS Provider due to the complexity of operations across products. Feature requests for such functionality will be closed. Please note that neither Terraform CLI nor the Terraform AWS Provider will initiate or perform the AWS SSO login flow. It is expected that you have already performed the SSO login flow using AWS CLI with the You can use configure AWS SSO credentials from the AWS shared configuration file by specifying the required keys in the profile:
For example, the following defines a profile "devsso" and specifies the AWS SSO parameters that defines the target account, role, sign-on portal, and the region where the user portal is located. Note: all SSO arguments must be provided, or an error will be returned.
Additional Resources Equivalent update for the Terraform S3 Backend can be found here: hashicorp/terraform#27620 (targeting next Terraform CLI 0.15 release and can be backported if another Terraform CLI 0.14 release is expected) |
This has been released in version 3.26.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I think that's a perfectly reasonable decision. While it does require the user to install another tool besides Terraform to perform authentication, at least supporting credentials managed by other (standard) tools is probably sufficient for most users. Thank you very much for the work! |
Now as SSO is enabled, can this documentation be updated? |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
https://aws.amazon.com/about-aws/whats-new/2019/11/use-the-aws-cli-v2-preview-with-aws-single-sign-on-to-increase-developer-productivity/
https://aws.amazon.com/blogs/developer/aws-cli-v2-now-supports-aws-single-sign-on/
I am using aws 2 with SSO integration to authenticate via command line. However, terraform is not recognising the configuration with the error below:
The text was updated successfully, but these errors were encountered: