aws-architect 6.7.69 → 6.7.70
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 +20 -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,24 @@ 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
|
+
};
|
|
159
175
|
try {
|
|
160
176
|
await this.S3Manager.headBucket({ Bucket: bucket }).promise();
|
|
161
177
|
} catch (error) {
|
|
@@ -163,7 +179,7 @@ class BucketManager {
|
|
|
163
179
|
throw { title: 'Failed to validate deployment bucket is available', error, bucket };
|
|
164
180
|
}
|
|
165
181
|
|
|
166
|
-
const params = { Bucket: bucket
|
|
182
|
+
const params = { Bucket: bucket };
|
|
167
183
|
if (this.S3Manager.config.region !== 'us-east-1') {
|
|
168
184
|
params.CreateBucketConfiguration = { LocationConstraint: this.S3Manager.config.region };
|
|
169
185
|
}
|
|
@@ -172,6 +188,7 @@ class BucketManager {
|
|
|
172
188
|
Bucket: bucket, PublicAccessBlockConfiguration: { BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true }
|
|
173
189
|
}).promise();
|
|
174
190
|
}
|
|
191
|
+
await this.S3Manager.putBucketLifecycleConfiguration(bucketLifecycleConfigurationParams).promise();
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
// Ensures a path will be in unix format (that is, forward slash), also on Windows systems.
|