aws-architect 6.7.66 → 6.7.69
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/README.md +8 -0
- package/index.d.ts +25 -3
- package/index.js +25 -0
- package/lib/CloudFormationDeployer.js +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,14 @@ publishAndDeployStagePromise(options) {
|
|
|
112
112
|
// options.deploymentKeyName
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// Deploy just a new version of a lambda function
|
|
116
|
+
deployLambdaFunctionVersion(options) {
|
|
117
|
+
// options.stage
|
|
118
|
+
// options.functionName
|
|
119
|
+
// options.deploymentBucketName
|
|
120
|
+
// options.deploymentKeyName
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
// Removes a deployed stage, to be used on pull-request created stages (API gateway has a limit fo 5 stages)
|
|
116
124
|
removeStagePromise(stage) {...}
|
|
117
125
|
|
package/index.d.ts
CHANGED
|
@@ -64,19 +64,41 @@ interface WebsiteDeploymentOptions {
|
|
|
64
64
|
|
|
65
65
|
declare class AwsArchitect {
|
|
66
66
|
constructor(packageMetadata: PackageMetadata, apiOptions: ApiOptions, contentOptions: ContentOptions);
|
|
67
|
+
|
|
67
68
|
publishZipArchive(options: PublishZipOptions): Promise<object>;
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
/* CloudFormation */
|
|
71
|
+
// CloudFormation related handlers:
|
|
69
72
|
validateTemplate(stackTemplate: object): Promise<object>;
|
|
70
73
|
deployTemplate(stackTemplate: object, stackConfiguration: StackConfiguration, parameters: object): Promise<object>;
|
|
71
74
|
deployStackSetTemplate(stackTemplate: object, stackSetConfiguration: StackSetConfiguration, parameters: object): Promise<object>;
|
|
72
75
|
configureStackSetForAwsOrganization(stackTemplate: object, stackSetConfiguration: OrganizationalStackSetConfiguration, parameters: object): Promise<object>;
|
|
76
|
+
/* ****** */
|
|
77
|
+
|
|
78
|
+
/* API Gateway */
|
|
79
|
+
// Support for API Gateway stages
|
|
73
80
|
deployStagePromise(stage: string, lambdaVersion: string): Promise<object>;
|
|
74
81
|
removeStagePromise(stage: string, functionName: string): Promise<object>;
|
|
75
|
-
cleanupPreviousFunctionVersions(functionName: string, forceRemovalOfAliases: string): Promise<object>;
|
|
76
82
|
publishAndDeployStagePromise(options: StageDeploymentOptions): Promise<object>;
|
|
83
|
+
/* ****** */
|
|
84
|
+
|
|
85
|
+
/* Lambda Functions */
|
|
86
|
+
// Package a lambda and push it to S3 for deployment
|
|
87
|
+
publishLambdaArtifactPromise(options: PublishLambdaOptions): Promise<object>;
|
|
88
|
+
// Clean up Lambda functions versions that aren't being used
|
|
89
|
+
cleanupPreviousFunctionVersions(functionName: string, forceRemovalOfAliases: string): Promise<object>;
|
|
90
|
+
// Deploy a new version of a lambda function alias
|
|
91
|
+
deployLambdaFunctionVersion(options: StageDeploymentOptions): Promise<object>;
|
|
92
|
+
// Run your lambda microservice locally
|
|
93
|
+
run(port: number, logger: Function): Promise<object>;
|
|
94
|
+
/* ****** */
|
|
95
|
+
|
|
96
|
+
/* S3 Websites using CloudFront */
|
|
97
|
+
// Deploy a new version of a website to S3
|
|
77
98
|
publishWebsite(version: string, options: WebsiteDeploymentOptions): Promise<object>;
|
|
99
|
+
// Delete a version of the website from S3
|
|
78
100
|
deleteWebsiteVersion(version: string): Promise<object>;
|
|
79
|
-
|
|
101
|
+
/* ****** */
|
|
80
102
|
}
|
|
81
103
|
|
|
82
104
|
export = AwsArchitect;
|
package/index.js
CHANGED
|
@@ -195,6 +195,31 @@ AwsArchitect.prototype.removeStagePromise = AwsArchitect.prototype.RemoveStagePr
|
|
|
195
195
|
return { title: 'Successfully deleted stage', stage: stageName, details: result };
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
+
AwsArchitect.prototype.deployLambdaFunctionVersion = async function(options = {}) {
|
|
199
|
+
let stage = options.stage;
|
|
200
|
+
let stageName = getStageName(stage);
|
|
201
|
+
let functionName = options.functionName;
|
|
202
|
+
let bucket = options.deploymentBucketName || this.deploymentBucket;
|
|
203
|
+
let deploymentKey = options.deploymentKeyName;
|
|
204
|
+
if (!stage) { throw new Error('Deployment stage is not defined.'); }
|
|
205
|
+
|
|
206
|
+
try {
|
|
207
|
+
const lambda = await this.LambdaManager.PublishNewVersion(functionName, bucket, deploymentKey);
|
|
208
|
+
const lambdaArn = lambda.FunctionArn;
|
|
209
|
+
const lambdaVersion = lambda.Version;
|
|
210
|
+
await this.LambdaManager.SetAlias(functionName, stageName, lambdaVersion);
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
LambdaResult: {
|
|
214
|
+
LambdaFunctionArn: lambdaArn,
|
|
215
|
+
LambdaVersion: lambdaVersion
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
} catch (failure) {
|
|
219
|
+
throw { Error: 'Failed to create and deploy updates.', Details: failure };
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
198
223
|
AwsArchitect.prototype.publishAndDeployStagePromise = AwsArchitect.prototype.PublishAndDeployStagePromise = async function(options = {}) {
|
|
199
224
|
let stage = options.stage;
|
|
200
225
|
let stageName = getStageName(stage);
|
|
@@ -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
|
-
|
|
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
|
}
|