-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
65 lines (60 loc) · 1.53 KB
/
serverless.yml
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
61
62
63
64
65
service: <CHANGE_ME>-aws-workshops-1 # NOTE: update this with your service name
custom:
bucket_name: "<CHANGE_ME>-aws-workshops-bucket"
queue_name: "<CHANGE_ME>-aws-workshops-queue"
provider:
name: aws
runtime: python3.8
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:PutObjectAcl"
Resource:
- "arn:aws:s3:::${self:custom.bucket_name}/*"
- "arn:aws:s3:::${self:custom.bucket_name}"
- Effect: "Allow"
Action:
- "sqs:SendMessage"
- "sqs:GetQueueUrl"
Resource:
- Fn::GetAtt: [MyQueue, Arn]
functions:
scraper:
handler: handlers.scraper.handler
events:
- sqs:
arn:
Fn::GetAtt: [MyQueue, Arn]
batchSize: 10
environment:
BUCKET_NAME: ${self:custom.bucket_name}
trigger:
handler: handlers.trigger.handler
environment:
QUEUE_NAME: ${self:custom.queue_name}
events:
- http:
path: trigger
method: get
resources:
Resources:
MyS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.bucket_name}
MyQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.queue_name}
VisibilityTimeout: 60
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt: ['MyQueueDLQ', 'Arn']
maxReceiveCount: 5
MyQueueDLQ:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 1209600
plugins:
- serverless-python-requirements