-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
94 lines (91 loc) · 2.55 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sqs-example
Sample SAM Template for sqs-example
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 5
Resources:
ProcessorFunction:
Type: AWS::Serverless::Function
Properties:
Role: !GetAtt SQSExampleRole.Arn
CodeUri: processor/
Handler: index.handler
Runtime: go1.x
ReservedConcurrentExecutions: 1
MemorySize: 128
Environment:
Variables:
TRACKING_TABLE_NAME: !Ref TrackingDynamoDBTable
Events:
WorkQueueEvent:
Type: SQS
Properties:
Queue: !GetAtt WorkQueue.Arn
BatchSize: 10
ImportFunction:
Type: AWS::Serverless::Function
Properties:
Role: !GetAtt SQSExampleRole.Arn
CodeUri: import/
Handler: index.handler
Runtime: go1.x
MemorySize: 128
Environment:
Variables:
QUEUE_NAME: !GetAtt WorkQueue.QueueName
TRACKING_TABLE_NAME: !Ref TrackingDynamoDBTable
WorkQueue:
Type: AWS::SQS::Queue
TrackingDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
BillingMode: PAY_PER_REQUEST
SQSExampleRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- "lambda.amazonaws.com"
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: sqsAllowAll
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: '*'
Resource: 'arn:aws:sqs:*'
- PolicyName: dynamodbAllowAll
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: '*'
Resource: 'arn:aws:dynamodb:*'
- PolicyName: AllowCloudWatch
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
- "logs:DescribeLogStreams"
Resource: "arn:aws:logs:*:*:*"