aws-architect 6.7.69 → 6.7.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BucketManager.js +21 -3
- package/package.json +1 -1
package/lib/BucketManager.js
CHANGED
|
@@ -42,8 +42,6 @@ class BucketManager {
|
|
|
42
42
|
const fileUrl = this.unixify(path.join(version, relativePath));
|
|
43
43
|
const fileData = await fs.readFile(file);
|
|
44
44
|
|
|
45
|
-
await this.ensureBucketExists(this.Bucket);
|
|
46
|
-
|
|
47
45
|
const putObjectParams = {
|
|
48
46
|
Bucket: this.Bucket,
|
|
49
47
|
Key: fileUrl,
|
|
@@ -156,6 +154,25 @@ class BucketManager {
|
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
async ensureBucketExists(bucket) {
|
|
157
|
+
const bucketLifecycleConfigurationParams = {
|
|
158
|
+
Bucket: bucket,
|
|
159
|
+
LifecycleConfiguration: {
|
|
160
|
+
Rules: [{
|
|
161
|
+
ID: 'AutoDeleteOldArtifacts',
|
|
162
|
+
Expiration: {
|
|
163
|
+
Days: 365
|
|
164
|
+
},
|
|
165
|
+
NoncurrentVersionExpiration: {
|
|
166
|
+
NoncurrentDays: 5
|
|
167
|
+
},
|
|
168
|
+
AbortIncompleteMultipartUpload: {
|
|
169
|
+
DaysAfterInitiation: 5
|
|
170
|
+
},
|
|
171
|
+
Status: 'Enabled'
|
|
172
|
+
}]
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
159
176
|
try {
|
|
160
177
|
await this.S3Manager.headBucket({ Bucket: bucket }).promise();
|
|
161
178
|
} catch (error) {
|
|
@@ -163,7 +180,7 @@ class BucketManager {
|
|
|
163
180
|
throw { title: 'Failed to validate deployment bucket is available', error, bucket };
|
|
164
181
|
}
|
|
165
182
|
|
|
166
|
-
const params = { Bucket: bucket
|
|
183
|
+
const params = { Bucket: bucket };
|
|
167
184
|
if (this.S3Manager.config.region !== 'us-east-1') {
|
|
168
185
|
params.CreateBucketConfiguration = { LocationConstraint: this.S3Manager.config.region };
|
|
169
186
|
}
|
|
@@ -171,6 +188,7 @@ class BucketManager {
|
|
|
171
188
|
await this.S3Manager.putPublicAccessBlock({
|
|
172
189
|
Bucket: bucket, PublicAccessBlockConfiguration: { BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true }
|
|
173
190
|
}).promise();
|
|
191
|
+
await this.S3Manager.putBucketLifecycleConfiguration(bucketLifecycleConfigurationParams).promise();
|
|
174
192
|
}
|
|
175
193
|
}
|
|
176
194
|
|