-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathtemplate.yaml
60 lines (59 loc) · 1.89 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Template that creates a S3 bucket, SQS Queue and a Lambda function
that will be invoked when new objects are upload to the bucket.
Then queue a new message with that file details
Globals:
Function:
MemorySize: 256
Architectures: [arm64]
Runtime: dotnet8
Timeout: 300
Tracing: Active
Parameters:
BucketName:
Type: String
Description: Name of S3 bucket to be created.
The Lambda function will be invoked when new objects are upload to the bucket.
If left blank a name will be generated.
MinLength: "0"
Conditions:
BucketNameGenerated:
!Equals [!Ref BucketName, ""]
Resources:
S3Function:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src/S3Notifications
Handler: S3Notifications::S3Notifications.Function::FunctionHandler
Policies:
- AWSLambda_FullAccess
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action: sqs:SendMessage
Resource: !GetAtt NotificationQueue.Arn
Environment:
Variables:
QUEUE_URL: !Ref NotificationQueue
Events:
NewS3Event:
Type: S3
Properties:
Bucket: !Ref MonitoredBucket
Events:
- s3:ObjectCreated:*
NotificationQueue:
Type: AWS::SQS::Queue
MonitoredBucket:
Type: AWS::S3::Bucket
Properties:
BucketName:
!If [BucketNameGenerated, !Ref AWS::NoValue, !Ref BucketName]
Outputs:
S3BucketName:
Value: !Ref MonitoredBucket
Description: Bucket that will invoke the lambda function when new objects are created.
QueueUrl:
Value: !Ref NotificationQueue
Description: Queue that would receive notification after S3 related events