-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig2jsonlines.yml
96 lines (90 loc) · 2.55 KB
/
config2jsonlines.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
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
95
96
Transform: AWS::Serverless-2016-10-31
Parameters:
OutputBucketName:
Type: String
InputBucketName:
Type: String
Globals:
Function:
AutoPublishAlias: live
CodeUri: ./config2jsonlines
Handler: config2jsonlines
MemorySize: 1024
Runtime: go1.x
Timeout: 120
Resources:
S3Event:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./config2jsonlines
Environment:
Variables:
MODE: S3Event
QUEUE_URL: !Ref Queue
Policies:
- SQSSendMessagePolicy:
QueueName: !GetAtt Queue.QueueName
S3Permission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !Ref S3Event.Alias
Action: lambda:InvokeFunction
Principal: s3.amazonaws.com
SourceAccount: !Ref AWS::AccountId
SourceArn: !Sub arn:aws:s3:::${InputBucketName}
Queue:
Type: AWS::SQS::Queue
Properties:
ReceiveMessageWaitTimeSeconds: 20
VisibilityTimeout: 150
RedrivePolicy:
deadLetterTargetArn: !GetAtt DeadLetterQueue.Arn
maxReceiveCount: 3
DeadLetterQueue:
Type: AWS::SQS::Queue
Processor:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./config2jsonlines
Environment:
Variables:
OUTPUT_BUCKET: !Ref OutputBucketName
MODE: Processor
Policies:
- Statement:
- Effect: Allow
Resource: !Sub arn:aws:s3:::${OutputBucketName}/*
Action:
- s3:PutObject
- s3:GetObject
- s3:AbortMultipartUpload
- s3:ListBucketMultipartUploads
- s3:ListMultipartUploadParts
- Effect: Allow
Resource: "*"
Action:
- kms:Decrypt
- kms:Encrypt
- kms:GenerateDataKey*
- kms:ReEncrypt*
Condition:
ForAnyValue:StringLike:
kms:EncryptionContext:aws:s3:arn:
- !Sub arn:aws:s3:::${OutputBucketName}/*
- !Sub arn:aws:s3:::${InputBucketName}/* # AWS Config doesn't support S3 SSE-KMS today, but maybe it will one day - one can hope.
- S3ReadPolicy:
BucketName: !Ref InputBucketName
Events:
SQS:
Type: SQS
Properties:
Queue: !GetAtt Queue.Arn
BatchSize: 1
Enabled: true
Outputs:
Processor:
Value: !Ref Processor.Version
S3Event:
Value: !Ref S3Event.Version
DeadLetterQueue:
Value: !Ref DeadLetterQueue