Skip to content

Commit 4fa5d6a

Browse files
author
Shreya
authored
chore: merge pull request #1174 from awslabs/release/v1.15.0
2 parents 0ff9a5e + d81aa57 commit 4fa5d6a

File tree

305 files changed

+12400
-9052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+12400
-9052
lines changed

docs/api.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/cloudformation_compatibility.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ ReservedConcurrentExecutions All
6868
Events Properties
6969
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7070

71+
Cognito
72+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73+
======================== ================================== ========================
74+
Property Name Intrinsic(s) Supported Reasons
75+
======================== ================================== ========================
76+
UserPool Ref of a AWS::Cognito::UserPool Properties in the AWS::Cognito::UserPool are used to construct different attributes.
77+
Trigger All
78+
======================== ================================== ========================
79+
7180
S3
7281
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7382
======================== ================================== ========================

docs/function.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/getting_started.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/internals/generated_resources.rst

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CloudFormation Resources Generated By SAM
55
:local:
66
:backlinks: none
77

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.
99
For example, when you create a ``AWS::Serverless::Function``, SAM will create a Lambda Function resource
1010
along with an IAM Role resource to give appropriate permissions for your function. This document describes all
1111
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
121121
AWS::ApiGateway::RestApi *ServerlessRestApi*
122122
AWS::ApiGateway::Stage *ServerlessRestApi*\ **Prod**\ Stage
123123
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**
125125
(Prod is the default Stage Name for implicit APIs)
126126
================================== ================================
127127

128128

129129
NOTE: ``ServerlessRestApi*`` resources are generated one per stack.
130130

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+
131171
S3
132172
^^^
133173

@@ -155,7 +195,7 @@ Additional generated resources:
155195
================================== ================================
156196
CloudFormation Resource Type Logical ID
157197
================================== ================================
158-
AWS::Lambda::Permissions MyFunction\ **S3Trigger**\ Permission
198+
AWS::Lambda::Permission MyFunction\ **S3Trigger**\ Permission
159199
AWS::S3::Bucket Existing MyBucket resource is modified to append ``NotificationConfiguration``
160200
property where the Lambda function trigger is defined
161201
================================== ================================
@@ -184,17 +224,23 @@ Example:
184224
Type: SNS
185225
Properties:
186226
Topic: arn:aws:sns:us-east-1:123456789012:my_topic
227+
SqsSubscription: true
187228
...
188229
189230
Additional generated resources:
190231

191232
================================== ================================
192233
CloudFormation Resource Type Logical ID
193234
================================== ================================
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
196240
================================== ================================
197241

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+
198244
Kinesis
199245
^^^^^^^
200246

@@ -219,7 +265,7 @@ Additional generated resources:
219265
================================== ================================
220266
CloudFormation Resource Type Logical ID
221267
================================== ================================
222-
AWS::Lambda::Permissions MyFunction\ **MyTrigger**\ Permission
268+
AWS::Lambda::Permission MyFunction\ **MyTrigger**\ Permission
223269
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger**
224270
================================== ================================
225271

@@ -246,7 +292,7 @@ Additional generated resources:
246292
================================== ================================
247293
CloudFormation Resource Type Logical ID
248294
================================== ================================
249-
AWS::Lambda::Permissions MyFunction\ **MyTrigger**\ Permission
295+
AWS::Lambda::Permission MyFunction\ **MyTrigger**\ Permission
250296
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger**
251297
================================== ================================
252298

@@ -274,7 +320,7 @@ Additional generated resources:
274320
================================== ================================
275321
CloudFormation Resource Type Logical ID
276322
================================== ================================
277-
AWS::Lambda::Permissions MyFunction\ **MyTrigger**\ Permission
323+
AWS::Lambda::Permission MyFunction\ **MyTrigger**\ Permission
278324
AWS::Lambda::EventSourceMapping MyFunction\ **MyTrigger**
279325
================================== ================================
280326

@@ -301,7 +347,7 @@ Additional generated resources:
301347
================================== ================================
302348
CloudFormation Resource Type Logical ID
303349
================================== ================================
304-
AWS::Lambda::Permissions MyFunction\ **MyTimer**\ Permission
350+
AWS::Lambda::Permission MyFunction\ **MyTimer**\ Permission
305351
AWS::Events::Rule MyFunction\ **MyTimer**
306352
================================== ================================
307353

@@ -331,7 +377,7 @@ Additional generated resources:
331377
================================== ================================
332378
CloudFormation Resource Type Logical ID
333379
================================== ================================
334-
AWS::Lambda::Permissions MyFunction\ **OnTerminate**\ Permission
380+
AWS::Lambda::Permission MyFunction\ **OnTerminate**\ Permission
335381
AWS::Events::Rule MyFunction\ **OnTerminate**
336382
================================== ================================
337383

examples/2016-10-31/api_cognito_auth/template.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ Resources:
9393
Type: AWS::Cognito::UserPool
9494
Properties:
9595
UserPoolName: !Ref CognitoUserPoolName
96-
LambdaConfig:
97-
PreSignUp: !GetAtt PreSignupLambdaFunction.Arn
9896
Policies:
9997
PasswordPolicy:
10098
MinimumLength: 8
@@ -124,20 +122,12 @@ Resources:
124122
MemorySize: 128
125123
Runtime: nodejs8.10
126124
Timeout: 3
127-
128-
LambdaCognitoUserPoolExecutionPermission:
129-
Type: AWS::Lambda::Permission
130-
Properties:
131-
Action: lambda:InvokeFunction
132-
FunctionName: !GetAtt PreSignupLambdaFunction.Arn
133-
Principal: cognito-idp.amazonaws.com
134-
SourceArn: !Sub 'arn:${AWS::Partition}:cognito-idp:${AWS::Region}:${AWS::AccountId}:userpool/${MyCognitoUserPool}'
135-
# TODO: Add a CognitoUserPool Event Source to SAM to create this permission for you.
136-
# Events:
137-
# CognitoUserPoolPreSignup:
138-
# Type: CognitoUserPool
139-
# Properties:
140-
# UserPool: !Ref MyCognitoUserPool
125+
Events:
126+
CognitoUserPoolPreSignup:
127+
Type: Cognito
128+
Properties:
129+
UserPool: !Ref MyCognitoUserPool
130+
Trigger: PreSignUp
141131

142132
Outputs:
143133
Region:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# api_lambda_auth_cors
2+
3+
## About
4+
5+
This example shows how to configure a TOKEN Lambda Authorizer as the `DefaultAuthorizer` for an API with CORS enabled.
6+
7+
## Installation
8+
9+
1. Provide a bucket name and deploy the resources
10+
```bash
11+
S3_BUCKET_NAME=your-bucket-name-here \
12+
npm run package-deploy
13+
```
14+
1. Install the required NPM dependencies
15+
```bash
16+
npm install
17+
```
18+
1. Start the web server
19+
```bash
20+
npm run start
21+
```
22+
1. Open `http://localhost:8080` in a browser, click the button and an alert will appear with the lambda response
23+
24+
## Cleanup
25+
26+
1. `aws cloudformation delete-stack --stack-name authorizer-cors-example`

0 commit comments

Comments
 (0)