-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/allow-canned-acl-with-s3-crud-policy
- Loading branch information
Showing
173 changed files
with
5,886 additions
and
1,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
ignore = E126 | ||
ignore = E126 F821 W504 W605 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Lambda function + Filtered SNS Subscription Example | ||
|
||
This example shows you how to create a Lambda function with a SNS event source. | ||
|
||
The Lambda function does not receive all messages published to the SNS topic but only a subset. The messages are filtered based on the attributes attached to | ||
the message. | ||
|
||
## Running the example | ||
|
||
Deploy the example into your account: | ||
|
||
```bash | ||
# Replace YOUR_S3_ARTIFACTS_BUCKET with the name of a bucket which already exists in your account | ||
aws cloudformation package --template-file template.yaml --output-template-file template.packaged.yaml --s3-bucket YOUR_S3_ARTIFACTS_BUCKET | ||
|
||
aws cloudformation deploy --template-file ./template.packaged.yaml --stack-name sam-example-lambda-sns-filter-policy --capabilities CAPABILITY_IAM | ||
``` | ||
|
||
The Lambda function will only receive messages with the attribute `sport` set to `football`. | ||
|
||
In the AWS console go to the topic sam-example-lambda-sns-filter-policy and push the Publish to Topic button. | ||
At the bottom of the Publish page you can add message attributes. Add one attribute: | ||
- key: sport | ||
- Attribute type: String | ||
- value: football | ||
|
||
Enter an arbitrary message body and publish the message. | ||
In Cloudwatch the log group /aws/lambda/sam-example-lambda-sns-filter-policy-notification-logger appears and the logging contains the message attributes of | ||
the received message. | ||
|
||
Now publish a couple of other messages with other values for the attribute `sport` or without the attribute `sport`. | ||
The Lambda function will not receive these messages. | ||
|
||
## Additional resources | ||
https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
|
||
exports.handler = async (event, context, callback) => { | ||
console.log("Message attributes: " + JSON.stringify(event.Records[0].Sns.MessageAttributes)); | ||
|
||
callback(null, "Success"); | ||
}; |
24 changes: 24 additions & 0 deletions
24
examples/2016-10-31/lambda_sns_filter_policy/template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: Lambda function with SNS filter policy | ||
Resources: | ||
NotificationLogger: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: ./src | ||
Handler: index.handler | ||
Runtime: nodejs8.10 | ||
FunctionName: sam-example-lambda-sns-filter-policy-notification-logger | ||
Events: | ||
NotificationTopic: | ||
Type: SNS | ||
Properties: | ||
Topic: !Ref Notifications | ||
FilterPolicy: | ||
sport: | ||
- football | ||
|
||
Notifications: | ||
Type: AWS::SNS::Topic | ||
Properties: | ||
TopicName: sam-example-lambda-sns-filter-policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '1.9.0' | ||
__version__ = '1.10.0' |
Oops, something went wrong.