Created
February 25, 2020 15:45
-
-
Save gmariette/4ff8165dbc8a91841c4a467a2fbed5a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| awsAccounts = { | |
| "Account N1": { "id": "123456789", "role": "iam-role", "region": "eu-west-3", "envs": ["env01", "env02", "env03"] }, | |
| } | |
| stsClient = boto3.client('sts') | |
| for awsAccount in awsAccounts: | |
| assumedRoleObject=stsClient.assume_role( | |
| RoleArn="arn:aws:iam::"+awsAccounts[awsAccount]["id"]+":role/"+awsAccounts[awsAccount]["role"], | |
| RoleSessionName="StatusPageSession" | |
| ) | |
| credentials=assumedRoleObject['Credentials'] | |
| ACCESS_KEY=credentials.get("AccessKeyId") | |
| SECRET_KEY=credentials.get("SecretAccessKey") | |
| SESSION_TOKEN=credentials.get("SessionToken") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment