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
[](https://codecov.io/gh/awslabs/serverless-application-model)
3
4
4
5

5
6
@@ -10,16 +11,11 @@ This GitHub project is the starting point for AWS SAM. It contains the SAM speci
10
11
11
12
The SAM specification and implementation are open sourced under the Apache 2.0 license. The current version of the SAM specification is available at [AWS SAM 2016-10-31](versions/2016-10-31.md).
12
13
13
-
14
-
## Creating a serverless application using SAM
15
-
To create a serverless application using SAM, first, you create a SAM template: a JSON or YAML configuration file that describes your Lambda functions, API endpoints and the other resources in your application. Then, you test, upload, and deploy your application using the [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli). During deployment, SAM automatically translates your application’s specification into CloudFormation syntax, filling in default values for any unspecified properties and determining the appropriate mappings and invocation permissions to setup for any Lambda functions.
16
-
17
-
[Read the How-To Guide](HOWTO.md) and see [examples](examples/) to learn how to define & deploy serverless applications using SAM.
18
-
14
+
Documentation about using AWS SAM to define, test, and deploy serverless applications is available at [AWS Serverless Application Model Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html).
19
15
20
16
## Contributing new features and enhancements to SAM
21
17
You can build serverless applications faster and further simplify your development of serverless applications by defining new event sources, new resource types, and new parameters within SAM. Additionally, you can modify SAM to integrate it with other frameworks and deployment providers from the community for building serverless applications.
22
18
23
19
[Read the Development Guide](DEVELOPMENT_GUIDE.rst) for in-depth information on how to start making changes.
24
20
25
-
[Join the SAM developers channel (#samdev) on Slack](https://awssamopensource.splashthat.com/) to collaborate with fellow community members and the AWS SAM team.
21
+
[Join the SAM developers channel (#samdev) on Slack](https://join.slack.com/t/awsdevelopers/shared_invite/enQtMzg3NTc5OTM2MzcxLTdjYTdhYWE3OTQyYTU4Njk1ZWY4Y2ZjYjBhMTUxNGYzNDg5MWQ1ZTc5MTRlOGY0OTI4NTdlZTMwNmI5YTgwOGM/) to collaborate with fellow community members and the AWS SAM team.
Copy file name to clipboardExpand all lines: docs/cloudformation_compatibility.rst
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,7 @@ Tracing All
60
60
KmsKeyArn All
61
61
DeadLetterQueue All
62
62
DeploymentPreference All
63
+
Layers All
63
64
AutoPublishAlias Ref of a CloudFormation Parameter Alias resources created by SAM uses a LocicalId <FunctionLogicalId+AliasName>. So SAM either needs a string for alias name, or a Ref to template Parameter that SAM can resolve into a string.
Copy file name to clipboardExpand all lines: docs/safe_lambda_deployments.rst
+28-2Lines changed: 28 additions & 2 deletions
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"
@@ -130,9 +133,11 @@ resource:
130
133
ComparisonOperator: GreaterThanThreshold
131
134
Dimensions:
132
135
- Name: Resource
133
-
Value: !Ref MyLambdaFunction.Version
136
+
Value: !Sub "${MyLambdaFunction}:live"
134
137
- Name: FunctionName
135
138
Value: !Ref MyLambdaFunction
139
+
- Name: ExecutedVersion
140
+
Value: !GetAtt MyLambdaFunction.Version.Version
136
141
EvaluationPeriods: 2
137
142
MetricName: Errors
138
143
Namespace: AWS/Lambda
@@ -162,6 +167,7 @@ resource:
162
167
FunctionName: 'CodeDeployHook_preTrafficHook'
163
168
DeploymentPreference:
164
169
Enabled: false
170
+
Role: ""
165
171
Environment:
166
172
Variables:
167
173
CurrentVersion: !Ref MyLambdaFunction.Version
@@ -176,6 +182,7 @@ CloudFormation, the following happens:
176
182
- 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
183
- 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
184
- If everything went well, the Alias will be pointing to the new Lambda Version.
185
+
- 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
186
180
187
NOTE: Verify that your AWS SDK version supports PutLifecycleEventHookExecutionStatus. For example, Python requires SDK version 1.4.8 or newer.
181
188
@@ -294,13 +301,32 @@ Internally, SAM will create the following resources in your CloudFormation stack
294
301
SAM template belongs to its own Deployment Group.
295
302
- Adds ``UpdatePolicy`` on ``AWS::Lambda::Alias`` resource that is
296
303
connected to the function's Deployment Group resource.
297
-
- One ``AWS::IAM::Role`` called "CodeDeployServiceRole".
304
+
- One ``AWS::IAM::Role`` called "CodeDeployServiceRole", if no custom role is provided
298
305
299
306
CodeDeploy assumes that there are no dependencies between Deployment Groups and hence will deploy them in parallel.
300
307
Since every Lambda function is to its own CodeDeploy DeploymentGroup, they will be deployed in parallel.
301
308
The CodeDeploy service will assume the new CodeDeployServiceRole to Invoke any Pre/Post hook functions and perform the traffic shifting and Alias updates.
302
309
303
310
NOTE: The CodeDeployServiceRole only allows InvokeFunction on functions with names prefixed with ``CodeDeployHook_``. For example, you should name your Hook functions as such: ``CodeDeployHook_PreTrafficHook``.
304
311
312
+
Production errors preventing deployments
313
+
~~~~~~~~~
314
+
In some situations, an issue that is happening in production may prevent you from deploying a fix. This may happen when a deployment happens when traffic is too low to register enough errors to trigger a roll back, or where someone is sending malicious traffic through to a lambda and you haven’t accounted for the scenario where they do.
315
+
316
+
When this happens, the alarm for errors in the current lambda version is in an error state, which will cause code deploy to roll back any attempted deploys straight away.
317
+
318
+
To release code in this situation, you need to
319
+
320
+
- Go into the CodeDeploy console
321
+
- Select the application you want to deploy to
322
+
- Select the corresponding Deployment Group
323
+
- Select “Edit”
324
+
- Select “Advanced - optional”
325
+
- Select "ignore alarm configuration"
326
+
- Save the changes
327
+
328
+
Run your deployment as usual
329
+
330
+
Then once deployment has successfully run, return to the CodeDeploy console, and follow the above steps but this time deselect “ignore alarm configuration”.
0 commit comments