-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.yaml
More file actions
198 lines (188 loc) · 5.66 KB
/
storage.yaml
File metadata and controls
198 lines (188 loc) · 5.66 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
AWSTemplateFormatVersion: "2010-09-09"
Description: VaultDB Create secure S3 bucket to store data
Parameters:
ApplicationName:
Type: String
AllowedPattern: "^[a-z][a-z0-9-]{0,48}[a-z0-9]$"
Description: Enter the name of your application with no spaces.
Metadata:
Author: VaultDB.ai
Url: https://www.vaultdb.ai
Rules:
ApplicationNameIsRequired:
Assertions:
- AssertDescription: Application Name is required
Assert: !Not [!Equals [!Ref ApplicationName, ""]]
Resources:
DataBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName:
!Join ["", [!Ref ApplicationName, "-data-", !Sub "${AWS::AccountId}"]]
Tags:
- Key: Purpose
Value: "VaultDB"
- Key: Project
Value: !Ref ApplicationName
- Key: createdBy
Value: vaultdb.ai
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
LifecycleConfiguration:
Rules:
- Id: DeleteArchivedContentsAfter7Days
Prefix: 'archived/'
Status: Enabled
ExpirationInDays: 7
# - Id: GlacierRule
# Prefix: 'archived/'
# Status: Disabled
# ExpirationInDays: 7
# Transitions:
# - TransitionInDays: 1
# StorageClass: GLACIER
PublicBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName:
!Join [
"",
[!Ref ApplicationName, "-public-storage-", !Sub "${AWS::AccountId}"],
]
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- "*"
AllowedMethods:
- GET
- PUT
- POST
- HEAD
AllowedOrigins:
- "*"
MaxAge: 1800
ExposedHeaders:
- "x-amz-server-side-encryption"
- "x-amz-request-id"
- "x-amz-id-2"
- "ETag"
Tags:
- Key: Purpose
Value: "VaultDB"
- Key: Project
Value: !Ref ApplicationName
- Key: createdBy
Value: vaultdb.ai
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
WebsiteConfiguration:
IndexDocument: "index.html"
ErrorDocument: "error.html"
PublicAccessBlockConfiguration:
BlockPublicPolicy: false
PublicBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref PublicBucket
PolicyDocument:
Id: PublicReadPolicy
Version: 2012-10-17
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: "*"
Action: "s3:GetObject"
Resource: !Sub arn:aws:s3:::${PublicBucket}/*
- Sid: AddPermlist
Effect: Allow
Principal: "*"
Action: "s3:ListBucket"
Resource: !Sub arn:aws:s3:::${PublicBucket}
#- Sid: AddPutObject
# Effect: Allow
# Principal: "*"
# Action: "s3:PutBucket"
# Resource: !Sub arn:aws:s3:::${PublicBucket}
EFSFileSystem:
Type: AWS::EFS::FileSystem
Properties:
BackupPolicy:
Status: ENABLED
Encrypted: true
LifecyclePolicies:
- TransitionToIA: AFTER_60_DAYS
PerformanceMode: generalPurpose
ThroughputMode: bursting
FileSystemTags:
- Key: Purpose
Value: "VaultDB"
- Key: Project
Value: !Ref ApplicationName
- Key: createdBy
Value: vaultdb.ai
EFSAccessPointResource:
Type: AWS::EFS::AccessPoint
Properties:
FileSystemId: !Ref EFSFileSystem
PosixUser:
Uid: 1001
Gid: 1001
RootDirectory:
CreationInfo:
OwnerGid: 1001
OwnerUid: 1001
Permissions: 770
Path: /commitlog
EFSMountTarget:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref EFSFileSystem
SecurityGroups:
- Fn::ImportValue: !Sub "${ApplicationName}-DataSecurityGroup"
SubnetId:
Fn::ImportValue: !Sub "${ApplicationName}-VPCPrivateSubnet"
Outputs:
DataBucketNameArn:
Description: ANR of the main bucket
Value: !GetAtt DataBucket.Arn
Export:
Name: !Sub ${ApplicationName}-DataBucket-arn
DataBucketName:
Description: Name of the main bucket
Value: !Ref DataBucket
Export:
Name: !Sub ${ApplicationName}-DataBucket
PublicBucketArn:
Description: Name of the public bucket
Value: !GetAtt PublicBucket.Arn
Export:
Name: !Sub ${ApplicationName}-PublicBucket-arn
PublicBucket:
Description: Name of the public bucket
Value: !Ref PublicBucket
Export:
Name: !Sub ${ApplicationName}-PublicBucket
WebsiteURL:
Value: !GetAtt PublicBucket.WebsiteURL
Description: URL for website hosted on S3
Export:
Name: !Sub ${ApplicationName}-WebsiteURL
EFSFileSystem:
Description: The created EFS
Value: !Ref EFSFileSystem
Export:
Name: !Sub ${ApplicationName}-EFSFileSystem
EFSMountTarget:
Description: The EFS EFSMountTarget
Value: !Ref EFSMountTarget
Export:
Name: !Sub ${ApplicationName}-EFSMountTarget
EFSAccessPointResource:
Description: EFS Access Point Resource
Value: !GetAtt EFSAccessPointResource.Arn
Export:
Name: !Sub ${ApplicationName}-EFSAccessPointResource