Created
July 24, 2019 09:18
-
-
Save raphaelschnaitl/effe6faa0203d1b9f48efd149f0616cd to your computer and use it in GitHub Desktop.
medium.bastion-host.createLambdaRole.ts
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
private createLambdaRole(): iam.Role { | |
const lambdaDocument = new iam.PolicyDocument(); | |
const associateAddressStatement = new iam.PolicyStatement(); | |
associateAddressStatement.addActions("ec2:AssociateAddress"); | |
associateAddressStatement.addResources(); | |
const logStatement = new iam.PolicyStatement() | |
logStatement.addActions("logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"); | |
logStatement.addAllResources() | |
lambdaDocument.addStatements(associateAddressStatement, logStatement); | |
return new iam.Role(this, "LambdaExecutionRole", { | |
assumedBy: new iam.ServicePrincipal("lambda.amazonaws.com"), | |
inlinePolicies: { | |
"AllowAssociateAddress": lambdaDocument | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment