Last active
October 2, 2019 21:51
-
-
Save alexcasalboni/7dcc74da977b0e531638b99dbf8899c8 to your computer and use it in GitHub Desktop.
AWS CodeDeploy - Lambda pre-traffic hook (YAML)
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
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myFunctionToBeDeployed: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
AutoPublishAlias: live | |
DeploymentPreference: | |
Type: Linear10PercentEvery1Minute | |
Hooks: | |
PreTraffic: !Ref preTrafficHook | |
# ... | |
# all the other properties here | |
# ... | |
preTrafficHook: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: preTrafficHook.handler | |
Runtime: nodejs8.10 | |
DeploymentPreference: | |
Enabled: false | |
Environment: | |
Variables: | |
NewVersion: !Ref myFunctionToBeDeployed.Version | |
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 myFunctionToBeDeployed.Version | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment