You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/safe_lambda_deployments.rst
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,9 @@ resource:
105
105
# Validation Lambda functions that are run before & after traffic shifting
106
106
PreTraffic: !Ref PreTrafficLambdaFunction
107
107
PostTraffic: !Ref PostTrafficLambdaFunction
108
+
# Provide a custom role for CodeDeploy traffic shifting here, if you don't supply one
109
+
# SAM will create one for you with default permissions
110
+
Role: !Ref IAMRoleForCodeDeploy # Parameter example, you can pass an IAM ARN
108
111
109
112
AliasErrorMetricGreaterThanZeroAlarm:
110
113
Type: "AWS::CloudWatch::Alarm"
@@ -162,6 +165,7 @@ resource:
162
165
FunctionName: 'CodeDeployHook_preTrafficHook'
163
166
DeploymentPreference:
164
167
Enabled: false
168
+
Role: ""
165
169
Environment:
166
170
Variables:
167
171
CurrentVersion: !Ref MyLambdaFunction.Version
@@ -176,6 +180,7 @@ CloudFormation, the following happens:
176
180
- During traffic shifting, if any of the CloudWatch Alarms go to *Alarm* state, CodeDeploy will immediately flip the Alias back to old version and report a failure to CloudFormation.
177
181
- After traffic shifting completes, CodeDeploy will invoke the **PostTraffic Hook** Lambda function. This is similar to PreTraffic Hook where the function must callback to CodeDeploy to report a Success or a Failure. PostTraffic hook is a great place to run integration tests or other validation actions.
178
182
- If everything went well, the Alias will be pointing to the new Lambda Version.
183
+
- If you supply the "Role" argument to the DeploymentPreference, it will prevent SAM from creating a role and instead use the provided CodeDeploy role for traffic shifting
179
184
180
185
NOTE: Verify that your AWS SDK version supports PutLifecycleEventHookExecutionStatus. For example, Python requires SDK version 1.4.8 or newer.
181
186
@@ -294,7 +299,7 @@ Internally, SAM will create the following resources in your CloudFormation stack
294
299
SAM template belongs to its own Deployment Group.
295
300
- Adds ``UpdatePolicy`` on ``AWS::Lambda::Alias`` resource that is
296
301
connected to the function's Deployment Group resource.
297
-
- One ``AWS::IAM::Role`` called "CodeDeployServiceRole".
302
+
- One ``AWS::IAM::Role`` called "CodeDeployServiceRole", if no custom role is provided
298
303
299
304
CodeDeploy assumes that there are no dependencies between Deployment Groups and hence will deploy them in parallel.
300
305
Since every Lambda function is to its own CodeDeploy DeploymentGroup, they will be deployed in parallel.
0 commit comments