forked from aws-samples/aws-safe-lambda-deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
56 lines (53 loc) · 1.59 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An example SAM template for Lambda Safe Deployments.
Resources:
returnS3Buckets:
Type: AWS::Serverless::Function
Properties:
Handler: returnS3Buckets.handler
Runtime: nodejs6.10
AutoPublishAlias: live
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "s3:ListAllMyBuckets"
Resource: '*'
DeploymentPreference:
Type: Linear10PercentEvery1Minute
Hooks:
PreTraffic: !Ref preTrafficHook
Events:
Api:
Type: Api
Properties:
Path: /test
Method: get
preTrafficHook:
Type: AWS::Serverless::Function
Properties:
Handler: preTrafficHook.handler
Policies:
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "codedeploy:PutLifecycleEventHookExecutionStatus"
Resource:
!Sub 'arn:aws:codedeploy:${AWS::Region}:${AWS::AccountId}:deploymentgroup:${ServerlessDeploymentApplication}/*'
- Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource: !Ref returnS3Buckets.Version
Runtime: nodejs6.10
FunctionName: 'CodeDeployHook_preTrafficHook'
DeploymentPreference:
Enabled: false
Timeout: 5
Environment:
Variables:
NewVersion: !Ref returnS3Buckets.Version