aws-architect 6.7.67 → 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.
@@ -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, ObjectOwnership: 'BucketOwnerEnforced' };
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.
@@ -115,14 +115,29 @@ class CloudFormationDeployer {
115
115
  }
116
116
  maxErrors += 1;
117
117
  });
118
- }).then(stackStatus => {
118
+ }).then(async stackStatus => {
119
119
  console.log(`Current status of stack ${stackName} is ${stackStatus}.`);
120
120
  if (stackStatus === 'REVIEW_IN_PROGRESS') {
121
121
  throw { error: 'Current status of the stack has failed', status: stackStatus };
122
122
  }
123
123
 
124
124
  if (!allowUpdateRollback && stackStatus === 'UPDATE_ROLLBACK_COMPLETE') {
125
- throw { title: 'Current stack status is failure', status: stackStatus };
125
+ const eventsResponse = await this.cloudFormationClient.describeStackEvents({ StackName: stackName }).promise();
126
+ const failureStackEventStatuses = {
127
+ CREATE_FAILED: true,
128
+ UPDATE_FAILED: true,
129
+ DELETE_FAILED: true,
130
+ IMPORT_FAILED: true,
131
+ IMPORT_ROLLBACK_FAILED: true,
132
+ UPDATE_ROLLBACK_FAILED: true,
133
+ ROLLBACK_FAILED: true
134
+ };
135
+ const mappedResults = eventsResponse.StackEvents.filter(event => failureStackEventStatuses[event.ResourceStatus]).map(result => ({
136
+ cloudFormationResourceName: result.LogicalResourceId, awsResourceId: result.PhysicalResourceId, error: result.ResourceStatusReason
137
+ }));
138
+ console.error('Stack status indicates failure because of the following events: ', mappedResults);
139
+
140
+ throw { title: 'Deployment to the stack failed.', status: stackStatus, code: stackStatus };
126
141
  }
127
142
 
128
143
  if (stackStatus.match(/PROGRESS$/i)) {
@@ -267,6 +282,9 @@ class CloudFormationDeployer {
267
282
 
268
283
  return stackData.Stacks[0];
269
284
  } catch (error) {
285
+ if (error.code === 'UPDATE_ROLLBACK_COMPLETE') {
286
+ throw error;
287
+ }
270
288
  if (error.code === 'ValidationError' || error.code === 'MultipleValidationErrors' || error.code === 'InvalidParameterType') {
271
289
  throw error;
272
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-architect",
3
- "version": "6.7.67",
3
+ "version": "6.7.70",
4
4
  "description": "AWS Architect is a node based tool to configure and deploy AWS-based microservices.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",