-
-
Save DavidWells/048bc855606331ab15bfdbd2ecd616f6 to your computer and use it in GitHub Desktop.
SLS existing S3 lambda trigger
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
functions: | |
TriggerFunc: | |
handler: handlers.main | |
resources: | |
Resources: | |
# Bucket 'TriggeredBucket' | |
TriggeredBucket: | |
Type: AWS::S3::Bucket | |
DependsOn: | |
- TriggerFuncLambdaPermissionTriggeredBucketS3 | |
Properties: | |
BucketName: my-unique-bucket-name | |
NotificationConfiguration: | |
LambdaConfigurations: | |
- Event: s3:ObjectCreated:* | |
Function: | |
Fn::GetAtt: | |
- TriggerFuncLambdaFunction | |
- Arn | |
CorsConfiguration: | |
CorsRules: | |
- AllowedHeaders: | |
- "*" | |
AllowedMethods: | |
- PUT | |
AllowedOrigins: | |
- "*" | |
# Lambda 'TriggerFunc' bucket permission | |
TriggerFuncLambdaPermissionTriggeredBucketS3: | |
Type: AWS::Lambda::Permission | |
DependsOn: | |
- TriggerFuncLambdaFunction | |
Properties: | |
FunctionName: | |
Fn::GetAtt: | |
- TriggerFuncLambdaFunction | |
- Arn | |
Action: lambda:InvokeFunction | |
Principal: s3.amazonaws.com | |
SourceArn: arn:aws:s3:::my-unique-bucket-name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi David, does this code still work for you? I've been dealing with errors trying to set this up for hours and I can't seem to find a solution. My setup is from what I can tell nearly identical to your code.
The error I get is fairly useless:
An error occurred: S3BucketContent - Unable to validate the following destination configurations (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: 90359047BABA63E7; S3 Extended Request ID: y8UhP9g6deB+EOjYAN7SOwAhU75CEXIFy8ivZNzgYg66hYEg0TB3h8qnYRjY3+VTHZ/pfPUW8jg=).
serverless.yml