Skip to content

Instantly share code, notes, and snippets.

@zaireali649
Created April 13, 2022 19:20
Show Gist options
  • Save zaireali649/2d8f1785c0b6c32b07c662a31b9f7107 to your computer and use it in GitHub Desktop.
Save zaireali649/2d8f1785c0b6c32b07c662a31b9f7107 to your computer and use it in GitHub Desktop.
Create a Sample IAM Role for a Lambda
### Create Trust Policy for IAM Role
import json
trust_policy = json.dumps({
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
})
### Create IAM Role
client_iam = boto3.client('iam')
response_create_role = client_iam.create_role(
RoleName='lambda-role-boto3',
AssumeRolePolicyDocument=trust_policy
)
role_arn = response_create_role['Role']['Arn']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment