-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.yaml
81 lines (74 loc) · 2.24 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Lambda2SQS
Globals:
Function:
Runtime: go1.x
Parameters:
DefaultSecurityGroup:
Type: String
Default: sg-66390301
PrivateSubnets:
Type: String
Default: >
subnet-0ff046ccc4e3b6281,subnet-0938728dfb344b970,subnet-0e123bd457c082cff
Resources:
Push:
Type: AWS::Serverless::Function
Properties:
FunctionName: ut_lambda2sqs_push
Role: !GetAtt LambdaRole.Arn
CodeUri: .
Handler: push-bin
Runtime: go1.x
Environment:
Variables:
SQS_URL: !Ref SQLTriggerQueue
Process:
Type: AWS::Serverless::Function
Properties:
Role: !GetAtt LambdaRole.Arn
CodeUri: .
FunctionName: ut_lambda2sqs_process
VpcConfig:
SecurityGroupIds: [!Ref DefaultSecurityGroup]
SubnetIds: !Split [',', !Ref PrivateSubnets]
Handler: process-bin
Runtime: go1.x
Events:
SQSEvent:
Type: SQS
Properties:
Queue: !GetAtt [SQLTriggerQueue, Arn]
BatchSize: 1
SQLTriggerQueueDLQ:
Type: AWS::SQS::Queue
Properties:
MessageRetentionPeriod: 1209600
SQLTriggerQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 120
MessageRetentionPeriod: 604800
RedrivePolicy:
deadLetterTargetArn: !GetAtt [SQLTriggerQueueDLQ, Arn]
maxReceiveCount: 10
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [lambda.amazonaws.com]
Action: ['sts:AssumeRole']
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSLambdaExecute
- arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess
- arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaRole
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
- arn:aws:iam::aws:policy/AmazonSNSFullAccess
- arn:aws:iam::aws:policy/AmazonSQSFullAccess
- arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole