Created
April 13, 2022 19:20
-
-
Save zaireali649/2d8f1785c0b6c32b07c662a31b9f7107 to your computer and use it in GitHub Desktop.
Create a Sample IAM Role for a Lambda
This file contains 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
### 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