Skip to content

Instantly share code, notes, and snippets.

@dsandor
Created January 3, 2020 14:43
Show Gist options
  • Save dsandor/52f0c3d982ff35fa22739d20a216e3e5 to your computer and use it in GitHub Desktop.
Save dsandor/52f0c3d982ff35fa22739d20a216e3e5 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
MemorySize: 128
Timeout: 15
Resources:
# Permissions
AllowS3ToCallLambdaPermission:
Type: AWS::Lambda::Permission
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !Ref S3TriggeredLambdaHandler
Principal: s3.amazonaws.com
SourceArn: !GetAtt S3Bucket.Arn
# Functions
S3TriggeredLambdaHandler:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: lambda.handler
Description: Function that is called when a file is stored in S3.
Runtime: nodejs12.x
Events:
S3Bucket:
Type: S3
Properties:
Bucket: !Ref S3Bucket
Events: 's3:ObjectCreated:*'
# S3 Bucket
S3Bucket:
Type: AWS::S3::Bucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment