@adobe/helix-deploy 5.0.2 → 5.0.3
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/deploy/AWSDeployer.js +33 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [5.0.3](https://github.com/adobe/helix-deploy/compare/v5.0.2...v5.0.3) (2021-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* wait for aws states completed between deploy steps ([#348](https://github.com/adobe/helix-deploy/issues/348)) ([9cf29ee](https://github.com/adobe/helix-deploy/commit/9cf29ee9807d6334fb951a2a21532ea56b7f9e72))
|
|
7
|
+
|
|
1
8
|
## [5.0.2](https://github.com/adobe/helix-deploy/compare/v5.0.1...v5.0.2) (2021-12-11)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -215,26 +215,41 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
215
215
|
|
|
216
216
|
this.log.info(`--: using lambda role "${this._cfg.role}"`);
|
|
217
217
|
|
|
218
|
+
// check if function already exists
|
|
219
|
+
let baseARN;
|
|
218
220
|
try {
|
|
219
|
-
this.log.info(`--:
|
|
220
|
-
await this._lambda.send(new GetFunctionCommand({
|
|
221
|
+
this.log.info(chalk`--: checking existing Lambda function {yellow ${functionName}}`);
|
|
222
|
+
const { Configuration: { FunctionArn } } = await this._lambda.send(new GetFunctionCommand({
|
|
221
223
|
FunctionName: functionName,
|
|
222
224
|
}));
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
FunctionName: functionName,
|
|
226
|
-
...functionConfig.Code,
|
|
227
|
-
}));
|
|
225
|
+
baseARN = FunctionArn;
|
|
226
|
+
this.log.info(chalk`{green ok}: exist {yellow ${FunctionArn}}`);
|
|
228
227
|
} catch (e) {
|
|
229
228
|
if (e.name === 'ResourceNotFoundException') {
|
|
230
|
-
this.log.info(
|
|
229
|
+
this.log.info(chalk`{green ok}: does not exist yet.`);
|
|
230
|
+
this.log.info(chalk`--: creating new Lambda function {yellow ${functionName}}`);
|
|
231
231
|
await this._lambda.send(new CreateFunctionCommand(functionConfig));
|
|
232
232
|
} else {
|
|
233
|
-
this.log.error(`Unable to verify existence of Lambda function ${functionName}`);
|
|
233
|
+
this.log.error(chalk`Unable to verify existence of Lambda function {yellow ${functionName}}`);
|
|
234
234
|
throw e;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
// update existing function
|
|
239
|
+
if (baseARN) {
|
|
240
|
+
await this.checkFunctionReady(baseARN);
|
|
241
|
+
this.log.info(chalk`--: updating existing Lambda function configuration {yellow ${functionName}}`);
|
|
242
|
+
await this._lambda.send(new UpdateFunctionConfigurationCommand(functionConfig));
|
|
243
|
+
await this.checkFunctionReady(baseARN);
|
|
244
|
+
this.log.info('--: updating Lambda function code...');
|
|
245
|
+
await this._lambda.send(new UpdateFunctionCodeCommand({
|
|
246
|
+
FunctionName: functionName,
|
|
247
|
+
...functionConfig.Code,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
await this.checkFunctionReady(baseARN);
|
|
251
|
+
|
|
252
|
+
this.log.info('--: publishing new version');
|
|
238
253
|
const versiondata = await this._lambda.send(new PublishVersionCommand({
|
|
239
254
|
FunctionName: functionName,
|
|
240
255
|
}));
|
|
@@ -242,22 +257,23 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
242
257
|
this._functionARN = versiondata.FunctionArn;
|
|
243
258
|
// eslint-disable-next-line prefer-destructuring
|
|
244
259
|
this._accountId = this._functionARN.split(':')[4];
|
|
245
|
-
|
|
246
260
|
const versionNum = versiondata.Version;
|
|
261
|
+
this.log.info(chalk`{green ok}: version {yellow ${versionNum}} published.`);
|
|
262
|
+
|
|
247
263
|
try {
|
|
248
264
|
await this._lambda.send(new GetAliasCommand({
|
|
249
265
|
FunctionName: functionName,
|
|
250
266
|
Name: functionVersion,
|
|
251
267
|
}));
|
|
252
268
|
|
|
253
|
-
this.log.info(`--: updating existing alias ${functionName}:${functionVersion} to
|
|
269
|
+
this.log.info(chalk`--: updating existing alias {yellow ${functionName}:${functionVersion}} to version {yellow ${versionNum}}`);
|
|
254
270
|
const updatedata = await this._lambda.send(new UpdateAliasCommand({
|
|
255
271
|
FunctionName: functionName,
|
|
256
272
|
Name: functionVersion,
|
|
257
273
|
FunctionVersion: versionNum,
|
|
258
274
|
}));
|
|
259
|
-
|
|
260
275
|
this._aliasARN = updatedata.AliasArn;
|
|
276
|
+
this.log.info(chalk`{green ok}: alias {yellow ${this._aliasARN}} updated.`);
|
|
261
277
|
} catch (e) {
|
|
262
278
|
if (e.name === 'ResourceNotFoundException') {
|
|
263
279
|
this.log.info(`--: creating new alias ${functionName}:${functionVersion} at v${versionNum}`);
|
|
@@ -267,6 +283,7 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
267
283
|
FunctionVersion: versionNum,
|
|
268
284
|
}));
|
|
269
285
|
this._aliasARN = createdata.AliasArn;
|
|
286
|
+
this.log.info(chalk`{green ok}: alias {yellow ${this._aliasARN}} created.`);
|
|
270
287
|
} else {
|
|
271
288
|
this.log.error(`Unable to verify existence of Lambda alias ${functionName}:${functionVersion}`);
|
|
272
289
|
throw e;
|
|
@@ -676,17 +693,17 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
676
693
|
}
|
|
677
694
|
}
|
|
678
695
|
|
|
679
|
-
async checkFunctionReady() {
|
|
696
|
+
async checkFunctionReady(arn) {
|
|
680
697
|
let tries = 3;
|
|
681
698
|
while (tries > 0) {
|
|
682
699
|
try {
|
|
683
700
|
tries -= 1;
|
|
684
701
|
this.log.info(chalk`--: checking function state ...`);
|
|
685
702
|
const { Configuration } = await this._lambda.send(new GetFunctionCommand({
|
|
686
|
-
FunctionName: this._functionARN,
|
|
703
|
+
FunctionName: arn ?? this._functionARN,
|
|
687
704
|
}));
|
|
688
|
-
if (Configuration.State !== 'Active') {
|
|
689
|
-
this.log.
|
|
705
|
+
if (Configuration.State !== 'Active' || Configuration.LastUpdateStatus === 'InProgress') {
|
|
706
|
+
this.log.info(chalk`{yellow !!:} function is {blue ${Configuration.State}} and last update was {blue ${Configuration.LastUpdateStatus}} (retry...)`);
|
|
690
707
|
} else {
|
|
691
708
|
this.log.info(chalk`{green ok:} function is {blue ${Configuration.State}} and last update was {blue ${Configuration.LastUpdateStatus}}.`);
|
|
692
709
|
return;
|