-
Notifications
You must be signed in to change notification settings - Fork 116
Add S3EventNotifier
example
#477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a565ae4
b790508
e67650a
32b7459
50e510b
0ad4533
e3757aa
1297c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,14 @@ If there are no errors, a ZIP file should be ready to deploy, located at `.build | |
|
||
## Deploy | ||
|
||
[!IMPORTANT] | ||
The Lambda function and the S3 bucket must be located in the same AWS Region. In the code below, we use `eu-west-1` (Ireland). | ||
|
||
To deploy the Lambda function, you can use the `aws` command line: | ||
|
||
```bash | ||
aws lambda create-function \ | ||
--region eu-west-1 \ | ||
--function-name S3EventNotifier \ | ||
--zip-file fileb://.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/S3EventNotifier/S3EventNotifier.zip \ | ||
--runtime provided.al2 \ | ||
|
@@ -51,14 +55,16 @@ Besides deploying the Lambda function you also need to create the S3 bucket and | |
```bash | ||
aws s3api create-bucket --bucket my-test-bucket --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1 | ||
|
||
aws lambda add-permission \ | ||
aws lambda add-permission | ||
--region eu-west-1 \ | ||
--function-name S3EventNotifier \ | ||
--statement-id S3InvokeFunction \ | ||
--action lambda:InvokeFunction \ | ||
--principal s3.amazonaws.com \ | ||
--source-arn arn:aws:s3:::my-test-bucket | ||
|
||
aws s3api put-bucket-notification-configuration \ | ||
--region eu-west-1 \ | ||
--bucket my-test-bucket \ | ||
--notification-configuration '{ | ||
"LambdaFunctionConfigurations": [{ | ||
|
@@ -67,7 +73,7 @@ aws s3api put-bucket-notification-configuration \ | |
}] | ||
}' | ||
|
||
aws s3 cp testfile.txt s3://my-test-bucket/ | ||
touch testfile.txt && aws s3 cp testfile.txt s3://my-test-bucket/ | ||
``` | ||
|
||
This will: | ||
|
@@ -76,4 +82,7 @@ This will: | |
- configure the bucket to send `s3:ObjectCreated:*` events to the Lambda function named `S3EventNotifier`; | ||
- upload a file named `testfile.txt` to the bucket. | ||
|
||
Replace `<REGION>` with the region where you deployed the Lambda function and `<YOUR_ACCOUNT_ID>` with your actual AWS account ID. | ||
Replace `my-test-bucket` with your bucket name (bucket names are unique globaly and this one is already taken). Also replace `<REGION>` with the region where you deployed the Lambda function and `<YOUR_ACCOUNT_ID>` with your actual AWS account ID. | ||
|
||
[!IMPORTANT] | ||
The Lambda function and the S3 bucket must be located in the same AWS Region. Adjust the code above according to your closest AWS Region. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be unnecessary if we have the one above already? But I'm not precious about it. If you do end up leaving it, this should use block quotes too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made it on purpose - it so important and I'm sure so many will not read it :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think GH markdown requires this to be in block quotes, so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct - thank you