Skip to content

Instantly share code, notes, and snippets.

@Pwntus
Created May 12, 2017 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Pwntus/bfcd8daed4c447473afea886f677d038 to your computer and use it in GitHub Desktop.
Save Pwntus/bfcd8daed4c447473afea886f677d038 to your computer and use it in GitHub Desktop.
SLS existing S3 lambda trigger
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