This repository was archived by the owner on Jan 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtemplate.yaml
More file actions
77 lines (72 loc) · 1.96 KB
/
template.yaml
File metadata and controls
77 lines (72 loc) · 1.96 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: S3 diff checker and version lifecycler - jbesw@.
Parameters:
BucketName:
Type: String
Resources:
## S3 bucket
SourceBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
VersioningConfiguration:
Status: Enabled
# Enforce HTTPS only access to S3 bucket #
BucketForImagePolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref SourceBucket
PolicyDocument:
Statement:
- Action: s3:*
Effect: Deny
Principal: "*"
Resource:
- !Sub "arn:aws:s3:::${SourceBucket}/*"
- !Sub "arn:aws:s3:::${SourceBucket}"
Condition:
Bool:
aws:SecureTransport: false
## Lambda function
S3ProcessorFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: app.handler
Runtime: nodejs14.x
MemorySize: 128
Environment:
Variables:
KEEP_VERSIONS: 3
Policies:
- S3ReadPolicy:
BucketName: !Ref BucketName
- Statement:
- Sid: VersionsPermission
Effect: Allow
Action:
- s3:ListBucketVersions
Resource: !Sub "arn:${AWS::Partition}:s3:::${BucketName}"
- Statement:
- Sid: DeletePermission
Effect: Allow
Action:
- s3:DeleteObject
- s3:DeleteObjectVersion
Resource: !Sub "arn:${AWS::Partition}:s3:::${BucketName}/*"
Events:
FileUpload:
Type: S3
Properties:
Bucket: !Ref SourceBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: suffix
Value: '.txt'
Outputs:
BucketARN:
Description: Source bucket ARN
Value: !Sub "arn:${AWS::Partition}:s3:::${BucketName}"