@adobe/helix-deploy 6.2.22 → 6.2.25

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 CHANGED
@@ -1,3 +1,24 @@
1
+ ## [6.2.25](https://github.com/adobe/helix-deploy/compare/v6.2.24...v6.2.25) (2022-04-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **aws:** link integration to v alias of function ([#401](https://github.com/adobe/helix-deploy/issues/401)) ([1a46a0e](https://github.com/adobe/helix-deploy/commit/1a46a0e3543d460c5fc3378b8bcf2e3ff837c5d4))
7
+
8
+ ## [6.2.24](https://github.com/adobe/helix-deploy/compare/v6.2.23...v6.2.24) (2022-04-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#400](https://github.com/adobe/helix-deploy/issues/400)) ([4d9623c](https://github.com/adobe/helix-deploy/commit/4d9623c62bf5c7c3bdb6830f7e6fe8b9352ddadb))
14
+
15
+ ## [6.2.23](https://github.com/adobe/helix-deploy/compare/v6.2.22...v6.2.23) (2022-04-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update external fixes ([#396](https://github.com/adobe/helix-deploy/issues/396)) ([7ca715d](https://github.com/adobe/helix-deploy/commit/7ca715d7dbd24a6ac988ea19a6ce2ca1016b54d1))
21
+
1
22
  ## [6.2.22](https://github.com/adobe/helix-deploy/compare/v6.2.21...v6.2.22) (2022-04-02)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "6.2.22",
3
+ "version": "6.2.25",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -37,61 +37,61 @@
37
37
  "@adobe/helix-universal": ">=1.9.0"
38
38
  },
39
39
  "dependencies": {
40
- "@adobe/fastly-native-promises": "2.0.6",
41
- "@adobe/helix-fetch": "3.0.8",
42
- "@aws-sdk/client-apigatewayv2": "3.58.0",
43
- "@aws-sdk/client-lambda": "3.58.0",
44
- "@aws-sdk/client-s3": "3.58.0",
45
- "@aws-sdk/client-secrets-manager": "3.58.0",
46
- "@aws-sdk/client-ssm": "3.58.0",
40
+ "@adobe/fastly-native-promises": "2.0.7",
41
+ "@adobe/helix-fetch": "3.0.9",
42
+ "@aws-sdk/client-apigatewayv2": "3.72.0",
43
+ "@aws-sdk/client-lambda": "3.72.0",
44
+ "@aws-sdk/client-s3": "3.72.0",
45
+ "@aws-sdk/client-secrets-manager": "3.72.0",
46
+ "@aws-sdk/client-ssm": "3.72.0",
47
47
  "@fastly/js-compute": "0.2.4",
48
48
  "@google-cloud/functions": "1.2.0",
49
- "@google-cloud/secret-manager": "3.11.0",
50
- "@google-cloud/storage": "5.18.3",
49
+ "@google-cloud/secret-manager": "3.12.0",
50
+ "@google-cloud/storage": "5.19.2",
51
51
  "@rollup/plugin-alias": "3.1.9",
52
- "@rollup/plugin-commonjs": "21.0.3",
52
+ "@rollup/plugin-commonjs": "21.1.0",
53
53
  "@rollup/plugin-json": "4.1.0",
54
- "@rollup/plugin-node-resolve": "13.1.3",
55
- "archiver": "5.3.0",
54
+ "@rollup/plugin-node-resolve": "13.2.1",
55
+ "archiver": "5.3.1",
56
56
  "chalk-template": "0.4.0",
57
57
  "constants-browserify": "1.0.0",
58
58
  "dotenv": "16.0.0",
59
59
  "express": "4.17.3",
60
60
  "form-data": "4.0.0",
61
- "fs-extra": "10.0.1",
61
+ "fs-extra": "10.1.0",
62
62
  "get-stream": "6.0.1",
63
- "isomorphic-git": "1.17.0",
63
+ "isomorphic-git": "1.17.1",
64
64
  "openwhisk": "3.21.6",
65
65
  "proxyquire": "2.1.3",
66
- "rollup": "2.70.1",
66
+ "rollup": "2.70.2",
67
67
  "rollup-plugin-terser": "7.0.2",
68
- "semver": "7.3.5",
68
+ "semver": "7.3.7",
69
69
  "tar": "6.1.11",
70
- "webpack": "5.71.0",
71
- "yargs": "17.4.0"
70
+ "webpack": "5.72.0",
71
+ "yargs": "17.4.1"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@adobe/eslint-config-helix": "1.3.2",
75
75
  "@adobe/helix-shared-wrap": "1.0.4",
76
- "@adobe/helix-status": "9.2.10",
77
- "@adobe/helix-universal-logger": "2.0.6",
76
+ "@adobe/helix-status": "9.2.11",
77
+ "@adobe/helix-universal-logger": "2.0.7",
78
78
  "@semantic-release/changelog": "6.0.1",
79
79
  "@semantic-release/git": "10.0.1",
80
80
  "c8": "7.11.0",
81
81
  "chai": "4.3.6",
82
82
  "chai-http": "4.3.0",
83
83
  "codecov": "3.8.3",
84
- "eslint": "8.12.0",
84
+ "eslint": "8.13.0",
85
85
  "eslint-plugin-header": "3.1.1",
86
- "eslint-plugin-import": "2.25.4",
86
+ "eslint-plugin-import": "2.26.0",
87
87
  "husky": "7.0.4",
88
- "lint-staged": "12.3.7",
88
+ "lint-staged": "12.3.8",
89
89
  "mocha": "9.2.2",
90
90
  "mocha-junit-reporter": "2.0.2",
91
91
  "mocha-multi-reporters": "1.5.1",
92
92
  "nock": "13.2.4",
93
93
  "semantic-release": "19.0.2",
94
- "sinon": "13.0.1",
94
+ "sinon": "13.0.2",
95
95
  "yauzl": "2.10.0"
96
96
  },
97
97
  "engines": {
@@ -228,7 +228,8 @@ export default class AWSDeployer extends BaseDeployer {
228
228
  if (e.name === 'ResourceNotFoundException') {
229
229
  this.log.info(chalk`{green ok}: does not exist yet.`);
230
230
  this.log.info(chalk`--: creating new Lambda function {yellow ${functionName}}`);
231
- await this._lambda.send(new CreateFunctionCommand(functionConfig));
231
+ const res = await this._lambda.send(new CreateFunctionCommand(functionConfig));
232
+ baseARN = res.FunctionArn;
232
233
  } else {
233
234
  this.log.error(chalk`Unable to verify existence of Lambda function {yellow ${functionName}}`);
234
235
  throw e;
@@ -627,21 +628,23 @@ export default class AWSDeployer extends BaseDeployer {
627
628
  Name: name,
628
629
  }));
629
630
  this.log.info(chalk`--: updating alias {blue ${name}}...`);
630
- await this._lambda.send(new UpdateAliasCommand({
631
+ const res = await this._lambda.send(new UpdateAliasCommand({
631
632
  FunctionName: functionName,
632
633
  Name: name,
633
634
  FunctionVersion: functionVersion,
634
635
  }));
635
636
  this.log.info(chalk`{green ok:} updated alias {blue ${name}} to version {yellow ${functionVersion}}.`);
637
+ return res.AliasArn;
636
638
  } catch (e) {
637
639
  if (e.name === 'ResourceNotFoundException') {
638
640
  this.log.info(chalk`--: creating alias {blue ${name}}...`);
639
- await this._lambda.send(new CreateAliasCommand({
641
+ const res = await this._lambda.send(new CreateAliasCommand({
640
642
  FunctionName: functionName,
641
643
  Name: name,
642
644
  FunctionVersion: functionVersion,
643
645
  }));
644
646
  this.log.info(chalk`{green ok:} created alias {blue ${name}} for version {yellow ${functionVersion}}.`);
647
+ return res.AliasArn;
645
648
  } else {
646
649
  this.log.error(`Unable to verify existence of Lambda alias ${name}`);
647
650
  throw e;
@@ -654,9 +657,7 @@ export default class AWSDeployer extends BaseDeployer {
654
657
  const { ApiId } = await this.initApiId();
655
658
  const functionVersion = cfg.version.replace(/\./g, '_');
656
659
 
657
- // get function alias
658
660
  let res;
659
- let aliasArn;
660
661
  let incrementalVersion;
661
662
  try {
662
663
  this.log.info(chalk`--: fetching alias ...`);
@@ -664,71 +665,95 @@ export default class AWSDeployer extends BaseDeployer {
664
665
  FunctionName: functionName,
665
666
  Name: functionVersion,
666
667
  }));
667
- aliasArn = res.AliasArn;
668
668
  incrementalVersion = res.FunctionVersion;
669
- this.log.info(chalk`{green ok}: ${aliasArn}`);
669
+ this.log.info(chalk`{green ok}: ${functionName}@${functionVersion} => ${incrementalVersion}`);
670
670
  } catch (e) {
671
671
  this.log.error(chalk`{red error}: Unable to create link to function ${functionName}`);
672
672
  throw e;
673
673
  }
674
674
 
675
- // find integration
676
- let integration = await this.findIntegration(ApiId, aliasArn);
677
- let cleanup = false;
678
- if (integration) {
679
- this.log.info(`--: using existing integration "${integration.IntegrationId}" for "${aliasArn}"`);
680
- } else {
681
- integration = await this._api.send(new CreateIntegrationCommand({
682
- ApiId,
683
- IntegrationMethod: 'POST',
684
- IntegrationType: 'AWS_PROXY',
685
- IntegrationUri: aliasArn,
686
- PayloadFormatVersion: '2.0',
687
- TimeoutInMillis: Math.min(cfg.timeout, 30000),
688
- }));
689
- this.log.info(chalk`{green ok:} created new integration "${integration.IntegrationId}" for "${aliasArn}"`);
690
- cleanup = true;
691
- }
692
- const { IntegrationId } = integration;
693
-
694
675
  // get all the routes
695
676
  this.log.info(chalk`--: fetching routes ...`);
696
677
  const routes = await this.fetchRoutes(ApiId);
697
- const routeParams = {
698
- ApiId,
699
- Target: `integrations/${IntegrationId}`,
700
- AuthorizerId: undefined,
701
- AuthorizationType: 'NONE',
702
- };
703
- if (this._cfg.attachAuthorizer) {
704
- this.log.info(chalk`--: fetching authorizers...`);
705
- const authorizers = await this.fetchAuthorizers(ApiId);
706
- const authorizer = authorizers.find((info) => info.Name === this._cfg.attachAuthorizer);
707
- if (!authorizer) {
708
- throw Error(`Specified authorizer ${this._cfg.attachAuthorizer} does not exist in api ${ApiId}.`);
709
- }
710
- routeParams.AuthorizerId = authorizer.AuthorizerId;
711
- routeParams.AuthorizationType = 'CUSTOM';
712
- this.log.info(chalk`{green ok:} configuring routes with authorizer {blue ${this._cfg.attachAuthorizer}} {yellow ${authorizer.AuthorizerId}}`);
713
- }
714
678
 
715
679
  // create routes for each symlink
716
680
  const sfx = this.getLinkVersions();
717
681
 
718
682
  for (const suffix of sfx) {
719
- // check if route already exists
683
+ // create or update alias
684
+ const aliasArn = await this.createOrUpdateAlias(suffix.replace('.', '_'), functionName, incrementalVersion);
685
+
686
+ // find or create integration
687
+ let integration = await this.findIntegration(ApiId, aliasArn);
688
+ if (integration) {
689
+ this.log.info(`--: using existing integration "${integration.IntegrationId}" for "${aliasArn}"`);
690
+ } else {
691
+ integration = await this._api.send(new CreateIntegrationCommand({
692
+ ApiId,
693
+ IntegrationMethod: 'POST',
694
+ IntegrationType: 'AWS_PROXY',
695
+ IntegrationUri: aliasArn,
696
+ PayloadFormatVersion: '2.0',
697
+ TimeoutInMillis: Math.min(cfg.timeout, 30000),
698
+ }));
699
+ this.log.info(chalk`{green ok:} created new integration "${integration.IntegrationId}" for "${aliasArn}"`);
700
+ }
701
+ const { IntegrationId } = integration;
702
+
703
+ const routeParams = {
704
+ ApiId,
705
+ Target: `integrations/${IntegrationId}`,
706
+ AuthorizerId: undefined,
707
+ AuthorizationType: 'NONE',
708
+ };
709
+ if (this._cfg.attachAuthorizer) {
710
+ this.log.info(chalk`--: fetching authorizers...`);
711
+ const authorizers = await this.fetchAuthorizers(ApiId);
712
+ const authorizer = authorizers.find((info) => info.Name === this._cfg.attachAuthorizer);
713
+ if (!authorizer) {
714
+ throw Error(`Specified authorizer ${this._cfg.attachAuthorizer} does not exist in api ${ApiId}.`);
715
+ }
716
+ routeParams.AuthorizerId = authorizer.AuthorizerId;
717
+ routeParams.AuthorizationType = 'CUSTOM';
718
+ this.log.info(chalk`{green ok:} configuring routes with authorizer {blue ${this._cfg.attachAuthorizer}} {yellow ${authorizer.AuthorizerId}}`);
719
+ }
720
+
721
+ // create or update routes
720
722
  await this.createOrUpdateRoute(routes, routeParams, `ANY /${cfg.packageName}/${cfg.baseName}/${suffix}`);
721
723
  await this.createOrUpdateRoute(routes, routeParams, `ANY /${cfg.packageName}/${cfg.baseName}/${suffix}/{path+}`);
722
724
 
723
- // create or update alias
724
- await this.createOrUpdateAlias(suffix.replace('.', '_'), functionName, incrementalVersion);
725
- }
725
+ await this.updateAuthorizers(ApiId, functionName, aliasArn);
726
726
 
727
- if (cleanup) {
728
- await this.cleanUpIntegrations(functionName);
727
+ // add permissions to invoke function (with and without path)
728
+ let sourceArn = `arn:aws:execute-api:${this._cfg.region}:${this._accountId}:${ApiId}/*/*/${cfg.packageName}/${cfg.baseName}/${suffix}`;
729
+ try {
730
+ // eslint-disable-next-line no-await-in-loop
731
+ await this._lambda.send(new AddPermissionCommand({
732
+ FunctionName: aliasArn,
733
+ Action: 'lambda:InvokeFunction',
734
+ SourceArn: sourceArn,
735
+ Principal: 'apigateway.amazonaws.com',
736
+ StatementId: crypto.createHash('md5').update(aliasArn + sourceArn).digest('hex'),
737
+ }));
738
+ this.log.info(chalk`{green ok:} added invoke permissions for ${sourceArn}`);
739
+ } catch (e) {
740
+ // ignore, most likely the permission already exists
741
+ }
742
+ sourceArn = `arn:aws:execute-api:${this._cfg.region}:${this._accountId}:${ApiId}/*/*/${cfg.packageName}/${cfg.baseName}/${suffix}/{path+}`;
743
+ try {
744
+ // eslint-disable-next-line no-await-in-loop
745
+ await this._lambda.send(new AddPermissionCommand({
746
+ FunctionName: aliasArn,
747
+ Action: 'lambda:InvokeFunction',
748
+ SourceArn: sourceArn,
749
+ Principal: 'apigateway.amazonaws.com',
750
+ StatementId: crypto.createHash('md5').update(aliasArn + sourceArn).digest('hex'),
751
+ }));
752
+ this.log.info(chalk`{green ok:} added invoke permissions for ${sourceArn}`);
753
+ } catch (e) {
754
+ // ignore, most likely the permission already exists
755
+ }
729
756
  }
730
-
731
- await this.updateAuthorizers(ApiId, functionName, aliasArn);
732
757
  }
733
758
 
734
759
  async updateAuthorizers(ApiId, functionName, aliasArn) {
@@ -153,7 +153,7 @@ export default class BaseDeployer {
153
153
  }
154
154
 
155
155
  /**
156
- * Returns the link versions based on the configruation. eg ['v8', 'ci']
156
+ * Returns the link versions based on the configuration. eg ['v8', 'ci']
157
157
  */
158
158
  getLinkVersions() {
159
159
  const sfx = [];
@@ -164,7 +164,7 @@ export default class BaseDeployer {
164
164
  if (link === 'major' || link === 'minor') {
165
165
  if (!s) {
166
166
  // eslint-disable-next-line no-underscore-dangle
167
- this.log.warn(chalk`{yellow warn:} unable to create version sequences. error while parsing version: ${this.cfg.version}`);
167
+ this.log.warn(chalk`{yellow warn:} Ignoring ${link} version link for ${this.cfg.version}. No semver format.`);
168
168
  return;
169
169
  }
170
170
  if (link === 'major') {
@@ -54,7 +54,7 @@ export default class FastlyGateway {
54
54
  }));
55
55
 
56
56
  await this._fastly.bulkUpdateDictItems(undefined, 'aliases', ...versionstrings);
57
- this._fastly.discard();
57
+ await this._fastly.discard();
58
58
  this.log.info(chalk`{green ok:} updated links on the Gateway for version ${version}.`);
59
59
  }
60
60