Skip to content

Multiple AWS Accounts with Terraform and Terragrunt

Notifications You must be signed in to change notification settings

kcloud1/awsmulti

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Multiple AWS Accounts with Terraform and Terragrunt

[Source]|(https://github.com/cobusbernard/hashitalks-africa-demo)

Testing of AWS multi account for S3 buckets

Run as user [works]

Run as role [checking]

echo "Using $AWS_PROFILE user"
aws sts get-caller-identity

subaccount=516890729523
nameOfMyrole=OrganizationAccountAccessRole
aws_credentials=$(aws sts assume-role --role-arn arn:aws:iam::${subaccount}:role/${nameOfMyrole} --role-session-name "RoleSession1" --output json)

export AWS_ACCESS_KEY_ID=$(echo $aws_credentials|jq '.Credentials.AccessKeyId'|tr -d '"')
export AWS_SECRET_ACCESS_KEY=$(echo $aws_credentials|jq '.Credentials.SecretAccessKey'|tr -d '"')
export AWS_SESSION_TOKEN=$(echo $aws_credentials|jq '.Credentials.SessionToken'|tr -d '"')

echo "Using $nameOfMyrole Role"
aws sts get-caller-identity
echo $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AWS_SESSION_TOKEN

Unset above variables

unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
echo $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
echo "Using $AWS_PROFILE user"
aws sts get-caller-identity

About

Multiple AWS Accounts with Terraform and Terragrunt

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 64.3%
  • Makefile 35.7%