gcloud auth application-default login
A web browser should open up, asking you to authorize access .
You can set up a default tfvars for the input. For instance
project_id = "internal-lab"
aws_identity_pool_info = {
internal-lab = {
aws_acct_name = "sandbox-01"
aws_acct_id = 123456789
role_arn = "arn:aws:sts::123456789:assumed-role/gcp-admin"
}
}
run terraform apply
with your default gcloud creds
After running in your outputs you'll have a map between an identity pool and an AWS role.
We'll need the identity pool id to setup the credentials config.
run terraform output
and get the command to generate a config file.
You should see something like
pool_provider_info = {
"internal-lab" = {
"generated_cred_config_cmd" = <<-EOT
gcloud iam workload-identity-pools create-cred-config \
projects/1040700731286/locations/global/workloadIdentityPools/aws-internal-lab/providers/aws-sandbox-02-internal-lab \
--service-account=tf-sa-internal-lab@internal-lab.iam.gserviceaccount.com \
--output-file=internal-lab.aws.config.json \
--aws
EOT
.
.
.
You can then use that command to generate a config that will work with the the google-auth python package > 1.27.0 Set the environment variable to the name of the output file generated and you can use your aws credentials to login
export GOOGLE_APPLICATION_CREDENTIALS=internal-lab.aws.config.json
Note that it doesn't appear at present that terraform can use those same creds