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
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,3 +81,71 @@ aws cloudformation deploy \
81
81
```
82
82
83
83
Refer to the [documentation](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/deploy/index.html) for more details.
84
+
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:
87
+
88
+
#### Dynamically set S3 location of Lambda function code zip
89
+
```
90
+
Transform: 'AWS::Serverless-2016-10-31'
91
+
92
+
# Parameters are CloudFormation features to pass input
93
+
# to your template when you create a stack
94
+
Parameters:
95
+
BucketName:
96
+
Type: String
97
+
CodeKey:
98
+
Type: String
99
+
100
+
Resources:
101
+
MyFunction:
102
+
Type: AWS::Serverless::Function
103
+
Properties:
104
+
Handler: index.handler
105
+
Runtime: nodejs4.3
106
+
CodeUri:
107
+
# !Ref function allows you to fetch value
108
+
# of parameters and other resources at runtime
109
+
Bucket: !Ref BucketName
110
+
Key: !Ref CodeKey
111
+
```
112
+
113
+
#### Generate a different function name for each stack
114
+
115
+
```
116
+
Transform: 'AWS::Serverless-2016-10-31'
117
+
118
+
# Parameters are CloudFormation features to pass input
[`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:
Copy file name to clipboardExpand all lines: versions/2016-10-31.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,8 @@ Property Name | Type | Description
62
62
---|:---:|---
63
63
Handler | `string` | **Required.** Function within your code that is called to begin execution.
64
64
Runtime | `string` | **Required.** The runtime environment.
65
-
CodeUri | `string` | **Required.** S3 Uri to the function code. The S3 object this Uri references MUST be a [Lambda deployment package](http://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html).
65
+
CodeUri | `string` <span>|</span> [S3 Location Object](#s3-location-object) | **Required.** S3 Uri or location to the function code. The S3 object this Uri references MUST be a [Lambda deployment package](http://docs.aws.amazon.com/lambda/latest/dg/deployment-package-v2.html).
66
+
FunctionName | `string` | A name for the function. If you don't specify a name, a unique name will be generated for you. [More Info](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionname)
66
67
Description | `string` | Description of the function.
67
68
MemorySize | `integer` | Size of the memory allocated per invocation of the function in MB. Defaults to 128.
68
69
Timeout | `integer` | Maximum time that the function can run before it is killed in seconds. Defaults to 3.
@@ -117,7 +118,8 @@ An `AWS::Serverless::Api` resource need not be explicitly added to a AWS Serverl
117
118
Property Name | Type | Description
118
119
---|:---:|---
119
120
StageName | `string` | **Required** The name of the stage, which API Gateway uses as the first path segment in the invoke Uniform Resource Identifier (URI).
120
-
DefinitionUri | `string` | **Required** S3 URI to the Swagger document describing the API.
121
+
DefinitionUri | `string` <span>|</span> [S3 Location Object](#s3-location-object) | S3 URI or location to the Swagger document describing the API. Either one of `DefinitionUri` or `DefinitionBody` must be specified.
122
+
DefinitionBody | `JSON or YAML Object` | Swagger specification that describes your API. Either one of `DefinitionUri` or `DefinitionBody` must be specified.
121
123
CacheClusterEnabled | `boolean` | Indicates whether cache clustering is enabled for the stage.
122
124
CacheClusterSize | `string` | The stage's cache cluster size.
123
125
Variables | Map of `string` to `string` | A map (string to string map) that defines the stage variables, where the variable name is the key and the variable value is the value. Variable names are limited to alphanumeric characters. Values must match the following regular expression: `[A-Za-z0-9._~:/?#&=,-]+`.
@@ -396,3 +398,15 @@ Type | `string` | Attribute type of the primary key. MUST be one of `String`, `N
396
398
Name: id
397
399
Type: String
398
400
```
401
+
402
+
### Data Types
403
+
#### S3 Location Object
404
+
Specifies the location of an S3 object as a dictionary containing `Bucket`, `Key`, and optional `Version` properties.
0 commit comments