Skip to content

Commit 651550c

Browse files
martysweetjlhood
authored andcommitted
fix(examples): Lambda@Edge Role Required (#797)
1 parent 7dbd4a9 commit 651550c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/2016-10-31/lambda_edge/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,34 @@ LambdaEdgeFunctionSample:
1111
CodeUri: src/
1212
Runtime: nodejs6.10
1313
Handler: index.handler
14+
Role: !GetAtt LambdaEdgeFunctionRole.Arn
1415
Timeout: 5
1516
# More info at https://github.com/awslabs/serverless-application-model/blob/master/docs/safe_lambda_deployments.rst
1617
AutoPublishAlias: live
1718
```
1819
20+
We must also create a custom IAM Role which allows `lambda.amazonaws.com` and `edgelambda.amazonaws.com` services to assume the role and execute the function.
21+
22+
```yaml
23+
LambdaEdgeFunctionRole:
24+
Type: "AWS::IAM::Role"
25+
Properties:
26+
Path: "/"
27+
ManagedPolicyArns:
28+
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
29+
AssumeRolePolicyDocument:
30+
Version: "2012-10-17"
31+
Statement:
32+
- Sid: "AllowLambdaServiceToAssumeRole"
33+
Effect: "Allow"
34+
Action:
35+
- "sts:AssumeRole"
36+
Principal:
37+
Service:
38+
- "lambda.amazonaws.com"
39+
- "edgelambda.amazonaws.com"
40+
```
41+
1942
We can now configure our [Cloudfront Distribution Lambda Association Property](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-lambdafunctionassociation.html) to always reference the latest available Lambda Function Version ARN:
2043

2144
```yaml

0 commit comments

Comments
 (0)