@@ -5,7 +5,7 @@ CloudFormation Resources Generated By SAM
5
5
:local:
6
6
:backlinks: none
7
7
8
- When you create a Serverless Function or a Serverlesss API, SAM will create additional AWS resources to wire everything up.
8
+ When you create a Serverless Function or a Serverless API, SAM will create additional AWS resources to wire everything up.
9
9
For example, when you create a ``AWS::Serverless::Function ``, SAM will create a Lambda Function resource
10
10
along with an IAM Role resource to give appropriate permissions for your function. This document describes all
11
11
such generated resources, how they are named, and how to refer to them in your SAM template.
@@ -121,13 +121,53 @@ CloudFormation Resource Type Logical ID
121
121
AWS::ApiGateway::RestApi *ServerlessRestApi *
122
122
AWS::ApiGateway::Stage *ServerlessRestApi *\ **Prod **\ Stage
123
123
AWS::ApiGateway::Deployment *ServerlessRestApi *\ Deployment\ *SHA * (10 Digits of SHA256 of Swagger)
124
- AWS::Lambda::Permissions MyFunction\ **ThumbnailApi **\ Permission\ **Prod **
124
+ AWS::Lambda::Permission MyFunction\ **ThumbnailApi **\ Permission\ **Prod **
125
125
(Prod is the default Stage Name for implicit APIs)
126
126
================================== ================================
127
127
128
128
129
129
NOTE: ``ServerlessRestApi* `` resources are generated one per stack.
130
130
131
+ Cognito
132
+ ^^^
133
+
134
+ Example:
135
+
136
+ .. code :: yaml
137
+
138
+ MyFunction :
139
+ Type : AWS::Serverless::Function
140
+ Properties :
141
+ ...
142
+ Events :
143
+ CognitoTrigger :
144
+ Type : Cognito
145
+ Properties :
146
+ UserPool : !Ref MyUserPool
147
+ Trigger : PreSignUp
148
+ ...
149
+
150
+ MyUserPool :
151
+ Type : AWS::Cognito::UserPool
152
+
153
+ Additional generated resources:
154
+
155
+ ================================== ================================
156
+ CloudFormation Resource Type Logical ID
157
+ ================================== ================================
158
+ AWS::Lambda::Permissions *MyFunction *\ CognitoPermission
159
+ AWS::Cognito::UserPool Existing MyUserPool resource is modified to append ``LambdaConfig ``
160
+ property where the Lambda function trigger is defined
161
+ ================================== ================================
162
+
163
+ NOTE: You **must ** refer to a Cognito UserPool defined in the same template. This is for two reasons:
164
+
165
+ 1. SAM needs to add a ``LambdaConfig `` property to the UserPool resource by reading and modifying the
166
+ resource definition
167
+
168
+ 2. Lambda triggers are specified as a property on the UserPool resource. Since CloudFormation cannot modify a resource
169
+ created outside of the stack, this bucket needs to be defined within the template.
170
+
131
171
S3
132
172
^^^
133
173
@@ -155,7 +195,7 @@ Additional generated resources:
155
195
================================== ================================
156
196
CloudFormation Resource Type Logical ID
157
197
================================== ================================
158
- AWS::Lambda::Permissions MyFunction\ **S3Trigger **\ Permission
198
+ AWS::Lambda::Permission MyFunction\ **S3Trigger **\ Permission
159
199
AWS::S3::Bucket Existing MyBucket resource is modified to append ``NotificationConfiguration ``
160
200
property where the Lambda function trigger is defined
161
201
================================== ================================
@@ -184,17 +224,23 @@ Example:
184
224
Type : SNS
185
225
Properties :
186
226
Topic : arn:aws:sns:us-east-1:123456789012:my_topic
227
+ SqsSubscription : true
187
228
...
188
229
189
230
Additional generated resources:
190
231
191
232
================================== ================================
192
233
CloudFormation Resource Type Logical ID
193
234
================================== ================================
194
- AWS::Lambda::Permissions MyFunction\ **MyTrigger **\ Permission
195
- AWS::SNS::Subscription MyFunction\ **MyTrigger **
235
+ AWS::Lambda::Permission MyFunction\ **MyTrigger **\ Permission
236
+ AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger **\ EventSourceMapping
237
+ AWS::SNS::Subscription MyFunction\ **MyTrigger **
238
+ AWS::SQS::Queue MyFunction\ **MyTrigger **\ Queue
239
+ AWS::SQS::QueuePolicy MyFunction\ **MyTrigger **\ QueuePolicy
196
240
================================== ================================
197
241
242
+ NOTE: ``AWS::Lambda::Permission `` resources are only generated if SqsSubscription is ``false ``. ``AWS::Lambda::EventSourceMapping ``, ``AWS::SQS::Queue ``, ``AWS::SQS::QueuePolicy `` resources are only generated if SqsSubscription is ``true ``.
243
+
198
244
Kinesis
199
245
^^^^^^^
200
246
@@ -219,7 +265,7 @@ Additional generated resources:
219
265
================================== ================================
220
266
CloudFormation Resource Type Logical ID
221
267
================================== ================================
222
- AWS::Lambda::Permissions MyFunction\ **MyTrigger **\ Permission
268
+ AWS::Lambda::Permission MyFunction\ **MyTrigger **\ Permission
223
269
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger **
224
270
================================== ================================
225
271
@@ -246,7 +292,7 @@ Additional generated resources:
246
292
================================== ================================
247
293
CloudFormation Resource Type Logical ID
248
294
================================== ================================
249
- AWS::Lambda::Permissions MyFunction\ **MyTrigger **\ Permission
295
+ AWS::Lambda::Permission MyFunction\ **MyTrigger **\ Permission
250
296
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger **
251
297
================================== ================================
252
298
@@ -274,7 +320,7 @@ Additional generated resources:
274
320
================================== ================================
275
321
CloudFormation Resource Type Logical ID
276
322
================================== ================================
277
- AWS::Lambda::Permissions MyFunction\ **MyTrigger **\ Permission
323
+ AWS::Lambda::Permission MyFunction\ **MyTrigger **\ Permission
278
324
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger **
279
325
================================== ================================
280
326
@@ -301,7 +347,7 @@ Additional generated resources:
301
347
================================== ================================
302
348
CloudFormation Resource Type Logical ID
303
349
================================== ================================
304
- AWS::Lambda::Permissions MyFunction\ **MyTimer **\ Permission
350
+ AWS::Lambda::Permission MyFunction\ **MyTimer **\ Permission
305
351
AWS::Events::Rule MyFunction\ **MyTimer **
306
352
================================== ================================
307
353
@@ -331,7 +377,7 @@ Additional generated resources:
331
377
================================== ================================
332
378
CloudFormation Resource Type Logical ID
333
379
================================== ================================
334
- AWS::Lambda::Permissions MyFunction\ **OnTerminate **\ Permission
380
+ AWS::Lambda::Permission MyFunction\ **OnTerminate **\ Permission
335
381
AWS::Events::Rule MyFunction\ **OnTerminate **
336
382
================================== ================================
337
383
0 commit comments