I have been using aws as cloud service and terraform as IaC. It's very annoying to copy paste the credentials frequently. Is there any solution available for that or any work around other to use aws sso?
How to configure aws sso for terraform?
8.9k Views Asked by Aman At
2
There are 2 best solutions below
0

It seems that this is possible without external plugins now, see here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs#shared-configuration-and-credentials-files
Example:
provider "aws" {
profile = "customprofile"
}
Premise
It was my understanding that there is a current issue between AWS SSO (authentication v2) and terraform; that only V1 authentication (access key and secret key) is reliably accepted.
For example, this open PR or this issue or this ongoing referenced merge
Work Around
There are a couple of projects that circumvent this issue by generating V1 creds from AWS SSO.
The one I use is a PyPi library called yawsso.
Try this:
Note
Just make sure you use the right profile with
export AWS_PROFILE=foo
where "foo" would be in~/.aws/config
as[profile foo]
Bonus
yawsso
will log you in on all profiles listed in the AWS config file, so you don't need to log in one-by-one into all profiles required at work