Last active
October 19, 2023 08:52
-
-
Save benbridts/b9d251fef3b341ccd0b9e5d5502640ea to your computer and use it in GitHub Desktop.
AWS Lambda Function with a generated name, using a CloudFormation-managed LogGroup
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
Resources: | |
Role: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Action: sts:AssumeRole | |
Effect: Allow | |
Principal: {Service: lambda.amazonaws.com} | |
Function: | |
Type: AWS::Lambda::Function | |
Properties: | |
Code: | |
ZipFile: "#todo" | |
Handler: "index.handler" | |
Role: !GetAtt Role.Arn | |
Runtime: "python3.8" | |
LogGroup: | |
Type: AWS::Logs::LogGroup | |
Properties: | |
LogGroupName: !Sub "/aws/lambda/${Function}" | |
LogPolicy: | |
Type: AWS::IAM::Policy | |
Properties: | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Action: | |
- logs:CreateLogStream | |
- logs:PutLogEvents | |
Effect: Allow | |
Resource: !GetAtt LogGroup.Arn | |
PolicyName: !Sub "${Function}-logs" | |
Roles: [!Ref Role] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment