Skip to content

Instantly share code, notes, and snippets.

@maguzzi
Created November 21, 2023 22:27
Show Gist options
  • Save maguzzi/0ac13a0588a736993e6a6dbcc81be078 to your computer and use it in GitHub Desktop.
Save maguzzi/0ac13a0588a736993e6a6dbcc81be078 to your computer and use it in GitHub Desktop.
Child lambda template
AWSTemplateFormatVersion: "2010-09-09"
Description: Lambda@Edge function stack
Parameters:
Stage:
Type: String
AllowedValues:
- dev
- prod
Resources:
LambdaEdge:
Properties:
Runtime: nodejs14.x
Handler: index.handler
Code:
S3Bucket: "bucket-for-artifacts"
S3Key: "lambda-edge.zip"
Role: !GetAtt LambdaRoleForCF.Arn
Type: "AWS::Lambda::Function"
LambdaFunctionVersion:
Type: AWS::Lambda::Version
Properties:
FunctionName: !Ref LambdaEdge
Description: v1
LambdaRoleForCF:
Type: "AWS::IAM::Role"
Properties:
RoleName: !Join [ "-", [ "LambdaRoleForCF", !Ref Stage ] ]
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- edgelambda.amazonaws.com
Action: "sts:AssumeRole"
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
Outputs:
LambdaFunctionVersionOutput:
Description: LambdaFunctionVersion Arn
Value:
Ref: LambdaFunctionVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment