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: HOWTO.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
# How to create serverless applications using AWS SAM
2
-
AWS Serverless Application Model (AWS SAM) allows you to easily create and
2
+
The AWS Serverless Application Model (AWS SAM) allows you to easily create and
3
3
manage resources used in your serverless application using AWS CloudFormation.
4
4
You can define your serverless application as a SAM template - a JSON or YAML
5
5
configuration file that describes Lambda function, API endpoints and
6
-
other resources in your application. Using nifty commands, you upload this
7
-
template to CloudFormation which creates all the individual resources and
6
+
other resources in your application. Using a variety of [nifty commands](https://github.com/awslabs/aws-sam-cli#usage), you upload this
7
+
template to CloudFormation, which in turn creates all the individual resources and
8
8
groups them into a *CloudFormation Stack* for ease of management.
9
9
When you update your SAM template, you will re-deploy the changes to
10
10
this stack. AWS CloudFormation will take care of updating the individual
11
11
resources for you.
12
12
13
13
14
-
The remainder of document explains how to write SAM templates and
14
+
The remainder of this document explains how to write SAM templates and
15
15
deploy them via AWS CloudFormation.
16
16
17
17
## Writing SAM Template
18
-
Checkout the [latest specification](versions/2016-10-31.md) for details on how to write a SAM template
18
+
Check out the [latest specification](versions/2016-10-31.md) for details on how to write a SAM template
19
19
20
20
## Packing Artifacts
21
21
Before you can deploy a SAM template, you should first upload your Lambda
@@ -71,7 +71,7 @@ SAM template is deployed to AWS CloudFormation by [creating a changeset](http://
71
71
using the SAM template followed by [executing the changeset](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets-execute.html).
72
72
Think of a ChangeSet as a diff between your current stack template and the new template that you are deploying. After you create a ChangeSet, you have the opportunity to examine the diff before executing it. Both the AWS Console and AWS CLI provide commands to create and execute a changeset.
73
73
74
-
Alternatively, you can use `aws cloudformation deploy` CLI command to deploy the SAM template. Under-the-hood it creates and executes a changeset and waits until the deployment completes. It also prints debugging hints when the deployment fails. Run the following command to deploy the packaged template to a stack called `my-new-stack`:
74
+
Alternatively, you can use `aws cloudformation deploy` CLI command to deploy the SAM template. Underthehood it creates and executes a changeset and waits until the deployment completes. It also prints debugging hints when the deployment fails. Run the following command to deploy the packaged template to a stack called `my-new-stack`:
75
75
76
76
```bash
77
77
$ aws cloudformation deploy \
@@ -83,7 +83,7 @@ $ aws cloudformation deploy \
83
83
Refer to the [documentation](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/deploy/index.html) for more details.
84
84
85
85
## Using Intrinsic Functions
86
-
CloudFormation provides handy functions you can use to generate values at runtime. These are called [Intrinsic Functions](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html). Since SAM is deployed using CloudFormation, you can use these intrinsic functions within SAM as well. Here are some examples:
86
+
CloudFormation provides handy functions that you can use to generate values at runtime. These are called [Intrinsic Functions](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html). Since SAM is deployed using CloudFormation, you can use these intrinsic functions within SAM as well. Here are some examples:
87
87
88
88
#### Dynamically set S3 location of Lambda function code zip
89
89
```YAML
@@ -136,7 +136,7 @@ Resources:
136
136
137
137
### Caveats:
138
138
#### ImportValue is partially supported
139
-
[`ImportValue`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html) allows one stack to refer to value of properties from another stack. ImportValue is supported on most properties, except the very few that SAM needs to parse. Following properties are *not* supported:
139
+
[`ImportValue`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html) allows one stack to refer to the value of properties from another stack. ImportValue is supported on most properties, except the very few that SAM needs to parse. The following properties are *not* supported:
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The SAM specification and implementation are open sourced under the Apache 2.0 l
12
12
13
13
14
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 [SAM Local CLI](https://github.com/awslabs/aws-sam-local). 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.
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
16
17
17
[Read the How-To Guide](HOWTO.md) and see [examples](examples/) to learn how to define & deploy serverless applications using SAM.
Copy file name to clipboardExpand all lines: docs/globals.rst
+28-15Lines changed: 28 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,19 +42,19 @@ In the above example, both ``HelloWorldFunction`` and ``ThumbnailFunction`` will
42
42
timeout and index.handler Handler. ``HelloWorldFunction`` adds MESSAGE environment variable in addition to the
43
43
inherited TABLE_NAME. ``ThumbnailFunction`` inherits all the Globals properties and adds an API Event source.
44
44
45
-
Supported Resources
46
-
-------------------
47
-
Properties of ``AWS::Serverless::Function`` and ``AWS::Serverless::Api`` are only supported in Globals section
48
-
presently.
45
+
Supported Resources and Properties
46
+
----------------------------------
47
+
Currently, the following resources and properties are being supported:
49
48
50
49
.. code:: yaml
51
50
52
51
Globals:
53
52
Function:
54
-
#Some properties of AWS::Serverless::Function
53
+
#Properties of AWS::Serverless::Function
55
54
Handler:
56
55
Runtime:
57
-
CodeUri:
56
+
# Specifying CodeUri on Globals is not yet supported by 'CloudFormation package' https://docs.aws.amazon.com/cli/latest/reference/cloudformation/package.html
57
+
CodeUri:
58
58
DeadLetterQueue:
59
59
Description:
60
60
MemorySize:
@@ -68,7 +68,7 @@ presently.
68
68
DeploymentPreference:
69
69
70
70
Api:
71
-
#Some properties of AWS::Serverless::Api
71
+
#Properties of AWS::Serverless::Api
72
72
# Also works with Implicit APIs
73
73
Name:
74
74
DefinitionUri:
@@ -81,6 +81,7 @@ presently.
81
81
Cors:
82
82
83
83
SimpleTable:
84
+
# Properties of AWS::Serverless::SimpleTable
84
85
SSESpecification
85
86
86
87
Implicit APIs
@@ -143,20 +144,19 @@ Runtime of ``MyFunction`` will be set to python3.6
143
144
144
145
Maps are merged
145
146
~~~~~~~~~~~~~~~
146
-
*Also called as dictionaries, or key/value pairs*
147
+
*Maps are also known as dictionaries or collections of key/value pairs*
147
148
148
-
Map value in the resource will be **merged** with the map value from Global.
149
+
Map entries in the resource will be **merged** with global map entries. In case of duplicates the resource entry will override the global entry.
149
150
150
151
Example:
151
152
152
-
Environment variables of ``MyFunction`` will be set to ``{ TABLE_NAME: "resource-table", "NEW_VAR": "hello" }``
153
-
154
153
.. code:: yaml
155
154
156
155
Globals:
157
156
Function:
158
157
Environment:
159
158
Variables:
159
+
STAGE: Production
160
160
TABLE_NAME: global-table
161
161
162
162
Resources:
@@ -168,16 +168,24 @@ Environment variables of ``MyFunction`` will be set to ``{ TABLE_NAME: "resource
168
168
TABLE_NAME: resource-table
169
169
NEW_VAR: hello
170
170
171
+
In the above example the environment variables of ``MyFunction`` will be set to:
172
+
173
+
.. code:: json
174
+
175
+
{
176
+
"STAGE": "Production",
177
+
"TABLE_NAME": "resource-table",
178
+
"NEW_VAR": "hello"
179
+
}
180
+
171
181
Lists are additive
172
182
~~~~~~~~~~~~~~~~~~~
173
-
*Also called as arrays*
183
+
*Lists are also known as arrays*
174
184
175
-
List values in the resource will be **appended** with the map value from Global.
185
+
Global entries will be **prepended** to the list in the resource.
176
186
177
187
Example:
178
188
179
-
SecurityGroupIds of VpcConfig will be set to ``["sg-first", "sg-123", "sg-456"]``
180
-
181
189
.. code:: yaml
182
190
183
191
Globals:
@@ -195,3 +203,8 @@ SecurityGroupIds of VpcConfig will be set to ``["sg-first", "sg-123", "sg-456"]`
195
203
SecurityGroupIds:
196
204
- sg-first
197
205
206
+
In the above example the Security Group Ids of ``MyFunction``'s VPC Config will be set to:
0 commit comments