@adobe/helix-deploy 6.0.0 → 6.2.1
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 +28 -0
- package/index.js +5 -13
- package/package.json +14 -14
- package/src/cli.js +3 -1
- package/src/deploy/AWSConfig.js +41 -1
- package/src/deploy/AWSDeployer.js +117 -18
- package/src/deploy/GoogleDeployer.js +2 -2
- package/src/index.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [6.2.1](https://github.com/adobe/helix-deploy/compare/v6.2.0...v6.2.1) (2022-01-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* properly export development server ([a3b60d8](https://github.com/adobe/helix-deploy/commit/a3b60d8107285a93ba72ed99ec21112b1ee565ed))
|
|
7
|
+
|
|
8
|
+
# [6.2.0](https://github.com/adobe/helix-deploy/compare/v6.1.0...v6.2.0) (2022-01-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* allow to set authorizer identity sources ([#363](https://github.com/adobe/helix-deploy/issues/363)) ([b4b6e30](https://github.com/adobe/helix-deploy/commit/b4b6e30f5e35449c123fcfe38fde851223fd3d4f))
|
|
14
|
+
|
|
15
|
+
# [6.1.0](https://github.com/adobe/helix-deploy/compare/v6.0.1...v6.1.0) (2022-01-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add AWS lambda authorizers support ([#362](https://github.com/adobe/helix-deploy/issues/362)) ([72e4def](https://github.com/adobe/helix-deploy/commit/72e4def53c5cb175447d97b70ec1de17161c1f78)), closes [#261](https://github.com/adobe/helix-deploy/issues/261) [#260](https://github.com/adobe/helix-deploy/issues/260)
|
|
21
|
+
|
|
22
|
+
## [6.0.1](https://github.com/adobe/helix-deploy/compare/v6.0.0...v6.0.1) (2022-01-24)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **deps:** update external fixes ([#360](https://github.com/adobe/helix-deploy/issues/360)) ([93a99c3](https://github.com/adobe/helix-deploy/commit/93a99c33357c92d4ca2aab6c591acc3f8ed4b400))
|
|
28
|
+
|
|
1
29
|
# [6.0.0](https://github.com/adobe/helix-deploy/compare/v5.1.0...v6.0.0) (2022-01-18)
|
|
2
30
|
|
|
3
31
|
|
package/index.js
CHANGED
|
@@ -9,16 +9,8 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
ActionBuilder,
|
|
20
|
-
Bundler,
|
|
21
|
-
BaseConfig,
|
|
22
|
-
CLI,
|
|
23
|
-
DevelopmentServer,
|
|
24
|
-
};
|
|
12
|
+
export { default as ActionBuilder } from './src/ActionBuilder.js';
|
|
13
|
+
export { default as Bundler } from './src/bundler/WebpackBundler.js';
|
|
14
|
+
export { default as BaseConfig } from './src/BaseConfig.js';
|
|
15
|
+
export { default as CLI } from './src/cli.js';
|
|
16
|
+
export { default as DevelopmentServer } from './src/DevelopmentServer.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-deploy",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.1",
|
|
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",
|
|
@@ -39,35 +39,35 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@adobe/fastly-native-promises": "2.0.0",
|
|
41
41
|
"@adobe/helix-fetch": "3.0.0",
|
|
42
|
-
"@aws-sdk/client-apigatewayv2": "3.
|
|
43
|
-
"@aws-sdk/client-lambda": "3.
|
|
44
|
-
"@aws-sdk/client-s3": "3.
|
|
45
|
-
"@aws-sdk/client-secrets-manager": "3.
|
|
46
|
-
"@aws-sdk/client-ssm": "3.
|
|
42
|
+
"@aws-sdk/client-apigatewayv2": "3.48.0",
|
|
43
|
+
"@aws-sdk/client-lambda": "3.48.0",
|
|
44
|
+
"@aws-sdk/client-s3": "3.48.0",
|
|
45
|
+
"@aws-sdk/client-secrets-manager": "3.48.0",
|
|
46
|
+
"@aws-sdk/client-ssm": "3.48.0",
|
|
47
47
|
"@fastly/js-compute": "0.2.1",
|
|
48
48
|
"@google-cloud/functions": "1.2.0",
|
|
49
49
|
"@google-cloud/secret-manager": "3.10.1",
|
|
50
|
-
"@google-cloud/storage": "5.
|
|
50
|
+
"@google-cloud/storage": "5.18.0",
|
|
51
51
|
"@rollup/plugin-alias": "3.1.9",
|
|
52
52
|
"@rollup/plugin-commonjs": "21.0.1",
|
|
53
53
|
"@rollup/plugin-json": "4.1.0",
|
|
54
54
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
55
55
|
"archiver": "5.3.0",
|
|
56
|
-
"chalk-template": "0.3.
|
|
56
|
+
"chalk-template": "0.3.1",
|
|
57
57
|
"constants-browserify": "1.0.0",
|
|
58
|
-
"dotenv": "14.
|
|
58
|
+
"dotenv": "14.2.0",
|
|
59
59
|
"express": "4.17.2",
|
|
60
60
|
"form-data": "4.0.0",
|
|
61
61
|
"fs-extra": "10.0.0",
|
|
62
62
|
"get-stream": "6.0.1",
|
|
63
|
-
"isomorphic-git": "1.10.
|
|
63
|
+
"isomorphic-git": "1.10.5",
|
|
64
64
|
"openwhisk": "3.21.6",
|
|
65
65
|
"proxyquire": "2.1.3",
|
|
66
|
-
"rollup": "2.
|
|
66
|
+
"rollup": "2.66.0",
|
|
67
67
|
"rollup-plugin-terser": "7.0.2",
|
|
68
68
|
"semver": "7.3.5",
|
|
69
69
|
"tar": "6.1.11",
|
|
70
|
-
"webpack": "5.
|
|
70
|
+
"webpack": "5.67.0",
|
|
71
71
|
"yargs": "17.3.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
"eslint-plugin-header": "3.1.1",
|
|
86
86
|
"eslint-plugin-import": "2.25.4",
|
|
87
87
|
"husky": "7.0.4",
|
|
88
|
-
"lint-staged": "12.1
|
|
88
|
+
"lint-staged": "12.3.1",
|
|
89
89
|
"mocha": "9.1.4",
|
|
90
90
|
"mocha-junit-reporter": "2.0.2",
|
|
91
91
|
"mocha-multi-reporters": "1.5.1",
|
|
92
92
|
"nock": "13.2.2",
|
|
93
|
-
"semantic-release": "
|
|
93
|
+
"semantic-release": "19.0.2",
|
|
94
94
|
"sinon": "12.0.1",
|
|
95
95
|
"yauzl": "2.10.0"
|
|
96
96
|
},
|
package/src/cli.js
CHANGED
|
@@ -41,7 +41,9 @@ export default class CLI {
|
|
|
41
41
|
.env('HLX');
|
|
42
42
|
BaseConfig.yarg(this._yargs);
|
|
43
43
|
PLUGINS.forEach((PluginClass) => PluginClass.Config.yarg(this._yargs));
|
|
44
|
-
this._yargs
|
|
44
|
+
this._yargs
|
|
45
|
+
.wrap(Math.min(120, this._yargs.terminalWidth()))
|
|
46
|
+
.help();
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
prepare(args) {
|
package/src/deploy/AWSConfig.js
CHANGED
|
@@ -24,6 +24,9 @@ export default class AWSConfig {
|
|
|
24
24
|
createRoutes: false,
|
|
25
25
|
lambdaFormat: DEFAULT_LAMBDA_FORMAT,
|
|
26
26
|
parameterMgr: ['system', 'secret'],
|
|
27
|
+
createAuthorizer: '',
|
|
28
|
+
attachAuthorizer: '',
|
|
29
|
+
identitySources: ['$request.header.Authorization'],
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -33,6 +36,9 @@ export default class AWSConfig {
|
|
|
33
36
|
.withAWSRole(argv.awsRole)
|
|
34
37
|
.withAWSApi(argv.awsApi)
|
|
35
38
|
.withAWSLambdaFormat(argv.awsLambdaFormat)
|
|
39
|
+
.withAWSCreateAuthorizer(argv.awsCreateAuthorizer)
|
|
40
|
+
.withAWSAttachAuthorizer(argv.awsAttachAuthorizer)
|
|
41
|
+
.withAWSIdentitySources(argv.awsIdentitySource)
|
|
36
42
|
.withAWSCleanUpBuckets(argv.awsCleanupBuckets)
|
|
37
43
|
.withAWSCleanUpIntegrations(argv.awsCleanupIntegrations)
|
|
38
44
|
.withAWSCreateRoutes(argv.awsCreateRoutes)
|
|
@@ -79,9 +85,26 @@ export default class AWSConfig {
|
|
|
79
85
|
return this;
|
|
80
86
|
}
|
|
81
87
|
|
|
88
|
+
withAWSCreateAuthorizer(value) {
|
|
89
|
+
this.createAuthorizer = value;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
withAWSAttachAuthorizer(value) {
|
|
94
|
+
this.attachAuthorizer = value;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
withAWSIdentitySources(value) {
|
|
99
|
+
this.identitySources = value;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
82
103
|
static yarg(yargs) {
|
|
83
104
|
return yargs
|
|
84
|
-
.group(['aws-region', 'aws-api', 'aws-role', 'aws-cleanup-buckets', 'aws-cleanup-integrations',
|
|
105
|
+
.group(['aws-region', 'aws-api', 'aws-role', 'aws-cleanup-buckets', 'aws-cleanup-integrations',
|
|
106
|
+
'aws-create-routes', 'aws-create-authorizer', 'aws-attach-authorizer', 'aws-lambda-format',
|
|
107
|
+
'aws-parameter-manager'], 'AWS Deployment Options')
|
|
85
108
|
.option('aws-region', {
|
|
86
109
|
description: 'the AWS region to deploy lambda functions to',
|
|
87
110
|
type: 'string',
|
|
@@ -113,6 +136,23 @@ export default class AWSConfig {
|
|
|
113
136
|
type: 'string',
|
|
114
137
|
default: DEFAULT_LAMBDA_FORMAT,
|
|
115
138
|
})
|
|
139
|
+
.option('aws-create-authorizer', {
|
|
140
|
+
description: 'Creates API Gateway authorizer using lambda authorization with this function and the specified name. '
|
|
141
|
+
+ 'The string can contain placeholders (note that all dots (\'.\') are replaced with underscores. '
|
|
142
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
143
|
+
+ 'Example: "helix-authorizer_${version}".',
|
|
144
|
+
type: 'string',
|
|
145
|
+
})
|
|
146
|
+
.option('aws-identity-source', {
|
|
147
|
+
description: 'Identity source to used when creating the authorizer',
|
|
148
|
+
type: 'string',
|
|
149
|
+
array: true,
|
|
150
|
+
default: ['$request.header.Authorization'],
|
|
151
|
+
})
|
|
152
|
+
.option('aws-attach-authorizer', {
|
|
153
|
+
description: 'Attach specified authorizer to routes during linking.',
|
|
154
|
+
type: 'string',
|
|
155
|
+
})
|
|
116
156
|
.option('aws-cleanup-buckets', {
|
|
117
157
|
description: 'Cleans up stray temporary S3 buckets',
|
|
118
158
|
type: 'boolean',
|
|
@@ -29,14 +29,14 @@ import {
|
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
31
|
ApiGatewayV2Client,
|
|
32
|
-
CreateApiCommand,
|
|
32
|
+
CreateApiCommand, CreateAuthorizerCommand,
|
|
33
33
|
CreateIntegrationCommand, CreateRouteCommand,
|
|
34
34
|
CreateStageCommand,
|
|
35
35
|
DeleteIntegrationCommand,
|
|
36
36
|
GetApiCommand,
|
|
37
|
-
GetApisCommand,
|
|
37
|
+
GetApisCommand, GetAuthorizersCommand,
|
|
38
38
|
GetIntegrationsCommand, GetRoutesCommand,
|
|
39
|
-
GetStagesCommand, UpdateRouteCommand,
|
|
39
|
+
GetStagesCommand, UpdateAuthorizerCommand, UpdateRouteCommand,
|
|
40
40
|
} from '@aws-sdk/client-apigatewayv2';
|
|
41
41
|
|
|
42
42
|
import { PutParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
|
|
@@ -366,6 +366,20 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
366
366
|
return routes;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
async fetchAuthorizers(ApiId) {
|
|
370
|
+
let nextToken;
|
|
371
|
+
const authorizers = [];
|
|
372
|
+
do {
|
|
373
|
+
const res = await this._api.send(new GetAuthorizersCommand({
|
|
374
|
+
ApiId,
|
|
375
|
+
NextToken: nextToken,
|
|
376
|
+
}));
|
|
377
|
+
authorizers.push(...res.Items);
|
|
378
|
+
nextToken = res.NextToken;
|
|
379
|
+
} while (nextToken);
|
|
380
|
+
return authorizers;
|
|
381
|
+
}
|
|
382
|
+
|
|
369
383
|
async createAPI() {
|
|
370
384
|
const { cfg } = this;
|
|
371
385
|
const { ApiId, ApiEndpoint } = await this.initApiId();
|
|
@@ -404,8 +418,12 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
404
418
|
const { IntegrationId } = integration;
|
|
405
419
|
this.log.info('--: fetching existing routes...');
|
|
406
420
|
const routes = await this.fetchRoutes(ApiId);
|
|
407
|
-
|
|
408
|
-
|
|
421
|
+
const routeParams = {
|
|
422
|
+
ApiId,
|
|
423
|
+
Target: `integrations/${IntegrationId}`,
|
|
424
|
+
};
|
|
425
|
+
await this.createOrUpdateRoute(routes, routeParams, `ANY ${this.functionPath}/{path+}`);
|
|
426
|
+
await this.createOrUpdateRoute(routes, routeParams, `ANY ${this.functionPath}`);
|
|
409
427
|
}
|
|
410
428
|
|
|
411
429
|
// setup permissions for entire package.
|
|
@@ -581,25 +599,24 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
581
599
|
this.log.info(chalk`{green ok}: deleted ${unused.length} unused integrations.`);
|
|
582
600
|
}
|
|
583
601
|
|
|
584
|
-
async createOrUpdateRoute(routes,
|
|
602
|
+
async createOrUpdateRoute(routes, routeParams, RouteKey) {
|
|
585
603
|
const existing = routes.find((r) => r.RouteKey === RouteKey);
|
|
604
|
+
const auth = routeParams.AuthorizerId ? chalk` {yellow (${routeParams.AuthorizerId})}` : '';
|
|
586
605
|
if (existing) {
|
|
587
606
|
this.log.info(chalk`--: updating route for: {blue ${existing.RouteKey}}...`);
|
|
588
607
|
const res = await this._api.send(new UpdateRouteCommand({
|
|
589
|
-
|
|
590
|
-
RouteId: existing.RouteId,
|
|
608
|
+
...routeParams,
|
|
591
609
|
RouteKey,
|
|
592
|
-
|
|
610
|
+
RouteId: existing.RouteId,
|
|
593
611
|
}));
|
|
594
|
-
this.log.info(chalk`{green ok}: updated route for: {blue ${res.RouteKey}}`);
|
|
612
|
+
this.log.info(chalk`{green ok}: updated route for: {blue ${res.RouteKey}}${auth}`);
|
|
595
613
|
} else {
|
|
596
614
|
this.log.info(chalk`--: creating route for: {blue ${RouteKey}}...`);
|
|
597
615
|
const res = await this._api.send(new CreateRouteCommand({
|
|
598
|
-
|
|
616
|
+
...routeParams,
|
|
599
617
|
RouteKey,
|
|
600
|
-
Target: `integrations/${IntegrationId}`,
|
|
601
618
|
}));
|
|
602
|
-
this.log.info(chalk`{green ok}: created route for: {blue ${res.RouteKey}}`);
|
|
619
|
+
this.log.info(chalk`{green ok}: created route for: {blue ${res.RouteKey}}${auth}`);
|
|
603
620
|
}
|
|
604
621
|
}
|
|
605
622
|
|
|
@@ -609,20 +626,22 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
609
626
|
FunctionName: functionName,
|
|
610
627
|
Name: name,
|
|
611
628
|
}));
|
|
612
|
-
this.log.info(chalk`--: updating alias
|
|
629
|
+
this.log.info(chalk`--: updating alias {blue ${name}}...`);
|
|
613
630
|
await this._lambda.send(new UpdateAliasCommand({
|
|
614
631
|
FunctionName: functionName,
|
|
615
632
|
Name: name,
|
|
616
633
|
FunctionVersion: functionVersion,
|
|
617
634
|
}));
|
|
635
|
+
this.log.info(chalk`{green ok:} updated alias {blue ${name}} to version {yellow ${functionVersion}}.`);
|
|
618
636
|
} catch (e) {
|
|
619
637
|
if (e.name === 'ResourceNotFoundException') {
|
|
620
|
-
this.log.info(chalk`--: creating alias
|
|
638
|
+
this.log.info(chalk`--: creating alias {blue ${name}}...`);
|
|
621
639
|
await this._lambda.send(new CreateAliasCommand({
|
|
622
640
|
FunctionName: functionName,
|
|
623
641
|
Name: name,
|
|
624
642
|
FunctionVersion: functionVersion,
|
|
625
643
|
}));
|
|
644
|
+
this.log.info(chalk`{green ok:} created alias {blue ${name}} for version {yellow ${functionVersion}}.`);
|
|
626
645
|
} else {
|
|
627
646
|
this.log.error(`Unable to verify existence of Lambda alias ${name}`);
|
|
628
647
|
throw e;
|
|
@@ -673,16 +692,33 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
673
692
|
const { IntegrationId } = integration;
|
|
674
693
|
|
|
675
694
|
// get all the routes
|
|
676
|
-
this.log.info(chalk`--:
|
|
695
|
+
this.log.info(chalk`--: fetching routes ...`);
|
|
677
696
|
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
|
+
}
|
|
678
714
|
|
|
679
715
|
// create routes for each symlink
|
|
680
716
|
const sfx = this.getLinkVersions();
|
|
681
717
|
|
|
682
718
|
for (const suffix of sfx) {
|
|
683
719
|
// check if route already exists
|
|
684
|
-
await this.createOrUpdateRoute(routes,
|
|
685
|
-
await this.createOrUpdateRoute(routes,
|
|
720
|
+
await this.createOrUpdateRoute(routes, routeParams, `ANY /${cfg.packageName}/${cfg.baseName}/${suffix}`);
|
|
721
|
+
await this.createOrUpdateRoute(routes, routeParams, `ANY /${cfg.packageName}/${cfg.baseName}/${suffix}/{path+}`);
|
|
686
722
|
|
|
687
723
|
// create or update alias
|
|
688
724
|
await this.createOrUpdateAlias(suffix.replace('.', '_'), functionName, incrementalVersion);
|
|
@@ -691,6 +727,69 @@ export default class AWSDeployer extends BaseDeployer {
|
|
|
691
727
|
if (cleanup) {
|
|
692
728
|
await this.cleanUpIntegrations(functionName);
|
|
693
729
|
}
|
|
730
|
+
|
|
731
|
+
await this.updateAuthorizers(ApiId, functionName, aliasArn);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
async updateAuthorizers(ApiId, functionName, aliasArn) {
|
|
735
|
+
const cfg = this._cfg;
|
|
736
|
+
if (!cfg.createAuthorizer) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const AUTH_URI_PREFIX = `arn:aws:apigateway:${cfg.region}:lambda:path/2015-03-31/functions/`;
|
|
741
|
+
const accountId = aliasArn.split(':')[4];
|
|
742
|
+
this.log.info(chalk`--: patching authorizers...`);
|
|
743
|
+
const authorizers = await this.fetchAuthorizers(ApiId);
|
|
744
|
+
const versions = this.getLinkVersions();
|
|
745
|
+
for (const version of versions) {
|
|
746
|
+
const props = {
|
|
747
|
+
...this.cfg,
|
|
748
|
+
...this.cfg.properties,
|
|
749
|
+
// overwrite version with link name
|
|
750
|
+
version,
|
|
751
|
+
};
|
|
752
|
+
const authorizerName = ActionBuilder.substitute(cfg.createAuthorizer, props).replace(/\./g, '_');
|
|
753
|
+
const existing = authorizers.find((info) => info.Name === authorizerName) || {};
|
|
754
|
+
let { AuthorizerId } = existing;
|
|
755
|
+
if (AuthorizerId) {
|
|
756
|
+
const res = await this._api.send(new UpdateAuthorizerCommand({
|
|
757
|
+
ApiId,
|
|
758
|
+
AuthorizerId,
|
|
759
|
+
AuthorizerUri: `${AUTH_URI_PREFIX}${aliasArn}/invocations`,
|
|
760
|
+
IdentitySource: this._cfg.identitySources,
|
|
761
|
+
}));
|
|
762
|
+
this.log.info(chalk`{green ok}: updated authorizer: {blue ${res.Name}}`);
|
|
763
|
+
} else {
|
|
764
|
+
const res = await this._api.send(new CreateAuthorizerCommand({
|
|
765
|
+
ApiId,
|
|
766
|
+
AuthorizerPayloadFormatVersion: '2.0',
|
|
767
|
+
AuthorizerType: 'REQUEST',
|
|
768
|
+
AuthorizerUri: `${AUTH_URI_PREFIX}${aliasArn}/invocations`,
|
|
769
|
+
AuthorizerResultTtlInSeconds: 0,
|
|
770
|
+
EnableSimpleResponses: true,
|
|
771
|
+
IdentitySource: this._cfg.identitySources,
|
|
772
|
+
Name: authorizerName,
|
|
773
|
+
}));
|
|
774
|
+
AuthorizerId = res.AuthorizerId;
|
|
775
|
+
this.log.info(chalk`{green ok}: created authorizer: {blue ${res.Name}}`);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// add permission to alias for the API Gateway is allowed to invoke the authorized function
|
|
779
|
+
try {
|
|
780
|
+
const sourceArn = `arn:aws:execute-api:${this._cfg.region}:${accountId}:${ApiId}/authorizers/${AuthorizerId}`;
|
|
781
|
+
await this._lambda.send(new AddPermissionCommand({
|
|
782
|
+
FunctionName: aliasArn,
|
|
783
|
+
Action: 'lambda:InvokeFunction',
|
|
784
|
+
SourceArn: sourceArn,
|
|
785
|
+
Principal: 'apigateway.amazonaws.com',
|
|
786
|
+
StatementId: crypto.createHash('sha256').update(aliasArn + sourceArn).digest('hex'),
|
|
787
|
+
}));
|
|
788
|
+
this.log.info(chalk`{green ok:} added invoke permissions for ${sourceArn}`);
|
|
789
|
+
} catch (e) {
|
|
790
|
+
// ignore, most likely the permission already exists
|
|
791
|
+
}
|
|
792
|
+
}
|
|
694
793
|
}
|
|
695
794
|
|
|
696
795
|
async checkFunctionReady(arn) {
|
|
@@ -223,8 +223,8 @@ export default class GoogleDeployer extends BaseDeployer {
|
|
|
223
223
|
},
|
|
224
224
|
});
|
|
225
225
|
} catch (err) {
|
|
226
|
-
this.log.error(chalk`{red error:} bad request: ${err.metadata.internalRepr
|
|
227
|
-
this.log.error(chalk`{red error:} details: ${err.metadata.internalRepr
|
|
226
|
+
this.log.error(chalk`{red error:} bad request: ${err.metadata.internalRepr?.get('google.rpc.badrequest-bin')?.toString()}`);
|
|
227
|
+
this.log.error(chalk`{red error:} details: ${err.metadata.internalRepr?.get('grpc-status-details-bin')?.toString()}`);
|
|
228
228
|
throw err;
|
|
229
229
|
}
|
|
230
230
|
|