@aws-cdk/toolkit-lib 0.3.1 → 0.3.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/README.md +1 -1
- package/build-info.json +2 -2
- package/db.json.gz +0 -0
- package/lib/actions/bootstrap/index.d.ts +1 -1
- package/lib/actions/bootstrap/index.js +5 -5
- package/lib/actions/deploy/index.d.ts +1 -1
- package/lib/actions/deploy/index.js +1 -1
- package/lib/actions/deploy/private/deploy-options.d.ts +1 -1
- package/lib/actions/deploy/private/deploy-options.js +1 -1
- package/lib/actions/deploy/private/helpers.d.ts +3 -2
- package/lib/actions/deploy/private/helpers.js +3 -3
- package/lib/actions/diff/private/helpers.d.ts +5 -9
- package/lib/actions/diff/private/helpers.js +6 -23
- package/lib/api/aws-auth/account-cache.d.ts +41 -0
- package/lib/api/aws-auth/account-cache.js +108 -0
- package/lib/api/aws-auth/awscli-compatible.d.ts +70 -0
- package/lib/api/aws-auth/awscli-compatible.js +250 -0
- package/lib/api/aws-auth/cached.d.ts +11 -0
- package/lib/api/aws-auth/cached.js +26 -0
- package/lib/api/aws-auth/credential-plugins.d.ts +38 -0
- package/lib/api/aws-auth/credential-plugins.js +154 -0
- package/lib/api/aws-auth/private/index.d.ts +11 -0
- package/lib/api/aws-auth/private/index.js +37 -0
- package/lib/api/aws-auth/provider-caching.d.ts +13 -0
- package/lib/api/aws-auth/provider-caching.js +24 -0
- package/lib/api/aws-auth/proxy-agent.d.ts +13 -0
- package/lib/api/aws-auth/proxy-agent.js +54 -0
- package/lib/api/aws-auth/sdk-logger.d.ts +69 -0
- package/lib/api/aws-auth/sdk-logger.js +128 -0
- package/lib/api/aws-auth/sdk-provider.d.ts +195 -0
- package/lib/api/aws-auth/sdk-provider.js +373 -0
- package/lib/api/aws-auth/sdk.d.ts +235 -0
- package/lib/api/aws-auth/sdk.js +391 -0
- package/lib/api/aws-auth/tracing.d.ts +11 -0
- package/lib/api/aws-auth/tracing.js +60 -0
- package/lib/api/aws-auth/types.d.ts +79 -1
- package/lib/api/aws-auth/types.js +74 -1
- package/lib/api/aws-auth/user-agent.d.ts +7 -0
- package/lib/api/aws-auth/user-agent.js +20 -0
- package/lib/api/aws-auth/util.d.ts +6 -0
- package/lib/api/aws-auth/util.js +21 -0
- package/lib/api/bootstrap/bootstrap-environment.d.ts +35 -0
- package/lib/api/bootstrap/bootstrap-environment.js +323 -0
- package/lib/api/bootstrap/bootstrap-props.d.ts +130 -0
- package/lib/api/bootstrap/bootstrap-props.js +14 -0
- package/lib/api/bootstrap/deploy-bootstrap.d.ts +39 -0
- package/lib/api/bootstrap/deploy-bootstrap.js +147 -0
- package/lib/api/bootstrap/index.d.ts +3 -0
- package/lib/api/bootstrap/index.js +23 -0
- package/lib/api/bootstrap/legacy-template.d.ts +2 -0
- package/lib/api/bootstrap/legacy-template.js +82 -0
- package/lib/api/cloud-assembly/environment.d.ts +43 -0
- package/lib/api/cloud-assembly/environment.js +127 -0
- package/lib/api/cloud-assembly/index.d.ts +1 -1
- package/lib/api/cloud-assembly/index.js +3 -3
- package/lib/api/cloud-assembly/private/context-aware-source.d.ts +1 -1
- package/lib/api/cloud-assembly/private/context-aware-source.js +5 -5
- package/lib/api/cloud-assembly/private/prepare-source.d.ts +2 -1
- package/lib/api/cloud-assembly/private/prepare-source.js +14 -12
- package/lib/api/cloud-assembly/private/readable-assembly.d.ts +1 -1
- package/lib/api/cloud-assembly/private/readable-assembly.js +1 -1
- package/lib/api/cloud-assembly/private/source-builder.js +10 -8
- package/lib/api/cloud-assembly/private/stack-assembly.d.ts +2 -1
- package/lib/api/cloud-assembly/private/stack-assembly.js +10 -9
- package/lib/api/cloud-assembly/stack-assembly.d.ts +55 -0
- package/lib/api/cloud-assembly/stack-assembly.js +139 -0
- package/lib/api/cloud-assembly/stack-collection.d.ts +27 -0
- package/lib/api/cloud-assembly/stack-collection.js +112 -0
- package/lib/api/cloud-assembly/stack-selector.d.ts +81 -2
- package/lib/api/cloud-assembly/stack-selector.js +62 -5
- package/lib/api/cloudformation/evaluate-cloudformation-template.d.ts +85 -0
- package/lib/api/cloudformation/evaluate-cloudformation-template.js +456 -0
- package/lib/api/cloudformation/index.d.ts +4 -0
- package/lib/api/cloudformation/index.js +21 -0
- package/lib/api/cloudformation/nested-stack-helpers.d.ts +25 -0
- package/lib/api/cloudformation/nested-stack-helpers.js +86 -0
- package/lib/api/cloudformation/stack-helpers.d.ts +96 -0
- package/lib/api/cloudformation/stack-helpers.js +163 -0
- package/lib/api/cloudformation/template-body-parameter.d.ts +22 -0
- package/lib/api/cloudformation/template-body-parameter.js +104 -0
- package/lib/api/context.d.ts +40 -0
- package/lib/api/context.js +84 -0
- package/lib/api/deployments/asset-manifest-builder.d.ts +8 -0
- package/lib/api/deployments/asset-manifest-builder.js +33 -0
- package/lib/api/deployments/asset-publishing.d.ts +60 -0
- package/lib/api/deployments/asset-publishing.js +144 -0
- package/lib/api/deployments/assets.d.ts +11 -0
- package/lib/api/deployments/assets.js +109 -0
- package/lib/api/deployments/cfn-api.d.ts +145 -0
- package/lib/api/deployments/cfn-api.js +444 -0
- package/lib/api/deployments/checks.d.ts +9 -0
- package/lib/api/deployments/checks.js +72 -0
- package/lib/api/deployments/deploy-stack.d.ts +164 -0
- package/lib/api/deployments/deploy-stack.js +490 -0
- package/lib/api/deployments/deployment-method.d.ts +24 -0
- package/lib/api/deployments/deployment-method.js +3 -0
- package/lib/api/deployments/deployment-result.d.ts +21 -0
- package/lib/api/deployments/deployment-result.js +10 -0
- package/lib/api/deployments/deployments.d.ts +289 -0
- package/lib/api/deployments/deployments.js +355 -0
- package/lib/api/deployments/index.d.ts +6 -0
- package/lib/api/deployments/index.js +27 -0
- package/lib/api/diff/diff-formatter.d.ts +147 -0
- package/lib/api/diff/diff-formatter.js +225 -0
- package/lib/api/diff/index.d.ts +1 -0
- package/lib/api/diff/index.js +18 -0
- package/lib/api/environment/environment-access.d.ts +139 -0
- package/lib/api/environment/environment-access.js +205 -0
- package/lib/api/environment/environment-resources.d.ts +75 -0
- package/lib/api/environment/environment-resources.js +213 -0
- package/lib/api/environment/index.d.ts +3 -0
- package/lib/api/environment/index.js +20 -0
- package/lib/api/environment/placeholders.d.ts +10 -0
- package/lib/api/environment/placeholders.js +23 -0
- package/lib/api/garbage-collection/garbage-collector.d.ts +158 -0
- package/lib/api/garbage-collection/garbage-collector.js +614 -0
- package/lib/api/garbage-collection/index.d.ts +3 -0
- package/lib/api/garbage-collection/index.js +21 -0
- package/lib/api/garbage-collection/progress-printer.d.ts +23 -0
- package/lib/api/garbage-collection/progress-printer.js +80 -0
- package/lib/api/garbage-collection/stack-refresh.d.ts +49 -0
- package/lib/api/garbage-collection/stack-refresh.js +152 -0
- package/lib/api/hotswap/appsync-mapping-templates.d.ts +4 -0
- package/lib/api/hotswap/appsync-mapping-templates.js +162 -0
- package/lib/api/hotswap/code-build-projects.d.ts +4 -0
- package/lib/api/hotswap/code-build-projects.js +62 -0
- package/lib/api/hotswap/common.d.ts +89 -0
- package/lib/api/hotswap/common.js +137 -0
- package/lib/api/hotswap/ecs-services.d.ts +4 -0
- package/lib/api/hotswap/ecs-services.js +159 -0
- package/lib/api/hotswap/hotswap-deployments.d.ts +17 -0
- package/lib/api/hotswap/hotswap-deployments.js +441 -0
- package/lib/api/hotswap/index.d.ts +2 -0
- package/lib/api/hotswap/index.js +19 -0
- package/lib/api/hotswap/lambda-functions.d.ts +4 -0
- package/lib/api/hotswap/lambda-functions.js +297 -0
- package/lib/api/hotswap/s3-bucket-deployments.d.ts +5 -0
- package/lib/api/hotswap/s3-bucket-deployments.js +117 -0
- package/lib/api/hotswap/stepfunctions-state-machines.d.ts +4 -0
- package/lib/api/hotswap/stepfunctions-state-machines.js +48 -0
- package/lib/api/index.d.ts +25 -0
- package/lib/api/index.js +42 -0
- package/lib/api/io/index.d.ts +3 -1
- package/lib/api/io/index.js +18 -1
- package/lib/api/io/io-host.d.ts +15 -0
- package/lib/api/io/io-host.js +3 -0
- package/lib/api/io/io-message.d.ts +76 -0
- package/lib/api/io/io-message.js +3 -0
- package/lib/api/io/private/index.d.ts +7 -1
- package/lib/api/io/private/index.js +8 -5
- package/lib/api/io/private/io-default-messages.d.ts +21 -0
- package/lib/api/io/private/io-default-messages.js +59 -0
- package/lib/api/io/private/io-helper.d.ts +32 -0
- package/lib/api/io/private/io-helper.js +51 -0
- package/lib/api/io/private/level-priority.d.ts +11 -0
- package/lib/api/io/private/level-priority.js +33 -0
- package/lib/api/io/private/message-maker.d.ts +89 -0
- package/lib/api/io/private/message-maker.js +60 -0
- package/lib/api/io/private/messages.d.ts +178 -0
- package/lib/api/io/private/messages.js +534 -0
- package/lib/api/io/private/span.d.ts +93 -0
- package/lib/api/io/private/span.js +87 -0
- package/lib/api/io/private/testing/fake-io-host.d.ts +28 -0
- package/lib/api/io/private/testing/fake-io-host.js +41 -0
- package/lib/api/io/private/testing/index.d.ts +2 -0
- package/lib/api/io/private/testing/index.js +19 -0
- package/lib/api/io/private/testing/test-io-host.d.ts +27 -0
- package/lib/api/io/private/testing/test-io-host.js +61 -0
- package/lib/api/io/private/types.d.ts +4 -0
- package/lib/api/io/private/types.js +3 -0
- package/lib/api/io/toolkit-action.d.ts +4 -0
- package/lib/api/io/toolkit-action.js +3 -0
- package/lib/api/logs-monitor/find-cloudwatch-logs.d.ts +25 -0
- package/lib/api/logs-monitor/find-cloudwatch-logs.js +95 -0
- package/lib/api/logs-monitor/index.d.ts +2 -0
- package/lib/api/logs-monitor/index.js +19 -0
- package/lib/api/logs-monitor/logs-monitor.d.ts +76 -0
- package/lib/api/logs-monitor/logs-monitor.js +194 -0
- package/lib/api/notices.d.ts +210 -0
- package/lib/api/notices.js +430 -0
- package/lib/api/plugin/context-provider-plugin.d.ts +6 -0
- package/lib/api/plugin/context-provider-plugin.js +7 -0
- package/lib/api/plugin/index.d.ts +3 -0
- package/lib/api/plugin/index.js +20 -0
- package/lib/api/plugin/mode.d.ts +4 -0
- package/lib/api/plugin/mode.js +9 -0
- package/lib/api/plugin/plugin.d.ts +72 -0
- package/lib/api/plugin/plugin.js +132 -0
- package/lib/api/private.d.ts +1 -0
- package/lib/api/private.js +18 -0
- package/lib/api/refactoring/cloudformation.d.ts +15 -0
- package/lib/api/refactoring/cloudformation.js +3 -0
- package/lib/api/refactoring/digest.d.ts +26 -0
- package/lib/api/refactoring/digest.js +175 -0
- package/lib/api/refactoring/index.d.ts +51 -0
- package/lib/api/refactoring/index.js +223 -0
- package/lib/api/require-approval.d.ts +17 -0
- package/lib/api/require-approval.js +22 -0
- package/lib/api/resource-import/importer.d.ts +216 -0
- package/lib/api/resource-import/importer.js +331 -0
- package/lib/api/resource-import/index.d.ts +2 -0
- package/lib/api/resource-import/index.js +19 -0
- package/lib/api/resource-import/migrator.d.ts +26 -0
- package/lib/api/resource-import/migrator.js +73 -0
- package/lib/api/resource-metadata/index.d.ts +1 -0
- package/lib/api/resource-metadata/index.js +18 -0
- package/lib/api/resource-metadata/resource-metadata.d.ts +24 -0
- package/lib/api/resource-metadata/resource-metadata.js +42 -0
- package/lib/api/rwlock.d.ts +60 -0
- package/lib/api/rwlock.js +204 -0
- package/lib/api/settings.d.ts +26 -0
- package/lib/api/settings.js +107 -0
- package/lib/api/shared-private.d.ts +8 -5
- package/lib/api/shared-private.js +2921 -9246
- package/lib/api/shared-private.js.map +4 -4
- package/lib/api/shared-public.d.ts +179 -37
- package/lib/api/shared-public.js +3106 -16
- package/lib/api/shared-public.js.map +4 -4
- package/lib/api/stack-events/index.d.ts +4 -0
- package/lib/api/stack-events/index.js +23 -0
- package/lib/api/stack-events/stack-activity-monitor.d.ts +100 -0
- package/lib/api/stack-events/stack-activity-monitor.js +164 -0
- package/lib/api/stack-events/stack-event-poller.d.ts +69 -0
- package/lib/api/stack-events/stack-event-poller.js +130 -0
- package/lib/api/stack-events/stack-progress-monitor.d.ts +48 -0
- package/lib/api/stack-events/stack-progress-monitor.js +98 -0
- package/lib/api/stack-events/stack-status.d.ts +42 -0
- package/lib/api/stack-events/stack-status.js +90 -0
- package/lib/api/streams.d.ts +7 -0
- package/lib/api/streams.js +24 -0
- package/lib/api/tags.d.ts +9 -0
- package/lib/api/tags.js +10 -0
- package/lib/api/toolkit-error.d.ts +86 -0
- package/lib/api/toolkit-error.js +132 -0
- package/lib/api/toolkit-info.d.ts +52 -0
- package/lib/api/toolkit-info.js +157 -0
- package/lib/api/tree.d.ts +31 -0
- package/lib/api/tree.js +37 -0
- package/lib/api/work-graph/index.d.ts +3 -0
- package/lib/api/work-graph/index.js +20 -0
- package/lib/api/work-graph/work-graph-builder.d.ts +34 -0
- package/lib/api/work-graph/work-graph-builder.js +172 -0
- package/lib/api/work-graph/work-graph-types.d.ts +50 -0
- package/lib/api/work-graph/work-graph-types.js +13 -0
- package/lib/api/work-graph/work-graph.d.ts +72 -0
- package/lib/api/work-graph/work-graph.js +349 -0
- package/lib/context-providers/ami.d.ts +13 -0
- package/lib/context-providers/ami.js +52 -0
- package/lib/context-providers/availability-zones.d.ts +13 -0
- package/lib/context-providers/availability-zones.js +29 -0
- package/lib/context-providers/cc-api-provider.d.ts +30 -0
- package/lib/context-providers/cc-api-provider.js +145 -0
- package/lib/context-providers/endpoint-service-availability-zones.d.ts +13 -0
- package/lib/context-providers/endpoint-service-availability-zones.js +35 -0
- package/lib/context-providers/hosted-zones.d.ts +12 -0
- package/lib/context-providers/hosted-zones.js +69 -0
- package/lib/context-providers/index.d.ts +44 -0
- package/lib/context-providers/index.js +128 -0
- package/lib/context-providers/keys.d.ts +13 -0
- package/lib/context-providers/keys.js +54 -0
- package/lib/context-providers/load-balancers.d.ts +20 -0
- package/lib/context-providers/load-balancers.js +161 -0
- package/lib/context-providers/security-groups.d.ts +9 -0
- package/lib/context-providers/security-groups.js +69 -0
- package/lib/context-providers/ssm-parameters.d.ts +25 -0
- package/lib/context-providers/ssm-parameters.js +61 -0
- package/lib/context-providers/vpcs.d.ts +13 -0
- package/lib/context-providers/vpcs.js +291 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index_bg.wasm +0 -0
- package/lib/payloads/bootstrap-environment-progress.d.ts +17 -0
- package/lib/payloads/bootstrap-environment-progress.js +3 -0
- package/lib/payloads/context.d.ts +9 -0
- package/lib/payloads/context.js +3 -0
- package/lib/payloads/deploy.d.ts +43 -0
- package/lib/payloads/deploy.js +3 -0
- package/lib/payloads/destroy.d.ts +23 -0
- package/lib/payloads/destroy.js +3 -0
- package/lib/payloads/diff.d.ts +31 -0
- package/lib/payloads/diff.js +22 -0
- package/lib/payloads/hotswap.d.ts +211 -0
- package/lib/payloads/hotswap.js +43 -0
- package/lib/payloads/index.d.ts +17 -0
- package/lib/payloads/index.js +34 -0
- package/lib/payloads/list.d.ts +4 -0
- package/lib/payloads/list.js +3 -0
- package/lib/payloads/logs-monitor.d.ts +33 -0
- package/lib/payloads/logs-monitor.js +3 -0
- package/lib/payloads/progress.d.ts +14 -0
- package/lib/payloads/progress.js +3 -0
- package/lib/payloads/refactor.d.ts +14 -0
- package/lib/payloads/refactor.js +3 -0
- package/lib/payloads/rollback.d.ts +17 -0
- package/lib/payloads/rollback.js +3 -0
- package/lib/payloads/sdk-trace.d.ts +20 -0
- package/lib/payloads/sdk-trace.js +3 -0
- package/lib/payloads/stack-activity.d.ts +53 -0
- package/lib/payloads/stack-activity.js +3 -0
- package/lib/payloads/stack-details.d.ts +17 -0
- package/lib/payloads/stack-details.js +3 -0
- package/lib/payloads/synth.d.ts +7 -0
- package/lib/payloads/synth.js +3 -0
- package/lib/payloads/types.d.ts +95 -0
- package/lib/payloads/types.js +3 -0
- package/lib/payloads/watch.d.ts +27 -0
- package/lib/payloads/watch.js +3 -0
- package/lib/private/activity-printer/base.d.ts +50 -0
- package/lib/private/activity-printer/base.js +120 -0
- package/lib/private/activity-printer/current.d.ts +26 -0
- package/lib/private/activity-printer/current.js +122 -0
- package/lib/private/activity-printer/display.d.ts +13 -0
- package/lib/private/activity-printer/display.js +81 -0
- package/lib/private/activity-printer/history.d.ts +32 -0
- package/lib/private/activity-printer/history.js +109 -0
- package/lib/private/activity-printer/index.d.ts +3 -0
- package/lib/private/activity-printer/index.js +20 -0
- package/lib/private/index.d.ts +1 -0
- package/lib/private/index.js +18 -0
- package/lib/private/util.d.ts +1 -1
- package/lib/private/util.js +22 -22
- package/lib/private/util.js.map +2 -2
- package/lib/toolkit/private/index.d.ts +2 -0
- package/lib/toolkit/private/index.js +1 -1
- package/lib/toolkit/toolkit.d.ts +16 -0
- package/lib/toolkit/toolkit.js +158 -124
- package/lib/toolkit/types.d.ts +0 -55
- package/lib/toolkit/types.js +1 -1
- package/lib/util/archive.d.ts +1 -0
- package/lib/util/archive.js +86 -0
- package/lib/util/arrays.d.ts +14 -0
- package/lib/util/arrays.js +36 -0
- package/lib/util/bool.d.ts +7 -0
- package/lib/util/bool.js +13 -0
- package/lib/util/bytes.d.ts +8 -0
- package/lib/util/bytes.js +21 -0
- package/lib/util/cloudformation.d.ts +16 -0
- package/lib/util/cloudformation.js +36 -0
- package/lib/util/content-hash.d.ts +5 -0
- package/lib/util/content-hash.js +43 -0
- package/lib/util/directories.d.ts +22 -0
- package/lib/util/directories.js +59 -0
- package/lib/util/format-error.d.ts +9 -0
- package/lib/util/format-error.js +22 -0
- package/lib/util/index.d.ts +18 -0
- package/lib/util/index.js +35 -0
- package/lib/util/json.d.ts +48 -0
- package/lib/util/json.js +68 -0
- package/lib/util/objects.d.ts +65 -0
- package/lib/util/objects.js +230 -0
- package/lib/util/package-info.d.ts +3 -0
- package/lib/util/package-info.js +22 -0
- package/lib/util/parallel.d.ts +6 -0
- package/lib/util/parallel.js +48 -0
- package/lib/util/serialize.d.ts +27 -0
- package/lib/util/serialize.js +86 -0
- package/lib/util/string-manipulation.d.ts +18 -0
- package/lib/util/string-manipulation.js +46 -0
- package/lib/util/type-brands.d.ts +39 -0
- package/lib/util/type-brands.js +39 -0
- package/lib/util/types.d.ts +27 -0
- package/lib/util/types.js +25 -0
- package/lib/util/version-range.d.ts +2 -0
- package/lib/util/version-range.js +36 -0
- package/lib/util/yaml-cfn.d.ts +15 -0
- package/lib/util/yaml-cfn.js +58 -0
- package/package.json +12 -13
package/lib/api/shared-public.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,22 +17,40 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
30
|
+
var result2 = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
31
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
32
|
+
if (decorator = decorators[i])
|
|
33
|
+
result2 = (kind ? decorator(target, key, result2) : decorator(result2)) || result2;
|
|
34
|
+
if (kind && result2) __defProp(target, key, result2);
|
|
35
|
+
return result2;
|
|
36
|
+
};
|
|
19
37
|
|
|
20
38
|
// lib/api/shared-public.ts
|
|
21
39
|
var shared_public_exports = {};
|
|
22
40
|
__export(shared_public_exports, {
|
|
23
41
|
AssemblyError: () => AssemblyError,
|
|
24
42
|
AuthenticationError: () => AuthenticationError,
|
|
43
|
+
ContextProviderError: () => ContextProviderError,
|
|
25
44
|
ExpandStackSelection: () => ExpandStackSelection,
|
|
26
45
|
NonHotswappableReason: () => NonHotswappableReason,
|
|
27
46
|
PermissionChangeType: () => PermissionChangeType,
|
|
47
|
+
PluginHost: () => PluginHost,
|
|
28
48
|
StackSelectionStrategy: () => StackSelectionStrategy,
|
|
29
49
|
ToolkitError: () => ToolkitError
|
|
30
50
|
});
|
|
31
51
|
module.exports = __toCommonJS(shared_public_exports);
|
|
32
52
|
|
|
33
|
-
//
|
|
53
|
+
// lib/api/toolkit-error.ts
|
|
34
54
|
var TOOLKIT_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit-lib.ToolkitError");
|
|
35
55
|
var AUTHENTICATION_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit-lib.AuthenticationError");
|
|
36
56
|
var ASSEMBLY_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit-lib.AssemblyError");
|
|
@@ -63,8 +83,8 @@ var ToolkitError = class _ToolkitError extends Error {
|
|
|
63
83
|
/**
|
|
64
84
|
* An AssemblyError with an original error as cause
|
|
65
85
|
*/
|
|
66
|
-
static withCause(
|
|
67
|
-
return new _ToolkitError(
|
|
86
|
+
static withCause(message2, error2) {
|
|
87
|
+
return new _ToolkitError(message2, "toolkit", error2);
|
|
68
88
|
}
|
|
69
89
|
/**
|
|
70
90
|
* The type of the error, defaults to "toolkit".
|
|
@@ -78,8 +98,8 @@ var ToolkitError = class _ToolkitError extends Error {
|
|
|
78
98
|
* The specific original cause of the error, if available
|
|
79
99
|
*/
|
|
80
100
|
cause;
|
|
81
|
-
constructor(
|
|
82
|
-
super(
|
|
101
|
+
constructor(message2, type = "toolkit", cause) {
|
|
102
|
+
super(message2);
|
|
83
103
|
Object.setPrototypeOf(this, _ToolkitError.prototype);
|
|
84
104
|
Object.defineProperty(this, TOOLKIT_ERROR_SYMBOL, { value: true });
|
|
85
105
|
this.name = new.target.name;
|
|
@@ -93,8 +113,8 @@ var AuthenticationError = class _AuthenticationError extends ToolkitError {
|
|
|
93
113
|
* Denotes the source of the error as user.
|
|
94
114
|
*/
|
|
95
115
|
source = "user";
|
|
96
|
-
constructor(
|
|
97
|
-
super(
|
|
116
|
+
constructor(message2) {
|
|
117
|
+
super(message2, "authentication");
|
|
98
118
|
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
99
119
|
Object.defineProperty(this, AUTHENTICATION_ERROR_SYMBOL, { value: true });
|
|
100
120
|
}
|
|
@@ -103,14 +123,14 @@ var AssemblyError = class _AssemblyError extends ToolkitError {
|
|
|
103
123
|
/**
|
|
104
124
|
* An AssemblyError with an original error as cause
|
|
105
125
|
*/
|
|
106
|
-
static withCause(
|
|
107
|
-
return new _AssemblyError(
|
|
126
|
+
static withCause(message2, error2) {
|
|
127
|
+
return new _AssemblyError(message2, void 0, error2);
|
|
108
128
|
}
|
|
109
129
|
/**
|
|
110
130
|
* An AssemblyError with a list of stacks as cause
|
|
111
131
|
*/
|
|
112
|
-
static withStacks(
|
|
113
|
-
return new _AssemblyError(
|
|
132
|
+
static withStacks(message2, stacks) {
|
|
133
|
+
return new _AssemblyError(message2, stacks);
|
|
114
134
|
}
|
|
115
135
|
/**
|
|
116
136
|
* Denotes the source of the error as user.
|
|
@@ -123,15 +143,26 @@ var AssemblyError = class _AssemblyError extends ToolkitError {
|
|
|
123
143
|
* Absence indicates synthesis didn't fully complete.
|
|
124
144
|
*/
|
|
125
145
|
stacks;
|
|
126
|
-
constructor(
|
|
127
|
-
super(
|
|
146
|
+
constructor(message2, stacks, cause) {
|
|
147
|
+
super(message2, "assembly", cause);
|
|
128
148
|
Object.setPrototypeOf(this, _AssemblyError.prototype);
|
|
129
149
|
Object.defineProperty(this, ASSEMBLY_ERROR_SYMBOL, { value: true });
|
|
130
150
|
this.stacks = stacks;
|
|
131
151
|
}
|
|
132
152
|
};
|
|
153
|
+
var ContextProviderError = class _ContextProviderError extends ToolkitError {
|
|
154
|
+
/**
|
|
155
|
+
* Denotes the source of the error as user.
|
|
156
|
+
*/
|
|
157
|
+
source = "user";
|
|
158
|
+
constructor(message2) {
|
|
159
|
+
super(message2, "context-provider");
|
|
160
|
+
Object.setPrototypeOf(this, _ContextProviderError.prototype);
|
|
161
|
+
Object.defineProperty(this, CONTEXT_PROVIDER_ERROR_SYMBOL, { value: true });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
133
164
|
|
|
134
|
-
//
|
|
165
|
+
// lib/api/cloud-assembly/stack-selector.ts
|
|
135
166
|
var StackSelectionStrategy = /* @__PURE__ */ ((StackSelectionStrategy2) => {
|
|
136
167
|
StackSelectionStrategy2["ALL_STACKS"] = "all-stacks";
|
|
137
168
|
StackSelectionStrategy2["MAIN_ASSEMBLY"] = "main-assembly";
|
|
@@ -148,7 +179,3064 @@ var ExpandStackSelection = /* @__PURE__ */ ((ExpandStackSelection2) => {
|
|
|
148
179
|
return ExpandStackSelection2;
|
|
149
180
|
})(ExpandStackSelection || {});
|
|
150
181
|
|
|
151
|
-
//
|
|
182
|
+
// lib/api/resource-metadata/resource-metadata.ts
|
|
183
|
+
var import_cloud_assembly_schema = require("@aws-cdk/cloud-assembly-schema");
|
|
184
|
+
|
|
185
|
+
// lib/api/plugin/plugin.ts
|
|
186
|
+
var import_util27 = require("util");
|
|
187
|
+
|
|
188
|
+
// lib/api/plugin/context-provider-plugin.ts
|
|
189
|
+
function isContextProviderPlugin(x) {
|
|
190
|
+
return typeof x === "object" && !!x && !!x.getValue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// lib/util/archive.ts
|
|
194
|
+
var glob = __toESM(require("glob"));
|
|
195
|
+
|
|
196
|
+
// lib/util/format-error.ts
|
|
197
|
+
function formatErrorMessage(error2) {
|
|
198
|
+
if (error2 && Array.isArray(error2.errors)) {
|
|
199
|
+
const innerMessages = error2.errors.map((innerError) => innerError?.message || innerError?.toString()).join("\n");
|
|
200
|
+
return `AggregateError: ${innerMessages}`;
|
|
201
|
+
}
|
|
202
|
+
return error2?.message || error2?.toString() || "Unknown error";
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// lib/util/archive.ts
|
|
206
|
+
var archiver = require("archiver");
|
|
207
|
+
|
|
208
|
+
// lib/util/directories.ts
|
|
209
|
+
var fs = __toESM(require("fs"));
|
|
210
|
+
var os = __toESM(require("os"));
|
|
211
|
+
var path = __toESM(require("path"));
|
|
212
|
+
function cdkHomeDir() {
|
|
213
|
+
const tmpDir = fs.realpathSync(os.tmpdir());
|
|
214
|
+
let home;
|
|
215
|
+
try {
|
|
216
|
+
let userInfoHome = os.userInfo().homedir;
|
|
217
|
+
if (userInfoHome == "/var/empty") {
|
|
218
|
+
userInfoHome = void 0;
|
|
219
|
+
}
|
|
220
|
+
home = path.join((userInfoHome ?? os.homedir()).trim(), ".cdk");
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
return process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : home || fs.mkdtempSync(path.join(tmpDir, ".cdk")).trim();
|
|
224
|
+
}
|
|
225
|
+
function cdkCacheDir() {
|
|
226
|
+
return path.join(cdkHomeDir(), "cache");
|
|
227
|
+
}
|
|
228
|
+
function bundledPackageRootDir(start, fail) {
|
|
229
|
+
function _rootDir(dirname2) {
|
|
230
|
+
const manifestPath = path.join(dirname2, "package.json");
|
|
231
|
+
if (fs.existsSync(manifestPath)) {
|
|
232
|
+
return dirname2;
|
|
233
|
+
}
|
|
234
|
+
if (path.dirname(dirname2) === dirname2) {
|
|
235
|
+
if (fail ?? true) {
|
|
236
|
+
throw new ToolkitError("Unable to find package manifest");
|
|
237
|
+
}
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
240
|
+
return _rootDir(path.dirname(dirname2));
|
|
241
|
+
}
|
|
242
|
+
return _rootDir(start);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// lib/util/json.ts
|
|
246
|
+
function getResultObj(jsonObject, identifier, propertiesToReturn) {
|
|
247
|
+
const propsObj = {};
|
|
248
|
+
propertiesToReturn.forEach((propName) => {
|
|
249
|
+
Object.assign(propsObj, { [propName]: findJsonValue(jsonObject, propName) });
|
|
250
|
+
});
|
|
251
|
+
Object.assign(propsObj, { ["Identifier"]: identifier });
|
|
252
|
+
return propsObj;
|
|
253
|
+
}
|
|
254
|
+
function findJsonValue(jsonObject, path5) {
|
|
255
|
+
const paths = path5.split(".");
|
|
256
|
+
let obj = jsonObject;
|
|
257
|
+
paths.forEach((p) => {
|
|
258
|
+
obj = obj[p];
|
|
259
|
+
if (obj === void 0) {
|
|
260
|
+
throw new TypeError(`Cannot read field ${path5}. ${p} is not found.`);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
return obj;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// lib/util/types.ts
|
|
267
|
+
var isArray = Array.isArray;
|
|
268
|
+
|
|
269
|
+
// lib/util/yaml-cfn.ts
|
|
270
|
+
var yaml = __toESM(require("yaml"));
|
|
271
|
+
var yaml_types = __toESM(require("yaml/types"));
|
|
272
|
+
function makeTagForCfnIntrinsic(intrinsicName, addFnPrefix) {
|
|
273
|
+
return {
|
|
274
|
+
identify(value) {
|
|
275
|
+
return typeof value === "string";
|
|
276
|
+
},
|
|
277
|
+
tag: `!${intrinsicName}`,
|
|
278
|
+
resolve: (_doc, cstNode) => {
|
|
279
|
+
const ret = {};
|
|
280
|
+
ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] = // the +1 is to account for the ! the short form begins with
|
|
281
|
+
parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));
|
|
282
|
+
return ret;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
var shortForms = [
|
|
287
|
+
"Base64",
|
|
288
|
+
"Cidr",
|
|
289
|
+
"FindInMap",
|
|
290
|
+
"GetAZs",
|
|
291
|
+
"ImportValue",
|
|
292
|
+
"Join",
|
|
293
|
+
"Sub",
|
|
294
|
+
"Select",
|
|
295
|
+
"Split",
|
|
296
|
+
"Transform",
|
|
297
|
+
"And",
|
|
298
|
+
"Equals",
|
|
299
|
+
"If",
|
|
300
|
+
"Not",
|
|
301
|
+
"Or",
|
|
302
|
+
"GetAtt"
|
|
303
|
+
].map((name) => makeTagForCfnIntrinsic(name, true)).concat(
|
|
304
|
+
makeTagForCfnIntrinsic("Ref", false),
|
|
305
|
+
makeTagForCfnIntrinsic("Condition", false)
|
|
306
|
+
);
|
|
307
|
+
function parseYamlStrWithCfnTags(text) {
|
|
308
|
+
return yaml.parse(text, {
|
|
309
|
+
customTags: shortForms,
|
|
310
|
+
schema: "core"
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// lib/util/string-manipulation.ts
|
|
315
|
+
function formatTime(num) {
|
|
316
|
+
return roundPercentage(millisecondsToSeconds(num));
|
|
317
|
+
}
|
|
318
|
+
function roundPercentage(num) {
|
|
319
|
+
return Math.round(100 * num) / 100;
|
|
320
|
+
}
|
|
321
|
+
function millisecondsToSeconds(num) {
|
|
322
|
+
return num / 1e3;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// lib/util/version-range.ts
|
|
326
|
+
var semver = __toESM(require("semver"));
|
|
327
|
+
|
|
328
|
+
// lib/private/dispose-polyfill.ts
|
|
329
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
330
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
331
|
+
|
|
332
|
+
// lib/private/activity-printer/history.ts
|
|
333
|
+
var chalk = __toESM(require("chalk"));
|
|
334
|
+
|
|
335
|
+
// lib/private/activity-printer/current.ts
|
|
336
|
+
var chalk2 = __toESM(require("chalk"));
|
|
337
|
+
|
|
338
|
+
// lib/private/activity-printer/display.ts
|
|
339
|
+
var wrapAnsi = require("wrap-ansi");
|
|
340
|
+
|
|
341
|
+
// lib/private/activity-printer/current.ts
|
|
342
|
+
var PROGRESSBAR_EXTRA_SPACE = 2 + 2 + 4 + 6;
|
|
343
|
+
|
|
344
|
+
// lib/api/aws-auth/proxy-agent.ts
|
|
345
|
+
var fs2 = __toESM(require("fs-extra"));
|
|
346
|
+
var import_proxy_agent = require("proxy-agent");
|
|
347
|
+
|
|
348
|
+
// lib/api/aws-auth/sdk.ts
|
|
349
|
+
var import_client_appsync = require("@aws-sdk/client-appsync");
|
|
350
|
+
var import_client_cloudcontrol = require("@aws-sdk/client-cloudcontrol");
|
|
351
|
+
var import_client_cloudformation = require("@aws-sdk/client-cloudformation");
|
|
352
|
+
var import_client_cloudwatch_logs = require("@aws-sdk/client-cloudwatch-logs");
|
|
353
|
+
var import_client_codebuild = require("@aws-sdk/client-codebuild");
|
|
354
|
+
var import_client_ec2 = require("@aws-sdk/client-ec2");
|
|
355
|
+
var import_client_ecr = require("@aws-sdk/client-ecr");
|
|
356
|
+
var import_client_ecs = require("@aws-sdk/client-ecs");
|
|
357
|
+
var import_client_elastic_load_balancing_v2 = require("@aws-sdk/client-elastic-load-balancing-v2");
|
|
358
|
+
var import_client_iam = require("@aws-sdk/client-iam");
|
|
359
|
+
var import_client_kms = require("@aws-sdk/client-kms");
|
|
360
|
+
var import_client_lambda = require("@aws-sdk/client-lambda");
|
|
361
|
+
var import_client_route_53 = require("@aws-sdk/client-route-53");
|
|
362
|
+
var import_client_s3 = require("@aws-sdk/client-s3");
|
|
363
|
+
var import_client_secrets_manager = require("@aws-sdk/client-secrets-manager");
|
|
364
|
+
var import_client_sfn = require("@aws-sdk/client-sfn");
|
|
365
|
+
var import_client_ssm = require("@aws-sdk/client-ssm");
|
|
366
|
+
var import_client_sts = require("@aws-sdk/client-sts");
|
|
367
|
+
var import_lib_storage = require("@aws-sdk/lib-storage");
|
|
368
|
+
var import_middleware_endpoint = require("@smithy/middleware-endpoint");
|
|
369
|
+
var import_util_retry = require("@smithy/util-retry");
|
|
370
|
+
|
|
371
|
+
// lib/api/aws-auth/account-cache.ts
|
|
372
|
+
var path2 = __toESM(require("path"));
|
|
373
|
+
var fs3 = __toESM(require("fs-extra"));
|
|
374
|
+
var AccountAccessKeyCache = class _AccountAccessKeyCache {
|
|
375
|
+
/**
|
|
376
|
+
* Max number of entries in the cache, after which the cache will be reset.
|
|
377
|
+
*/
|
|
378
|
+
static MAX_ENTRIES = 1e3;
|
|
379
|
+
/**
|
|
380
|
+
* The default path used for the accounts access key cache
|
|
381
|
+
*/
|
|
382
|
+
static get DEFAULT_PATH() {
|
|
383
|
+
return path2.join(cdkCacheDir(), "accounts_partitions.json");
|
|
384
|
+
}
|
|
385
|
+
cacheFile;
|
|
386
|
+
debug;
|
|
387
|
+
/**
|
|
388
|
+
* @param filePath Path to the cache file
|
|
389
|
+
*/
|
|
390
|
+
constructor(filePath = _AccountAccessKeyCache.DEFAULT_PATH, debugFn) {
|
|
391
|
+
this.cacheFile = filePath;
|
|
392
|
+
this.debug = debugFn;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Tries to fetch the account ID from cache. If it's not in the cache, invokes
|
|
396
|
+
* the resolver function which should retrieve the account ID and return it.
|
|
397
|
+
* Then, it will be stored into disk cache returned.
|
|
398
|
+
*
|
|
399
|
+
* Example:
|
|
400
|
+
*
|
|
401
|
+
* const accountId = cache.fetch(accessKey, async () => {
|
|
402
|
+
* return await fetchAccountIdFromSomewhere(accessKey);
|
|
403
|
+
* });
|
|
404
|
+
*/
|
|
405
|
+
async fetch(accessKeyId, resolver) {
|
|
406
|
+
const cached2 = await this.get(accessKeyId);
|
|
407
|
+
if (cached2) {
|
|
408
|
+
await this.debug(`Retrieved account ID ${cached2.accountId} from disk cache`);
|
|
409
|
+
return cached2;
|
|
410
|
+
}
|
|
411
|
+
const account = await resolver();
|
|
412
|
+
if (account) {
|
|
413
|
+
await this.put(accessKeyId, account);
|
|
414
|
+
}
|
|
415
|
+
return account;
|
|
416
|
+
}
|
|
417
|
+
/** Get the account ID from an access key or undefined if not in cache */
|
|
418
|
+
async get(accessKeyId) {
|
|
419
|
+
const map = await this.loadMap();
|
|
420
|
+
return map[accessKeyId];
|
|
421
|
+
}
|
|
422
|
+
/** Put a mapping between access key and account ID */
|
|
423
|
+
async put(accessKeyId, account) {
|
|
424
|
+
let map = await this.loadMap();
|
|
425
|
+
if (Object.keys(map).length >= _AccountAccessKeyCache.MAX_ENTRIES) {
|
|
426
|
+
map = {};
|
|
427
|
+
}
|
|
428
|
+
map[accessKeyId] = account;
|
|
429
|
+
await this.saveMap(map);
|
|
430
|
+
}
|
|
431
|
+
async loadMap() {
|
|
432
|
+
try {
|
|
433
|
+
return await fs3.readJson(this.cacheFile);
|
|
434
|
+
} catch (e) {
|
|
435
|
+
if (e.code === "ENOENT" || e.code === "EACCES") {
|
|
436
|
+
return {};
|
|
437
|
+
}
|
|
438
|
+
if (e instanceof SyntaxError) {
|
|
439
|
+
return {};
|
|
440
|
+
}
|
|
441
|
+
throw e;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
async saveMap(map) {
|
|
445
|
+
try {
|
|
446
|
+
await fs3.ensureFile(this.cacheFile);
|
|
447
|
+
await fs3.writeJson(this.cacheFile, map, { spaces: 2 });
|
|
448
|
+
} catch (e) {
|
|
449
|
+
if (e.code === "ENOENT" || e.code === "EACCES" || e.code === "EROFS") {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
throw e;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// lib/api/aws-auth/cached.ts
|
|
458
|
+
function cached(obj, sym, fn) {
|
|
459
|
+
if (!(sym in obj)) {
|
|
460
|
+
obj[sym] = fn();
|
|
461
|
+
}
|
|
462
|
+
return obj[sym];
|
|
463
|
+
}
|
|
464
|
+
async function cachedAsync(obj, sym, fn) {
|
|
465
|
+
if (!(sym in obj)) {
|
|
466
|
+
obj[sym] = await fn();
|
|
467
|
+
}
|
|
468
|
+
return obj[sym];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// lib/api/aws-auth/tracing.ts
|
|
472
|
+
var ENABLED = false;
|
|
473
|
+
var INDENT = 0;
|
|
474
|
+
function callTrace(fn, className, logger) {
|
|
475
|
+
if (!ENABLED || !logger) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
logger.info(`[trace] ${" ".repeat(INDENT)}${className || "(anonymous)"}#${fn}()`);
|
|
479
|
+
}
|
|
480
|
+
function traceCall(receiver, _propertyKey, descriptor, parentClassName) {
|
|
481
|
+
const fn = descriptor.value;
|
|
482
|
+
const className = typeof receiver === "function" ? receiver.name : parentClassName;
|
|
483
|
+
descriptor.value = function(...args) {
|
|
484
|
+
const logger = this.logger;
|
|
485
|
+
if (!ENABLED || typeof logger?.info !== "function") {
|
|
486
|
+
return fn.apply(this, args);
|
|
487
|
+
}
|
|
488
|
+
logger.info.apply(logger, [`[trace] ${" ".repeat(INDENT)}${className || this.constructor.name || "(anonymous)"}#${fn.name}()`]);
|
|
489
|
+
INDENT += 2;
|
|
490
|
+
const ret = fn.apply(this, args);
|
|
491
|
+
if (ret instanceof Promise) {
|
|
492
|
+
return ret.finally(() => {
|
|
493
|
+
INDENT -= 2;
|
|
494
|
+
});
|
|
495
|
+
} else {
|
|
496
|
+
INDENT -= 2;
|
|
497
|
+
return ret;
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
return descriptor;
|
|
501
|
+
}
|
|
502
|
+
function traceMemberMethods(constructor) {
|
|
503
|
+
for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(constructor.prototype))) {
|
|
504
|
+
if (typeof descriptor.value !== "function") {
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
const newDescriptor = traceCall(constructor.prototype, name, descriptor, constructor.name) ?? descriptor;
|
|
508
|
+
Object.defineProperty(constructor.prototype, name, newDescriptor);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// lib/api/aws-auth/user-agent.ts
|
|
513
|
+
var path3 = __toESM(require("path"));
|
|
514
|
+
|
|
515
|
+
// lib/api/aws-auth/util.ts
|
|
516
|
+
var fs4 = __toESM(require("fs-extra"));
|
|
517
|
+
function readIfPossible(filename) {
|
|
518
|
+
try {
|
|
519
|
+
if (!fs4.pathExistsSync(filename)) {
|
|
520
|
+
return void 0;
|
|
521
|
+
}
|
|
522
|
+
return fs4.readFileSync(filename, { encoding: "utf-8" });
|
|
523
|
+
} catch (e) {
|
|
524
|
+
return void 0;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// lib/api/aws-auth/user-agent.ts
|
|
529
|
+
function defaultCliUserAgent() {
|
|
530
|
+
const root = bundledPackageRootDir(__dirname, false);
|
|
531
|
+
const pkg = JSON.parse((root ? readIfPossible(path3.join(root, "package.json")) : void 0) ?? "{}");
|
|
532
|
+
const name = pkg.name ?? path3.basename(process.argv[1] ?? "cdk-cli");
|
|
533
|
+
const version = pkg.version ?? "<unknown>";
|
|
534
|
+
return `${name}/${version}`;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// lib/api/aws-auth/sdk.ts
|
|
538
|
+
var SDK = class {
|
|
539
|
+
constructor(credProvider, region, requestHandler, ioHelper, logger) {
|
|
540
|
+
this.credProvider = credProvider;
|
|
541
|
+
const debugFn = async (msg) => ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(msg));
|
|
542
|
+
this.accountCache = new AccountAccessKeyCache(AccountAccessKeyCache.DEFAULT_PATH, debugFn);
|
|
543
|
+
this.debug = debugFn;
|
|
544
|
+
this.config = {
|
|
545
|
+
region,
|
|
546
|
+
credentials: credProvider,
|
|
547
|
+
requestHandler,
|
|
548
|
+
retryStrategy: new import_util_retry.ConfiguredRetryStrategy(7, (attempt) => 300 * 2 ** attempt),
|
|
549
|
+
customUserAgent: defaultCliUserAgent(),
|
|
550
|
+
logger
|
|
551
|
+
};
|
|
552
|
+
this.logger = logger;
|
|
553
|
+
this.currentRegion = region;
|
|
554
|
+
}
|
|
555
|
+
currentRegion;
|
|
556
|
+
config;
|
|
557
|
+
logger;
|
|
558
|
+
accountCache;
|
|
559
|
+
/**
|
|
560
|
+
* STS is used to check credential validity, don't do too many retries.
|
|
561
|
+
*/
|
|
562
|
+
stsRetryStrategy = new import_util_retry.ConfiguredRetryStrategy(3, (attempt) => 100 * 2 ** attempt);
|
|
563
|
+
/**
|
|
564
|
+
* Whether we have proof that the credentials have not expired
|
|
565
|
+
*
|
|
566
|
+
* We need to do some manual plumbing around this because the JS SDKv2 treats `ExpiredToken`
|
|
567
|
+
* as retriable and we have hefty retries on CFN calls making the CLI hang for a good 15 minutes
|
|
568
|
+
* if the credentials have expired.
|
|
569
|
+
*/
|
|
570
|
+
_credentialsValidated = false;
|
|
571
|
+
/**
|
|
572
|
+
* A function to create debug messages
|
|
573
|
+
*/
|
|
574
|
+
debug;
|
|
575
|
+
appendCustomUserAgent(userAgentData) {
|
|
576
|
+
if (!userAgentData) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
const currentCustomUserAgent = this.config.customUserAgent;
|
|
580
|
+
this.config.customUserAgent = currentCustomUserAgent ? `${currentCustomUserAgent} ${userAgentData}` : userAgentData;
|
|
581
|
+
}
|
|
582
|
+
removeCustomUserAgent(userAgentData) {
|
|
583
|
+
this.config.customUserAgent = this.config.customUserAgent?.replace(userAgentData, "");
|
|
584
|
+
}
|
|
585
|
+
appsync() {
|
|
586
|
+
const client = new import_client_appsync.AppSyncClient(this.config);
|
|
587
|
+
return {
|
|
588
|
+
getSchemaCreationStatus: (input) => client.send(new import_client_appsync.GetSchemaCreationStatusCommand(input)),
|
|
589
|
+
startSchemaCreation: (input) => client.send(new import_client_appsync.StartSchemaCreationCommand(input)),
|
|
590
|
+
updateApiKey: (input) => client.send(new import_client_appsync.UpdateApiKeyCommand(input)),
|
|
591
|
+
updateFunction: (input) => client.send(new import_client_appsync.UpdateFunctionCommand(input)),
|
|
592
|
+
updateResolver: (input) => client.send(new import_client_appsync.UpdateResolverCommand(input)),
|
|
593
|
+
// Pagination Functions
|
|
594
|
+
listFunctions: async (input) => {
|
|
595
|
+
const functions = Array();
|
|
596
|
+
const paginator = (0, import_client_appsync.paginateListFunctions)({ client }, input);
|
|
597
|
+
for await (const page of paginator) {
|
|
598
|
+
functions.push(...page.functions || []);
|
|
599
|
+
}
|
|
600
|
+
return functions;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
cloudControl() {
|
|
605
|
+
const client = new import_client_cloudcontrol.CloudControlClient(this.config);
|
|
606
|
+
return {
|
|
607
|
+
listResources: (input) => client.send(new import_client_cloudcontrol.ListResourcesCommand(input)),
|
|
608
|
+
getResource: (input) => client.send(new import_client_cloudcontrol.GetResourceCommand(input))
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
cloudFormation() {
|
|
612
|
+
const client = new import_client_cloudformation.CloudFormationClient({
|
|
613
|
+
...this.config,
|
|
614
|
+
retryStrategy: new import_util_retry.ConfiguredRetryStrategy(11, (attempt) => 1e3 * 2 ** attempt)
|
|
615
|
+
});
|
|
616
|
+
return {
|
|
617
|
+
continueUpdateRollback: async (input) => client.send(new import_client_cloudformation.ContinueUpdateRollbackCommand(input)),
|
|
618
|
+
createChangeSet: (input) => client.send(new import_client_cloudformation.CreateChangeSetCommand(input)),
|
|
619
|
+
createGeneratedTemplate: (input) => client.send(new import_client_cloudformation.CreateGeneratedTemplateCommand(input)),
|
|
620
|
+
createStack: (input) => client.send(new import_client_cloudformation.CreateStackCommand(input)),
|
|
621
|
+
deleteChangeSet: (input) => client.send(new import_client_cloudformation.DeleteChangeSetCommand(input)),
|
|
622
|
+
deleteGeneratedTemplate: (input) => client.send(new import_client_cloudformation.DeleteGeneratedTemplateCommand(input)),
|
|
623
|
+
deleteStack: (input) => client.send(new import_client_cloudformation.DeleteStackCommand(input)),
|
|
624
|
+
describeChangeSet: (input) => client.send(new import_client_cloudformation.DescribeChangeSetCommand(input)),
|
|
625
|
+
describeGeneratedTemplate: (input) => client.send(new import_client_cloudformation.DescribeGeneratedTemplateCommand(input)),
|
|
626
|
+
describeResourceScan: (input) => client.send(new import_client_cloudformation.DescribeResourceScanCommand(input)),
|
|
627
|
+
describeStacks: (input) => client.send(new import_client_cloudformation.DescribeStacksCommand(input)),
|
|
628
|
+
describeStackResources: (input) => client.send(new import_client_cloudformation.DescribeStackResourcesCommand(input)),
|
|
629
|
+
executeChangeSet: (input) => client.send(new import_client_cloudformation.ExecuteChangeSetCommand(input)),
|
|
630
|
+
getGeneratedTemplate: (input) => client.send(new import_client_cloudformation.GetGeneratedTemplateCommand(input)),
|
|
631
|
+
getTemplate: (input) => client.send(new import_client_cloudformation.GetTemplateCommand(input)),
|
|
632
|
+
getTemplateSummary: (input) => client.send(new import_client_cloudformation.GetTemplateSummaryCommand(input)),
|
|
633
|
+
listExports: (input) => client.send(new import_client_cloudformation.ListExportsCommand(input)),
|
|
634
|
+
listResourceScanRelatedResources: (input) => client.send(new import_client_cloudformation.ListResourceScanRelatedResourcesCommand(input)),
|
|
635
|
+
listResourceScanResources: (input) => client.send(new import_client_cloudformation.ListResourceScanResourcesCommand(input)),
|
|
636
|
+
listResourceScans: (input) => client.send(new import_client_cloudformation.ListResourceScansCommand(input)),
|
|
637
|
+
listStacks: (input) => client.send(new import_client_cloudformation.ListStacksCommand(input)),
|
|
638
|
+
rollbackStack: (input) => client.send(new import_client_cloudformation.RollbackStackCommand(input)),
|
|
639
|
+
startResourceScan: (input) => client.send(new import_client_cloudformation.StartResourceScanCommand(input)),
|
|
640
|
+
updateStack: (input) => client.send(new import_client_cloudformation.UpdateStackCommand(input)),
|
|
641
|
+
updateTerminationProtection: (input) => client.send(new import_client_cloudformation.UpdateTerminationProtectionCommand(input)),
|
|
642
|
+
describeStackEvents: (input) => {
|
|
643
|
+
return client.send(new import_client_cloudformation.DescribeStackEventsCommand(input));
|
|
644
|
+
},
|
|
645
|
+
listStackResources: async (input) => {
|
|
646
|
+
const stackResources = Array();
|
|
647
|
+
const paginator = (0, import_client_cloudformation.paginateListStackResources)({ client }, input);
|
|
648
|
+
for await (const page of paginator) {
|
|
649
|
+
stackResources.push(...page?.StackResourceSummaries || []);
|
|
650
|
+
}
|
|
651
|
+
return stackResources;
|
|
652
|
+
},
|
|
653
|
+
paginatedListStacks: async (input) => {
|
|
654
|
+
const stackResources = Array();
|
|
655
|
+
const paginator = (0, import_client_cloudformation.paginateListStacks)({ client }, input);
|
|
656
|
+
for await (const page of paginator) {
|
|
657
|
+
stackResources.push(...page?.StackSummaries || []);
|
|
658
|
+
}
|
|
659
|
+
return stackResources;
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
cloudWatchLogs() {
|
|
664
|
+
const client = new import_client_cloudwatch_logs.CloudWatchLogsClient(this.config);
|
|
665
|
+
return {
|
|
666
|
+
describeLogGroups: (input) => client.send(new import_client_cloudwatch_logs.DescribeLogGroupsCommand(input)),
|
|
667
|
+
filterLogEvents: (input) => client.send(new import_client_cloudwatch_logs.FilterLogEventsCommand(input))
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
codeBuild() {
|
|
671
|
+
const client = new import_client_codebuild.CodeBuildClient(this.config);
|
|
672
|
+
return {
|
|
673
|
+
updateProject: (input) => client.send(new import_client_codebuild.UpdateProjectCommand(input))
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
ec2() {
|
|
677
|
+
const client = new import_client_ec2.EC2Client(this.config);
|
|
678
|
+
return {
|
|
679
|
+
describeAvailabilityZones: (input) => client.send(new import_client_ec2.DescribeAvailabilityZonesCommand(input)),
|
|
680
|
+
describeImages: (input) => client.send(new import_client_ec2.DescribeImagesCommand(input)),
|
|
681
|
+
describeInstances: (input) => client.send(new import_client_ec2.DescribeInstancesCommand(input)),
|
|
682
|
+
describeRouteTables: (input) => client.send(new import_client_ec2.DescribeRouteTablesCommand(input)),
|
|
683
|
+
describeSecurityGroups: (input) => client.send(new import_client_ec2.DescribeSecurityGroupsCommand(input)),
|
|
684
|
+
describeSubnets: (input) => client.send(new import_client_ec2.DescribeSubnetsCommand(input)),
|
|
685
|
+
describeVpcEndpointServices: (input) => client.send(new import_client_ec2.DescribeVpcEndpointServicesCommand(input)),
|
|
686
|
+
describeVpcs: (input) => client.send(new import_client_ec2.DescribeVpcsCommand(input)),
|
|
687
|
+
describeVpnGateways: (input) => client.send(new import_client_ec2.DescribeVpnGatewaysCommand(input))
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
ecr() {
|
|
691
|
+
const client = new import_client_ecr.ECRClient(this.config);
|
|
692
|
+
return {
|
|
693
|
+
batchDeleteImage: (input) => client.send(new import_client_ecr.BatchDeleteImageCommand(input)),
|
|
694
|
+
batchGetImage: (input) => client.send(new import_client_ecr.BatchGetImageCommand(input)),
|
|
695
|
+
createRepository: (input) => client.send(new import_client_ecr.CreateRepositoryCommand(input)),
|
|
696
|
+
describeImages: (input) => client.send(new import_client_ecr.DescribeImagesCommand(input)),
|
|
697
|
+
describeRepositories: (input) => client.send(new import_client_ecr.DescribeRepositoriesCommand(input)),
|
|
698
|
+
getAuthorizationToken: (input) => client.send(new import_client_ecr.GetAuthorizationTokenCommand(input)),
|
|
699
|
+
listImages: (input) => client.send(new import_client_ecr.ListImagesCommand(input)),
|
|
700
|
+
putImage: (input) => client.send(new import_client_ecr.PutImageCommand(input)),
|
|
701
|
+
putImageScanningConfiguration: (input) => client.send(new import_client_ecr.PutImageScanningConfigurationCommand(input))
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
ecs() {
|
|
705
|
+
const client = new import_client_ecs.ECSClient(this.config);
|
|
706
|
+
return {
|
|
707
|
+
listClusters: (input) => client.send(new import_client_ecs.ListClustersCommand(input)),
|
|
708
|
+
registerTaskDefinition: (input) => client.send(new import_client_ecs.RegisterTaskDefinitionCommand(input)),
|
|
709
|
+
updateService: (input) => client.send(new import_client_ecs.UpdateServiceCommand(input)),
|
|
710
|
+
// Waiters
|
|
711
|
+
waitUntilServicesStable: (input) => {
|
|
712
|
+
return (0, import_client_ecs.waitUntilServicesStable)(
|
|
713
|
+
{
|
|
714
|
+
client,
|
|
715
|
+
maxWaitTime: 600,
|
|
716
|
+
minDelay: 6,
|
|
717
|
+
maxDelay: 6
|
|
718
|
+
},
|
|
719
|
+
input
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
elbv2() {
|
|
725
|
+
const client = new import_client_elastic_load_balancing_v2.ElasticLoadBalancingV2Client(this.config);
|
|
726
|
+
return {
|
|
727
|
+
describeListeners: (input) => client.send(new import_client_elastic_load_balancing_v2.DescribeListenersCommand(input)),
|
|
728
|
+
describeLoadBalancers: (input) => client.send(new import_client_elastic_load_balancing_v2.DescribeLoadBalancersCommand(input)),
|
|
729
|
+
describeTags: (input) => client.send(new import_client_elastic_load_balancing_v2.DescribeTagsCommand(input)),
|
|
730
|
+
// Pagination Functions
|
|
731
|
+
paginateDescribeListeners: async (input) => {
|
|
732
|
+
const listeners = Array();
|
|
733
|
+
const paginator = (0, import_client_elastic_load_balancing_v2.paginateDescribeListeners)({ client }, input);
|
|
734
|
+
for await (const page of paginator) {
|
|
735
|
+
listeners.push(...page?.Listeners || []);
|
|
736
|
+
}
|
|
737
|
+
return listeners;
|
|
738
|
+
},
|
|
739
|
+
paginateDescribeLoadBalancers: async (input) => {
|
|
740
|
+
const loadBalancers = Array();
|
|
741
|
+
const paginator = (0, import_client_elastic_load_balancing_v2.paginateDescribeLoadBalancers)({ client }, input);
|
|
742
|
+
for await (const page of paginator) {
|
|
743
|
+
loadBalancers.push(...page?.LoadBalancers || []);
|
|
744
|
+
}
|
|
745
|
+
return loadBalancers;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
iam() {
|
|
750
|
+
const client = new import_client_iam.IAMClient(this.config);
|
|
751
|
+
return {
|
|
752
|
+
createPolicy: (input) => client.send(new import_client_iam.CreatePolicyCommand(input)),
|
|
753
|
+
getPolicy: (input) => client.send(new import_client_iam.GetPolicyCommand(input)),
|
|
754
|
+
getRole: (input) => client.send(new import_client_iam.GetRoleCommand(input))
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
kms() {
|
|
758
|
+
const client = new import_client_kms.KMSClient(this.config);
|
|
759
|
+
return {
|
|
760
|
+
describeKey: (input) => client.send(new import_client_kms.DescribeKeyCommand(input)),
|
|
761
|
+
listAliases: (input) => client.send(new import_client_kms.ListAliasesCommand(input))
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
lambda() {
|
|
765
|
+
const client = new import_client_lambda.LambdaClient(this.config);
|
|
766
|
+
return {
|
|
767
|
+
invokeCommand: (input) => client.send(new import_client_lambda.InvokeCommand(input)),
|
|
768
|
+
publishVersion: (input) => client.send(new import_client_lambda.PublishVersionCommand(input)),
|
|
769
|
+
updateAlias: (input) => client.send(new import_client_lambda.UpdateAliasCommand(input)),
|
|
770
|
+
updateFunctionCode: (input) => client.send(new import_client_lambda.UpdateFunctionCodeCommand(input)),
|
|
771
|
+
updateFunctionConfiguration: (input) => client.send(new import_client_lambda.UpdateFunctionConfigurationCommand(input)),
|
|
772
|
+
// Waiters
|
|
773
|
+
waitUntilFunctionUpdated: (delaySeconds, input) => {
|
|
774
|
+
return (0, import_client_lambda.waitUntilFunctionUpdatedV2)(
|
|
775
|
+
{
|
|
776
|
+
client,
|
|
777
|
+
maxDelay: delaySeconds,
|
|
778
|
+
minDelay: delaySeconds,
|
|
779
|
+
maxWaitTime: delaySeconds * 60
|
|
780
|
+
},
|
|
781
|
+
input
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
route53() {
|
|
787
|
+
const client = new import_client_route_53.Route53Client(this.config);
|
|
788
|
+
return {
|
|
789
|
+
getHostedZone: (input) => client.send(new import_client_route_53.GetHostedZoneCommand(input)),
|
|
790
|
+
listHostedZones: (input) => client.send(new import_client_route_53.ListHostedZonesCommand(input)),
|
|
791
|
+
listHostedZonesByName: (input) => client.send(new import_client_route_53.ListHostedZonesByNameCommand(input))
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
s3() {
|
|
795
|
+
const client = new import_client_s3.S3Client(this.config);
|
|
796
|
+
return {
|
|
797
|
+
deleteObjects: (input) => client.send(new import_client_s3.DeleteObjectsCommand({
|
|
798
|
+
...input,
|
|
799
|
+
ChecksumAlgorithm: "SHA256"
|
|
800
|
+
})),
|
|
801
|
+
deleteObjectTagging: (input) => client.send(new import_client_s3.DeleteObjectTaggingCommand(input)),
|
|
802
|
+
getBucketEncryption: (input) => client.send(new import_client_s3.GetBucketEncryptionCommand(input)),
|
|
803
|
+
getBucketLocation: (input) => client.send(new import_client_s3.GetBucketLocationCommand(input)),
|
|
804
|
+
getObject: (input) => client.send(new import_client_s3.GetObjectCommand(input)),
|
|
805
|
+
getObjectTagging: (input) => client.send(new import_client_s3.GetObjectTaggingCommand(input)),
|
|
806
|
+
listObjectsV2: (input) => client.send(new import_client_s3.ListObjectsV2Command(input)),
|
|
807
|
+
putObjectTagging: (input) => client.send(new import_client_s3.PutObjectTaggingCommand({
|
|
808
|
+
...input,
|
|
809
|
+
ChecksumAlgorithm: "SHA256"
|
|
810
|
+
})),
|
|
811
|
+
upload: (input) => {
|
|
812
|
+
try {
|
|
813
|
+
const upload = new import_lib_storage.Upload({
|
|
814
|
+
client,
|
|
815
|
+
params: { ...input, ChecksumAlgorithm: "SHA256" }
|
|
816
|
+
});
|
|
817
|
+
return upload.done();
|
|
818
|
+
} catch (e) {
|
|
819
|
+
throw new AuthenticationError(`Upload failed: ${formatErrorMessage(e)}`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
secretsManager() {
|
|
825
|
+
const client = new import_client_secrets_manager.SecretsManagerClient(this.config);
|
|
826
|
+
return {
|
|
827
|
+
getSecretValue: (input) => client.send(new import_client_secrets_manager.GetSecretValueCommand(input))
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
ssm() {
|
|
831
|
+
const client = new import_client_ssm.SSMClient(this.config);
|
|
832
|
+
return {
|
|
833
|
+
getParameter: (input) => client.send(new import_client_ssm.GetParameterCommand(input))
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
stepFunctions() {
|
|
837
|
+
const client = new import_client_sfn.SFNClient(this.config);
|
|
838
|
+
return {
|
|
839
|
+
updateStateMachine: (input) => client.send(new import_client_sfn.UpdateStateMachineCommand(input))
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* The AWS SDK v3 requires a client config and a command in order to get an endpoint for
|
|
844
|
+
* any given service.
|
|
845
|
+
*/
|
|
846
|
+
async getUrlSuffix(region) {
|
|
847
|
+
const cfn = new import_client_cloudformation.CloudFormationClient({ region });
|
|
848
|
+
const endpoint = await (0, import_middleware_endpoint.getEndpointFromInstructions)({}, import_client_cloudformation.DescribeStackResourcesCommand, { ...cfn.config });
|
|
849
|
+
return endpoint.url.hostname.split(`${region}.`).pop();
|
|
850
|
+
}
|
|
851
|
+
async currentAccount() {
|
|
852
|
+
return cachedAsync(this, CURRENT_ACCOUNT_KEY, async () => {
|
|
853
|
+
const creds = await this.credProvider();
|
|
854
|
+
return this.accountCache.fetch(creds.accessKeyId, async () => {
|
|
855
|
+
await this.debug("Looking up default account ID from STS");
|
|
856
|
+
const client = new import_client_sts.STSClient({
|
|
857
|
+
...this.config,
|
|
858
|
+
retryStrategy: this.stsRetryStrategy
|
|
859
|
+
});
|
|
860
|
+
const command = new import_client_sts.GetCallerIdentityCommand({});
|
|
861
|
+
const result2 = await client.send(command);
|
|
862
|
+
const accountId = result2.Account;
|
|
863
|
+
const partition = result2.Arn.split(":")[1];
|
|
864
|
+
if (!accountId) {
|
|
865
|
+
throw new AuthenticationError("STS didn't return an account ID");
|
|
866
|
+
}
|
|
867
|
+
await this.debug(`Default account ID: ${accountId}`);
|
|
868
|
+
this._credentialsValidated = true;
|
|
869
|
+
return { accountId, partition };
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Make sure the the current credentials are not expired
|
|
875
|
+
*/
|
|
876
|
+
async validateCredentials() {
|
|
877
|
+
if (this._credentialsValidated) {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
const client = new import_client_sts.STSClient({ ...this.config, retryStrategy: this.stsRetryStrategy });
|
|
881
|
+
await client.send(new import_client_sts.GetCallerIdentityCommand({}));
|
|
882
|
+
this._credentialsValidated = true;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
SDK = __decorateClass([
|
|
886
|
+
traceMemberMethods
|
|
887
|
+
], SDK);
|
|
888
|
+
var CURRENT_ACCOUNT_KEY = Symbol("current_account_key");
|
|
889
|
+
|
|
890
|
+
// lib/api/aws-auth/sdk-provider.ts
|
|
891
|
+
var os2 = __toESM(require("os"));
|
|
892
|
+
var import_cx_api = require("@aws-cdk/cx-api");
|
|
893
|
+
var import_credential_providers2 = require("@aws-sdk/credential-providers");
|
|
894
|
+
|
|
895
|
+
// lib/api/aws-auth/awscli-compatible.ts
|
|
896
|
+
var import_node_util = require("node:util");
|
|
897
|
+
var import_credential_providers = require("@aws-sdk/credential-providers");
|
|
898
|
+
var import_ec2_metadata_service = require("@aws-sdk/ec2-metadata-service");
|
|
899
|
+
var import_shared_ini_file_loader = require("@smithy/shared-ini-file-loader");
|
|
900
|
+
var promptly = __toESM(require("promptly"));
|
|
901
|
+
|
|
902
|
+
// lib/api/aws-auth/provider-caching.ts
|
|
903
|
+
var import_property_provider = require("@smithy/property-provider");
|
|
904
|
+
function makeCachingProvider(provider) {
|
|
905
|
+
return (0, import_property_provider.memoize)(
|
|
906
|
+
provider,
|
|
907
|
+
credentialsAboutToExpire,
|
|
908
|
+
(token) => !!token.expiration
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
function credentialsAboutToExpire(token) {
|
|
912
|
+
const expiryMarginSecs = 5;
|
|
913
|
+
return !!token.expiration && token.expiration.getTime() - Date.now() < expiryMarginSecs * 1e3;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// lib/api/aws-auth/awscli-compatible.ts
|
|
917
|
+
var AwsCliCompatible = class {
|
|
918
|
+
ioHelper;
|
|
919
|
+
requestHandler;
|
|
920
|
+
logger;
|
|
921
|
+
constructor(ioHelper, requestHandler, logger) {
|
|
922
|
+
this.ioHelper = ioHelper;
|
|
923
|
+
this.requestHandler = requestHandler;
|
|
924
|
+
this.logger = logger;
|
|
925
|
+
}
|
|
926
|
+
async baseConfig(profile) {
|
|
927
|
+
const credentialProvider = await this.credentialChainBuilder({
|
|
928
|
+
profile,
|
|
929
|
+
logger: this.logger
|
|
930
|
+
});
|
|
931
|
+
const defaultRegion = await this.region(profile);
|
|
932
|
+
return { credentialProvider, defaultRegion };
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Build an AWS CLI-compatible credential chain provider
|
|
936
|
+
*
|
|
937
|
+
* The credential chain returned by this function is always caching.
|
|
938
|
+
*/
|
|
939
|
+
async credentialChainBuilder(options = {}) {
|
|
940
|
+
const clientConfig = {
|
|
941
|
+
requestHandler: this.requestHandler,
|
|
942
|
+
customUserAgent: "aws-cdk",
|
|
943
|
+
logger: options.logger
|
|
944
|
+
};
|
|
945
|
+
const parentClientConfig = {
|
|
946
|
+
region: await this.region(options.profile)
|
|
947
|
+
};
|
|
948
|
+
if (options.profile) {
|
|
949
|
+
return makeCachingProvider((0, import_credential_providers.fromIni)({
|
|
950
|
+
profile: options.profile,
|
|
951
|
+
ignoreCache: true,
|
|
952
|
+
mfaCodeProvider: this.tokenCodeFn.bind(this),
|
|
953
|
+
clientConfig,
|
|
954
|
+
parentClientConfig,
|
|
955
|
+
logger: options.logger
|
|
956
|
+
}));
|
|
957
|
+
}
|
|
958
|
+
const envProfile = process.env.AWS_PROFILE || process.env.AWS_DEFAULT_PROFILE;
|
|
959
|
+
const nodeProviderChain = (0, import_credential_providers.fromNodeProviderChain)({
|
|
960
|
+
profile: envProfile,
|
|
961
|
+
clientConfig,
|
|
962
|
+
parentClientConfig,
|
|
963
|
+
logger: options.logger,
|
|
964
|
+
mfaCodeProvider: this.tokenCodeFn.bind(this),
|
|
965
|
+
ignoreCache: true
|
|
966
|
+
});
|
|
967
|
+
return shouldPrioritizeEnv() ? (0, import_credential_providers.createCredentialChain)((0, import_credential_providers.fromEnv)(), nodeProviderChain).expireAfter(60 * 6e4) : nodeProviderChain;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Attempts to get the region from a number of sources and falls back to us-east-1 if no region can be found,
|
|
971
|
+
* as is done in the AWS CLI.
|
|
972
|
+
*
|
|
973
|
+
* The order of priority is the following:
|
|
974
|
+
*
|
|
975
|
+
* 1. Environment variables specifying region, with both an AWS prefix and AMAZON prefix
|
|
976
|
+
* to maintain backwards compatibility, and without `DEFAULT` in the name because
|
|
977
|
+
* Lambda and CodeBuild set the $AWS_REGION variable.
|
|
978
|
+
* 2. Regions listed in the Shared Ini Files - First checking for the profile provided
|
|
979
|
+
* and then checking for the default profile.
|
|
980
|
+
* 3. IMDS instance identity region from the Metadata Service.
|
|
981
|
+
* 4. us-east-1
|
|
982
|
+
*/
|
|
983
|
+
async region(maybeProfile) {
|
|
984
|
+
const defaultRegion = "us-east-1";
|
|
985
|
+
const profile = maybeProfile || process.env.AWS_PROFILE || process.env.AWS_DEFAULT_PROFILE || "default";
|
|
986
|
+
const region = process.env.AWS_REGION || process.env.AMAZON_REGION || process.env.AWS_DEFAULT_REGION || process.env.AMAZON_DEFAULT_REGION || await this.getRegionFromIni(profile) || await this.regionFromMetadataService();
|
|
987
|
+
if (!region) {
|
|
988
|
+
const usedProfile = !profile ? "" : ` (profile: "${profile}")`;
|
|
989
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(
|
|
990
|
+
`Unable to determine AWS region from environment or AWS configuration${usedProfile}, defaulting to '${defaultRegion}'`
|
|
991
|
+
));
|
|
992
|
+
return defaultRegion;
|
|
993
|
+
}
|
|
994
|
+
return region;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* The MetadataService class will attempt to fetch the instance identity document from
|
|
998
|
+
* IMDSv2 first, and then will attempt v1 as a fallback.
|
|
999
|
+
*
|
|
1000
|
+
* If this fails, we will use us-east-1 as the region so no error should be thrown.
|
|
1001
|
+
* @returns The region for the instance identity
|
|
1002
|
+
*/
|
|
1003
|
+
async regionFromMetadataService() {
|
|
1004
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg("Looking up AWS region in the EC2 Instance Metadata Service (IMDS)."));
|
|
1005
|
+
try {
|
|
1006
|
+
const metadataService = new import_ec2_metadata_service.MetadataService({
|
|
1007
|
+
httpOptions: {
|
|
1008
|
+
timeout: 1e3
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
await metadataService.fetchMetadataToken();
|
|
1012
|
+
const document = await metadataService.request("/latest/dynamic/instance-identity/document", {});
|
|
1013
|
+
return JSON.parse(document).region;
|
|
1014
|
+
} catch (e) {
|
|
1015
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(`Unable to retrieve AWS region from IMDS: ${e}`));
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Looks up the region of the provided profile. If no region is present,
|
|
1020
|
+
* it will attempt to lookup the default region.
|
|
1021
|
+
* @param profile The profile to use to lookup the region
|
|
1022
|
+
* @returns The region for the profile or default profile, if present. Otherwise returns undefined.
|
|
1023
|
+
*/
|
|
1024
|
+
async getRegionFromIni(profile) {
|
|
1025
|
+
const sharedFiles = await (0, import_shared_ini_file_loader.loadSharedConfigFiles)({ ignoreCache: true });
|
|
1026
|
+
return this.getRegionFromIniFile(profile, sharedFiles.credentialsFile) ?? this.getRegionFromIniFile(profile, sharedFiles.configFile) ?? this.getRegionFromIniFile("default", sharedFiles.credentialsFile) ?? this.getRegionFromIniFile("default", sharedFiles.configFile);
|
|
1027
|
+
}
|
|
1028
|
+
getRegionFromIniFile(profile, data) {
|
|
1029
|
+
return data?.[profile]?.region;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Ask user for MFA token for given serial
|
|
1033
|
+
*
|
|
1034
|
+
* Result is send to callback function for SDK to authorize the request
|
|
1035
|
+
*/
|
|
1036
|
+
async tokenCodeFn(serialArn) {
|
|
1037
|
+
const debugFn = (msg, ...args) => this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg((0, import_node_util.format)(msg, ...args)));
|
|
1038
|
+
await debugFn("Require MFA token for serial ARN", serialArn);
|
|
1039
|
+
try {
|
|
1040
|
+
const token = await promptly.prompt(`MFA token for ${serialArn}: `, {
|
|
1041
|
+
trim: true,
|
|
1042
|
+
default: ""
|
|
1043
|
+
});
|
|
1044
|
+
await debugFn("Successfully got MFA token from user");
|
|
1045
|
+
return token;
|
|
1046
|
+
} catch (err) {
|
|
1047
|
+
await debugFn("Failed to get MFA token", err);
|
|
1048
|
+
const e = new AuthenticationError(`Error fetching MFA token: ${err.message ?? err}`);
|
|
1049
|
+
e.name = "SharedIniFileCredentialsProviderFailure";
|
|
1050
|
+
throw e;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
function shouldPrioritizeEnv() {
|
|
1055
|
+
const id = process.env.AWS_ACCESS_KEY_ID || process.env.AMAZON_ACCESS_KEY_ID;
|
|
1056
|
+
const key = process.env.AWS_SECRET_ACCESS_KEY || process.env.AMAZON_SECRET_ACCESS_KEY;
|
|
1057
|
+
if (!!id && !!key) {
|
|
1058
|
+
process.env.AWS_ACCESS_KEY_ID = id;
|
|
1059
|
+
process.env.AWS_SECRET_ACCESS_KEY = key;
|
|
1060
|
+
const sessionToken = process.env.AWS_SESSION_TOKEN ?? process.env.AMAZON_SESSION_TOKEN;
|
|
1061
|
+
if (sessionToken) {
|
|
1062
|
+
process.env.AWS_SESSION_TOKEN = sessionToken;
|
|
1063
|
+
}
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// lib/api/aws-auth/credential-plugins.ts
|
|
1070
|
+
var import_util8 = require("util");
|
|
1071
|
+
var CredentialPlugins = class {
|
|
1072
|
+
constructor(host, ioHelper) {
|
|
1073
|
+
this.host = host;
|
|
1074
|
+
this.ioHelper = ioHelper;
|
|
1075
|
+
}
|
|
1076
|
+
cache = {};
|
|
1077
|
+
async fetchCredentialsFor(awsAccountId, mode) {
|
|
1078
|
+
const key = `${awsAccountId}-${mode}`;
|
|
1079
|
+
if (!(key in this.cache)) {
|
|
1080
|
+
this.cache[key] = await this.lookupCredentials(awsAccountId, mode);
|
|
1081
|
+
}
|
|
1082
|
+
return this.cache[key];
|
|
1083
|
+
}
|
|
1084
|
+
get availablePluginNames() {
|
|
1085
|
+
return this.host.credentialProviderSources.map((s) => s.name);
|
|
1086
|
+
}
|
|
1087
|
+
async lookupCredentials(awsAccountId, mode) {
|
|
1088
|
+
const triedSources = [];
|
|
1089
|
+
for (const source of this.host.credentialProviderSources) {
|
|
1090
|
+
let available;
|
|
1091
|
+
try {
|
|
1092
|
+
available = await source.isAvailable();
|
|
1093
|
+
} catch (e) {
|
|
1094
|
+
await this.ioHelper.notify(IO.CDK_TOOLKIT_W0100.msg(`Uncaught exception in ${source.name}: ${formatErrorMessage(e)}`));
|
|
1095
|
+
available = false;
|
|
1096
|
+
}
|
|
1097
|
+
if (!available) {
|
|
1098
|
+
await this.ioHelper.notify(IO.DEFAULT_TOOLKIT_DEBUG.msg(`Credentials source ${source.name} is not available, ignoring it.`));
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
triedSources.push(source);
|
|
1102
|
+
let canProvide;
|
|
1103
|
+
try {
|
|
1104
|
+
canProvide = await source.canProvideCredentials(awsAccountId);
|
|
1105
|
+
} catch (e) {
|
|
1106
|
+
await this.ioHelper.notify(IO.CDK_TOOLKIT_W0100.msg(`Uncaught exception in ${source.name}: ${formatErrorMessage(e)}`));
|
|
1107
|
+
canProvide = false;
|
|
1108
|
+
}
|
|
1109
|
+
if (!canProvide) {
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
await this.ioHelper.notify(IO.DEFAULT_TOOLKIT_DEBUG.msg(`Using ${source.name} credentials for account ${awsAccountId}`));
|
|
1113
|
+
return {
|
|
1114
|
+
credentials: await v3ProviderFromPlugin(() => source.getProvider(awsAccountId, mode, {
|
|
1115
|
+
supportsV3Providers: true
|
|
1116
|
+
})),
|
|
1117
|
+
pluginName: source.name
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
return void 0;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
async function v3ProviderFromPlugin(producer) {
|
|
1124
|
+
const initial = await producer();
|
|
1125
|
+
if (isV3Provider(initial)) {
|
|
1126
|
+
return makeCachingProvider(initial);
|
|
1127
|
+
} else if (isV3Credentials(initial) && initial.expiration === void 0) {
|
|
1128
|
+
return () => Promise.resolve(initial);
|
|
1129
|
+
} else if (isV3Credentials(initial) && initial.expiration !== void 0) {
|
|
1130
|
+
return refreshFromPluginProvider(initial, producer);
|
|
1131
|
+
} else if (isV2Credentials(initial)) {
|
|
1132
|
+
return v3ProviderFromV2Credentials(initial);
|
|
1133
|
+
} else {
|
|
1134
|
+
throw new AuthenticationError(`Plugin returned a value that doesn't resemble AWS credentials: ${(0, import_util8.inspect)(initial)}`);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function v3ProviderFromV2Credentials(x) {
|
|
1138
|
+
return async () => {
|
|
1139
|
+
await x.getPromise();
|
|
1140
|
+
return {
|
|
1141
|
+
accessKeyId: x.accessKeyId,
|
|
1142
|
+
secretAccessKey: x.secretAccessKey,
|
|
1143
|
+
sessionToken: x.sessionToken,
|
|
1144
|
+
expiration: x.expireTime ?? void 0
|
|
1145
|
+
};
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
function refreshFromPluginProvider(current, producer) {
|
|
1149
|
+
return async () => {
|
|
1150
|
+
if (credentialsAboutToExpire(current)) {
|
|
1151
|
+
const newCreds = await producer();
|
|
1152
|
+
if (!isV3Credentials(newCreds)) {
|
|
1153
|
+
throw new AuthenticationError(`Plugin initially returned static V3 credentials but now returned something else: ${(0, import_util8.inspect)(newCreds)}`);
|
|
1154
|
+
}
|
|
1155
|
+
current = newCreds;
|
|
1156
|
+
}
|
|
1157
|
+
return current;
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
function isV3Provider(x) {
|
|
1161
|
+
return typeof x === "function";
|
|
1162
|
+
}
|
|
1163
|
+
function isV2Credentials(x) {
|
|
1164
|
+
return !!(x && typeof x === "object" && x.getPromise);
|
|
1165
|
+
}
|
|
1166
|
+
function isV3Credentials(x) {
|
|
1167
|
+
return !!(x && typeof x === "object" && x.accessKeyId && !isV2Credentials(x));
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// lib/api/aws-auth/sdk-provider.ts
|
|
1171
|
+
var CACHED_ACCOUNT = Symbol("cached_account");
|
|
1172
|
+
var SdkProvider = class {
|
|
1173
|
+
/**
|
|
1174
|
+
* Create a new SdkProvider which gets its defaults in a way that behaves like the AWS CLI does
|
|
1175
|
+
*
|
|
1176
|
+
* The AWS SDK for JS behaves slightly differently from the AWS CLI in a number of ways; see the
|
|
1177
|
+
* class `AwsCliCompatible` for the details.
|
|
1178
|
+
*/
|
|
1179
|
+
static async withAwsCliCompatibleDefaults(options) {
|
|
1180
|
+
callTrace(SdkProvider.withAwsCliCompatibleDefaults.name, SdkProvider.constructor.name, options.logger);
|
|
1181
|
+
const config = await new AwsCliCompatible(options.ioHelper, options.requestHandler ?? {}, options.logger).baseConfig(options.profile);
|
|
1182
|
+
return new SdkProvider(config.credentialProvider, config.defaultRegion, options);
|
|
1183
|
+
}
|
|
1184
|
+
defaultRegion;
|
|
1185
|
+
defaultCredentialProvider;
|
|
1186
|
+
plugins;
|
|
1187
|
+
requestHandler;
|
|
1188
|
+
ioHelper;
|
|
1189
|
+
logger;
|
|
1190
|
+
constructor(defaultCredentialProvider, defaultRegion, services) {
|
|
1191
|
+
this.defaultCredentialProvider = defaultCredentialProvider;
|
|
1192
|
+
this.defaultRegion = defaultRegion ?? "us-east-1";
|
|
1193
|
+
this.requestHandler = services.requestHandler ?? {};
|
|
1194
|
+
this.ioHelper = services.ioHelper;
|
|
1195
|
+
this.logger = services.logger;
|
|
1196
|
+
this.plugins = new CredentialPlugins(services.pluginHost ?? new PluginHost(), this.ioHelper);
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Return an SDK which can do operations in the given environment
|
|
1200
|
+
*
|
|
1201
|
+
* The `environment` parameter is resolved first (see `resolveEnvironment()`).
|
|
1202
|
+
*/
|
|
1203
|
+
async forEnvironment(environment, mode, options, quiet = false) {
|
|
1204
|
+
const env = await this.resolveEnvironment(environment);
|
|
1205
|
+
const baseCreds = await this.obtainBaseCredentials(env.account, mode);
|
|
1206
|
+
if (baseCreds.source === "none") {
|
|
1207
|
+
throw new AuthenticationError(fmtObtainCredentialsError(env.account, baseCreds));
|
|
1208
|
+
}
|
|
1209
|
+
if (options?.assumeRoleArn === void 0) {
|
|
1210
|
+
if (baseCreds.source === "incorrectDefault") {
|
|
1211
|
+
throw new AuthenticationError(fmtObtainCredentialsError(env.account, baseCreds));
|
|
1212
|
+
}
|
|
1213
|
+
const sdk = this._makeSdk(baseCreds.credentials, env.region);
|
|
1214
|
+
await sdk.validateCredentials();
|
|
1215
|
+
return { sdk, didAssumeRole: false };
|
|
1216
|
+
}
|
|
1217
|
+
try {
|
|
1218
|
+
const sdk = await this.withAssumedRole(
|
|
1219
|
+
baseCreds,
|
|
1220
|
+
options.assumeRoleArn,
|
|
1221
|
+
options.assumeRoleExternalId,
|
|
1222
|
+
options.assumeRoleAdditionalOptions,
|
|
1223
|
+
env.region
|
|
1224
|
+
);
|
|
1225
|
+
return { sdk, didAssumeRole: true };
|
|
1226
|
+
} catch (err) {
|
|
1227
|
+
if (err.name === "ExpiredToken") {
|
|
1228
|
+
throw err;
|
|
1229
|
+
}
|
|
1230
|
+
if (baseCreds.source === "correctDefault" || baseCreds.source === "plugin") {
|
|
1231
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(err.message));
|
|
1232
|
+
const maker = quiet ? IO.DEFAULT_SDK_DEBUG : IO.DEFAULT_SDK_WARN;
|
|
1233
|
+
await this.ioHelper.notify(maker.msg(
|
|
1234
|
+
`${fmtObtainedCredentials(baseCreds)} could not be used to assume '${options.assumeRoleArn}', but are for the right account. Proceeding anyway.`
|
|
1235
|
+
));
|
|
1236
|
+
return {
|
|
1237
|
+
sdk: this._makeSdk(baseCreds.credentials, env.region),
|
|
1238
|
+
didAssumeRole: false
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
throw err;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Return the partition that base credentials are for
|
|
1246
|
+
*
|
|
1247
|
+
* Returns `undefined` if there are no base credentials.
|
|
1248
|
+
*/
|
|
1249
|
+
async baseCredentialsPartition(environment, mode) {
|
|
1250
|
+
const env = await this.resolveEnvironment(environment);
|
|
1251
|
+
const baseCreds = await this.obtainBaseCredentials(env.account, mode);
|
|
1252
|
+
if (baseCreds.source === "none") {
|
|
1253
|
+
return void 0;
|
|
1254
|
+
}
|
|
1255
|
+
return (await this._makeSdk(baseCreds.credentials, env.region).currentAccount()).partition;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Resolve the environment for a stack
|
|
1259
|
+
*
|
|
1260
|
+
* Replaces the magic values `UNKNOWN_REGION` and `UNKNOWN_ACCOUNT`
|
|
1261
|
+
* with the defaults for the current SDK configuration (`~/.aws/config` or
|
|
1262
|
+
* otherwise).
|
|
1263
|
+
*
|
|
1264
|
+
* It is an error if `UNKNOWN_ACCOUNT` is used but the user hasn't configured
|
|
1265
|
+
* any SDK credentials.
|
|
1266
|
+
*/
|
|
1267
|
+
async resolveEnvironment(env) {
|
|
1268
|
+
const region = env.region !== import_cx_api.UNKNOWN_REGION ? env.region : this.defaultRegion;
|
|
1269
|
+
const account = env.account !== import_cx_api.UNKNOWN_ACCOUNT ? env.account : (await this.defaultAccount())?.accountId;
|
|
1270
|
+
if (!account) {
|
|
1271
|
+
throw new AuthenticationError(
|
|
1272
|
+
"Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment"
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
region,
|
|
1277
|
+
account,
|
|
1278
|
+
name: import_cx_api.EnvironmentUtils.format(account, region)
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* The account we'd auth into if we used default credentials.
|
|
1283
|
+
*
|
|
1284
|
+
* Default credentials are the set of ambiently configured credentials using
|
|
1285
|
+
* one of the environment variables, or ~/.aws/credentials, or the *one*
|
|
1286
|
+
* profile that was passed into the CLI.
|
|
1287
|
+
*
|
|
1288
|
+
* Might return undefined if there are no default/ambient credentials
|
|
1289
|
+
* available (in which case the user should better hope they have
|
|
1290
|
+
* credential plugins configured).
|
|
1291
|
+
*
|
|
1292
|
+
* Uses a cache to avoid STS calls if we don't need 'em.
|
|
1293
|
+
*/
|
|
1294
|
+
async defaultAccount() {
|
|
1295
|
+
return cached(this, CACHED_ACCOUNT, async () => {
|
|
1296
|
+
try {
|
|
1297
|
+
return await this._makeSdk(this.defaultCredentialProvider, this.defaultRegion).currentAccount();
|
|
1298
|
+
} catch (e) {
|
|
1299
|
+
if (e.name === "ExpiredToken") {
|
|
1300
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_WARN.msg(
|
|
1301
|
+
"There are expired AWS credentials in your environment. The CDK app will synth without current account information."
|
|
1302
|
+
));
|
|
1303
|
+
return void 0;
|
|
1304
|
+
}
|
|
1305
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(`Unable to determine the default AWS account (${e.name}): ${formatErrorMessage(e)}`));
|
|
1306
|
+
return void 0;
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Get credentials for the given account ID in the given mode
|
|
1312
|
+
*
|
|
1313
|
+
* 1. Use the default credentials if the destination account matches the
|
|
1314
|
+
* current credentials' account.
|
|
1315
|
+
* 2. Otherwise try all credential plugins.
|
|
1316
|
+
* 3. Fail if neither of these yield any credentials.
|
|
1317
|
+
* 4. Return a failure if any of them returned credentials
|
|
1318
|
+
*/
|
|
1319
|
+
async obtainBaseCredentials(accountId, mode) {
|
|
1320
|
+
const defaultAccountId = (await this.defaultAccount())?.accountId;
|
|
1321
|
+
if (defaultAccountId === accountId) {
|
|
1322
|
+
return {
|
|
1323
|
+
source: "correctDefault",
|
|
1324
|
+
credentials: await this.defaultCredentialProvider
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const pluginCreds = await this.plugins.fetchCredentialsFor(accountId, mode);
|
|
1328
|
+
if (pluginCreds) {
|
|
1329
|
+
return { source: "plugin", ...pluginCreds };
|
|
1330
|
+
}
|
|
1331
|
+
if (defaultAccountId !== void 0) {
|
|
1332
|
+
return {
|
|
1333
|
+
source: "incorrectDefault",
|
|
1334
|
+
accountId: defaultAccountId,
|
|
1335
|
+
credentials: await this.defaultCredentialProvider,
|
|
1336
|
+
unusedPlugins: this.plugins.availablePluginNames
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
return {
|
|
1340
|
+
source: "none",
|
|
1341
|
+
unusedPlugins: this.plugins.availablePluginNames
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Return an SDK which uses assumed role credentials
|
|
1346
|
+
*
|
|
1347
|
+
* The base credentials used to retrieve the assumed role credentials will be the
|
|
1348
|
+
* same credentials returned by obtainCredentials if an environment and mode is passed,
|
|
1349
|
+
* otherwise it will be the current credentials.
|
|
1350
|
+
*/
|
|
1351
|
+
async withAssumedRole(mainCredentials, roleArn, externalId, additionalOptions, region) {
|
|
1352
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(`Assuming role '${roleArn}'.`));
|
|
1353
|
+
region = region ?? this.defaultRegion;
|
|
1354
|
+
const sourceDescription = fmtObtainedCredentials(mainCredentials);
|
|
1355
|
+
try {
|
|
1356
|
+
const credentials = await makeCachingProvider((0, import_credential_providers2.fromTemporaryCredentials)({
|
|
1357
|
+
masterCredentials: mainCredentials.credentials,
|
|
1358
|
+
params: {
|
|
1359
|
+
RoleArn: roleArn,
|
|
1360
|
+
ExternalId: externalId,
|
|
1361
|
+
RoleSessionName: `aws-cdk-${safeUsername()}`,
|
|
1362
|
+
...additionalOptions,
|
|
1363
|
+
TransitiveTagKeys: additionalOptions?.Tags ? additionalOptions.Tags.map((t) => t.Key) : void 0
|
|
1364
|
+
},
|
|
1365
|
+
clientConfig: {
|
|
1366
|
+
region,
|
|
1367
|
+
requestHandler: this.requestHandler,
|
|
1368
|
+
customUserAgent: "aws-cdk",
|
|
1369
|
+
logger: this.logger
|
|
1370
|
+
},
|
|
1371
|
+
logger: this.logger
|
|
1372
|
+
}));
|
|
1373
|
+
await credentials();
|
|
1374
|
+
return this._makeSdk(credentials, region);
|
|
1375
|
+
} catch (err) {
|
|
1376
|
+
if (err.name === "ExpiredToken") {
|
|
1377
|
+
throw err;
|
|
1378
|
+
}
|
|
1379
|
+
await this.ioHelper.notify(IO.DEFAULT_SDK_DEBUG.msg(`Assuming role failed: ${err.message}`));
|
|
1380
|
+
throw new AuthenticationError(
|
|
1381
|
+
[
|
|
1382
|
+
"Could not assume role in target account",
|
|
1383
|
+
...sourceDescription ? [`using ${sourceDescription}`] : [],
|
|
1384
|
+
err.message,
|
|
1385
|
+
". Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI."
|
|
1386
|
+
].join(" ")
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Factory function that creates a new SDK instance
|
|
1392
|
+
*
|
|
1393
|
+
* This is a function here, instead of all the places where this is used creating a `new SDK`
|
|
1394
|
+
* instance, so that it is trivial to mock from tests.
|
|
1395
|
+
*
|
|
1396
|
+
* Use like this:
|
|
1397
|
+
*
|
|
1398
|
+
* ```ts
|
|
1399
|
+
* const mockSdk = jest.spyOn(SdkProvider.prototype, '_makeSdk').mockReturnValue(new MockSdk());
|
|
1400
|
+
* // ...
|
|
1401
|
+
* mockSdk.mockRestore();
|
|
1402
|
+
* ```
|
|
1403
|
+
*
|
|
1404
|
+
* @internal
|
|
1405
|
+
*/
|
|
1406
|
+
_makeSdk(credProvider, region) {
|
|
1407
|
+
return new SDK(credProvider, region, this.requestHandler, this.ioHelper, this.logger);
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
SdkProvider = __decorateClass([
|
|
1411
|
+
traceMemberMethods
|
|
1412
|
+
], SdkProvider);
|
|
1413
|
+
function safeUsername() {
|
|
1414
|
+
try {
|
|
1415
|
+
return os2.userInfo().username.replace(/[^\w+=,.@-]/g, "@");
|
|
1416
|
+
} catch {
|
|
1417
|
+
return "noname";
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
function fmtObtainCredentialsError(targetAccountId, obtainResult) {
|
|
1421
|
+
const msg = [`Need to perform AWS calls for account ${targetAccountId}`];
|
|
1422
|
+
switch (obtainResult.source) {
|
|
1423
|
+
case "incorrectDefault":
|
|
1424
|
+
msg.push(`but the current credentials are for ${obtainResult.accountId}`);
|
|
1425
|
+
break;
|
|
1426
|
+
case "none":
|
|
1427
|
+
msg.push("but no credentials have been configured");
|
|
1428
|
+
}
|
|
1429
|
+
if (obtainResult.unusedPlugins.length > 0) {
|
|
1430
|
+
msg.push(`and none of these plugins found any: ${obtainResult.unusedPlugins.join(", ")}`);
|
|
1431
|
+
}
|
|
1432
|
+
return msg.join(", ");
|
|
1433
|
+
}
|
|
1434
|
+
function fmtObtainedCredentials(obtainResult) {
|
|
1435
|
+
switch (obtainResult.source) {
|
|
1436
|
+
case "correctDefault":
|
|
1437
|
+
return "current credentials";
|
|
1438
|
+
case "plugin":
|
|
1439
|
+
return `credentials returned by plugin '${obtainResult.pluginName}'`;
|
|
1440
|
+
case "incorrectDefault":
|
|
1441
|
+
const msg = [];
|
|
1442
|
+
msg.push(`current credentials (which are for account ${obtainResult.accountId}`);
|
|
1443
|
+
if (obtainResult.unusedPlugins.length > 0) {
|
|
1444
|
+
msg.push(`, and none of the following plugins provided credentials: ${obtainResult.unusedPlugins.join(", ")}`);
|
|
1445
|
+
}
|
|
1446
|
+
msg.push(")");
|
|
1447
|
+
return msg.join("");
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
async function initContextProviderSdk(aws, options) {
|
|
1451
|
+
const account = options.account;
|
|
1452
|
+
const region = options.region;
|
|
1453
|
+
const creds = {
|
|
1454
|
+
assumeRoleArn: options.lookupRoleArn,
|
|
1455
|
+
assumeRoleExternalId: options.lookupRoleExternalId,
|
|
1456
|
+
assumeRoleAdditionalOptions: options.assumeRoleAdditionalOptions
|
|
1457
|
+
};
|
|
1458
|
+
return (await aws.forEnvironment(import_cx_api.EnvironmentUtils.make(account, region), 0 /* ForReading */, creds)).sdk;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// lib/context-providers/index.ts
|
|
1462
|
+
var cxschema2 = __toESM(require("@aws-cdk/cloud-assembly-schema"));
|
|
1463
|
+
var cxapi2 = __toESM(require("@aws-cdk/cx-api"));
|
|
1464
|
+
|
|
1465
|
+
// lib/context-providers/ami.ts
|
|
1466
|
+
var AmiContextProviderPlugin = class {
|
|
1467
|
+
constructor(aws, io) {
|
|
1468
|
+
this.aws = aws;
|
|
1469
|
+
this.io = io;
|
|
1470
|
+
}
|
|
1471
|
+
async getValue(args) {
|
|
1472
|
+
const region = args.region;
|
|
1473
|
+
const account = args.account;
|
|
1474
|
+
await this.io.info(`Searching for AMI in ${account}:${region}`);
|
|
1475
|
+
await this.io.debug(`AMI search parameters: ${JSON.stringify(args)}`);
|
|
1476
|
+
const ec2 = (await initContextProviderSdk(this.aws, args)).ec2();
|
|
1477
|
+
const response = await ec2.describeImages({
|
|
1478
|
+
Owners: args.owners,
|
|
1479
|
+
Filters: Object.entries(args.filters).map(([key, values]) => ({
|
|
1480
|
+
Name: key,
|
|
1481
|
+
Values: values
|
|
1482
|
+
}))
|
|
1483
|
+
});
|
|
1484
|
+
const images = [...response.Images || []].filter((i) => i.ImageId !== void 0);
|
|
1485
|
+
if (images.length === 0) {
|
|
1486
|
+
throw new ContextProviderError("No AMI found that matched the search criteria");
|
|
1487
|
+
}
|
|
1488
|
+
images.sort(descending((i) => Date.parse(i.CreationDate || "1970")));
|
|
1489
|
+
await this.io.debug(`Selected image '${images[0].ImageId}' created at '${images[0].CreationDate}'`);
|
|
1490
|
+
return images[0].ImageId;
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
function descending(valueOf) {
|
|
1494
|
+
return (a, b) => {
|
|
1495
|
+
return valueOf(b) - valueOf(a);
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// lib/context-providers/availability-zones.ts
|
|
1500
|
+
var AZContextProviderPlugin = class {
|
|
1501
|
+
constructor(aws, io) {
|
|
1502
|
+
this.aws = aws;
|
|
1503
|
+
this.io = io;
|
|
1504
|
+
}
|
|
1505
|
+
async getValue(args) {
|
|
1506
|
+
const region = args.region;
|
|
1507
|
+
const account = args.account;
|
|
1508
|
+
await this.io.debug(`Reading AZs for ${account}:${region}`);
|
|
1509
|
+
const ec2 = (await initContextProviderSdk(this.aws, args)).ec2();
|
|
1510
|
+
const response = await ec2.describeAvailabilityZones({});
|
|
1511
|
+
if (!response.AvailabilityZones) {
|
|
1512
|
+
return [];
|
|
1513
|
+
}
|
|
1514
|
+
const azs = response.AvailabilityZones.filter((zone) => zone.State === "available").map(
|
|
1515
|
+
(zone) => zone.ZoneName
|
|
1516
|
+
);
|
|
1517
|
+
return azs;
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
// lib/context-providers/cc-api-provider.ts
|
|
1522
|
+
var import_client_cloudcontrol2 = require("@aws-sdk/client-cloudcontrol");
|
|
1523
|
+
var CcApiContextProviderPlugin = class {
|
|
1524
|
+
constructor(aws) {
|
|
1525
|
+
this.aws = aws;
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* This returns a data object with the value from CloudControl API result.
|
|
1529
|
+
*
|
|
1530
|
+
* See the documentation in the Cloud Assembly Schema for the semantics of
|
|
1531
|
+
* each query parameter.
|
|
1532
|
+
*/
|
|
1533
|
+
async getValue(args) {
|
|
1534
|
+
if (args.exactIdentifier && args.propertyMatch) {
|
|
1535
|
+
throw new ContextProviderError(`Provider protocol error: specify either exactIdentifier or propertyMatch, but not both (got ${JSON.stringify(args)})`);
|
|
1536
|
+
}
|
|
1537
|
+
if (args.ignoreErrorOnMissingContext && args.dummyValue === void 0) {
|
|
1538
|
+
throw new ContextProviderError(`Provider protocol error: if ignoreErrorOnMissingContext is set, a dummyValue must be supplied (got ${JSON.stringify(args)})`);
|
|
1539
|
+
}
|
|
1540
|
+
if (args.dummyValue !== void 0 && (!Array.isArray(args.dummyValue) || !args.dummyValue.every(isObject2))) {
|
|
1541
|
+
throw new ContextProviderError(`Provider protocol error: dummyValue must be an array of objects (got ${JSON.stringify(args.dummyValue)})`);
|
|
1542
|
+
}
|
|
1543
|
+
const cloudControl = (await initContextProviderSdk(this.aws, args)).cloudControl();
|
|
1544
|
+
try {
|
|
1545
|
+
let resources;
|
|
1546
|
+
if (args.exactIdentifier) {
|
|
1547
|
+
resources = await this.getResource(cloudControl, args.typeName, args.exactIdentifier);
|
|
1548
|
+
} else if (args.propertyMatch) {
|
|
1549
|
+
resources = await this.listResources(cloudControl, args.typeName, args.propertyMatch, args.expectedMatchCount);
|
|
1550
|
+
} else {
|
|
1551
|
+
throw new ContextProviderError(`Provider protocol error: neither exactIdentifier nor propertyMatch is specified in ${JSON.stringify(args)}.`);
|
|
1552
|
+
}
|
|
1553
|
+
return resources.map((r) => getResultObj(r.properties, r.identifier, args.propertiesToReturn));
|
|
1554
|
+
} catch (err) {
|
|
1555
|
+
if (err instanceof ZeroResourcesFoundError && args.ignoreErrorOnMissingContext) {
|
|
1556
|
+
return args.dummyValue;
|
|
1557
|
+
}
|
|
1558
|
+
throw err;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Calls getResource from CC API to get the resource.
|
|
1563
|
+
* See https://docs.aws.amazon.com/cli/latest/reference/cloudcontrol/get-resource.html
|
|
1564
|
+
*
|
|
1565
|
+
* Will always return exactly one resource, or fail.
|
|
1566
|
+
*/
|
|
1567
|
+
async getResource(cc, typeName, exactIdentifier) {
|
|
1568
|
+
try {
|
|
1569
|
+
const result2 = await cc.getResource({
|
|
1570
|
+
TypeName: typeName,
|
|
1571
|
+
Identifier: exactIdentifier
|
|
1572
|
+
});
|
|
1573
|
+
if (!result2.ResourceDescription) {
|
|
1574
|
+
throw new ContextProviderError("Unexpected CloudControl API behavior: returned empty response");
|
|
1575
|
+
}
|
|
1576
|
+
return [foundResourceFromCcApi(result2.ResourceDescription)];
|
|
1577
|
+
} catch (err) {
|
|
1578
|
+
if (err instanceof import_client_cloudcontrol2.ResourceNotFoundException || err.name === "ResourceNotFoundException") {
|
|
1579
|
+
throw new ZeroResourcesFoundError(`No resource of type ${typeName} with identifier: ${exactIdentifier}`);
|
|
1580
|
+
}
|
|
1581
|
+
if (!(err instanceof ContextProviderError)) {
|
|
1582
|
+
throw new ContextProviderError(`Encountered CC API error while getting ${typeName} resource ${exactIdentifier}: ${err.message}`);
|
|
1583
|
+
}
|
|
1584
|
+
throw err;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Calls listResources from CC API to get the resources and apply args.propertyMatch to find the resources.
|
|
1589
|
+
* See https://docs.aws.amazon.com/cli/latest/reference/cloudcontrol/list-resources.html
|
|
1590
|
+
*
|
|
1591
|
+
* Will return 0 or more resources.
|
|
1592
|
+
*
|
|
1593
|
+
* Does not currently paginate through more than one result page.
|
|
1594
|
+
*/
|
|
1595
|
+
async listResources(cc, typeName, propertyMatch, expectedMatchCount) {
|
|
1596
|
+
try {
|
|
1597
|
+
const result2 = await cc.listResources({
|
|
1598
|
+
TypeName: typeName
|
|
1599
|
+
});
|
|
1600
|
+
const found = (result2.ResourceDescriptions ?? []).map(foundResourceFromCcApi).filter((r) => {
|
|
1601
|
+
return Object.entries(propertyMatch).every(([propPath, expected]) => {
|
|
1602
|
+
const actual = findJsonValue(r.properties, propPath);
|
|
1603
|
+
return propertyMatchesFilter(actual, expected);
|
|
1604
|
+
});
|
|
1605
|
+
});
|
|
1606
|
+
if ((expectedMatchCount === "at-least-one" || expectedMatchCount === "exactly-one") && found.length === 0) {
|
|
1607
|
+
throw new ZeroResourcesFoundError(`Could not find any resources matching ${JSON.stringify(propertyMatch)}`);
|
|
1608
|
+
}
|
|
1609
|
+
if ((expectedMatchCount === "at-most-one" || expectedMatchCount === "exactly-one") && found.length > 1) {
|
|
1610
|
+
throw new ContextProviderError(`Found ${found.length} resources matching ${JSON.stringify(propertyMatch)}; please narrow the search criteria`);
|
|
1611
|
+
}
|
|
1612
|
+
return found;
|
|
1613
|
+
} catch (err) {
|
|
1614
|
+
if (!(err instanceof ContextProviderError) && !(err instanceof ZeroResourcesFoundError)) {
|
|
1615
|
+
throw new ContextProviderError(`Encountered CC API error while listing ${typeName} resources matching ${JSON.stringify(propertyMatch)}: ${err.message}`);
|
|
1616
|
+
}
|
|
1617
|
+
throw err;
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
function foundResourceFromCcApi(desc) {
|
|
1622
|
+
return {
|
|
1623
|
+
identifier: desc.Identifier ?? "*MISSING*",
|
|
1624
|
+
properties: JSON.parse(desc.Properties ?? "{}")
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
function propertyMatchesFilter(actual, expected) {
|
|
1628
|
+
return expected === actual;
|
|
1629
|
+
}
|
|
1630
|
+
function isObject2(x) {
|
|
1631
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
1632
|
+
}
|
|
1633
|
+
var ZeroResourcesFoundError = class extends Error {
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// lib/context-providers/endpoint-service-availability-zones.ts
|
|
1637
|
+
var EndpointServiceAZContextProviderPlugin = class {
|
|
1638
|
+
constructor(aws, io) {
|
|
1639
|
+
this.aws = aws;
|
|
1640
|
+
this.io = io;
|
|
1641
|
+
}
|
|
1642
|
+
async getValue(args) {
|
|
1643
|
+
const region = args.region;
|
|
1644
|
+
const account = args.account;
|
|
1645
|
+
const serviceName = args.serviceName;
|
|
1646
|
+
await this.io.debug(`Reading AZs for ${account}:${region}:${serviceName}`);
|
|
1647
|
+
const ec2 = (await initContextProviderSdk(this.aws, args)).ec2();
|
|
1648
|
+
const response = await ec2.describeVpcEndpointServices({
|
|
1649
|
+
ServiceNames: [serviceName]
|
|
1650
|
+
});
|
|
1651
|
+
if (!response.ServiceDetails || response.ServiceDetails.length === 0) {
|
|
1652
|
+
await this.io.debug(`Could not retrieve service details for ${account}:${region}:${serviceName}`);
|
|
1653
|
+
return [];
|
|
1654
|
+
}
|
|
1655
|
+
const azs = response.ServiceDetails[0].AvailabilityZones;
|
|
1656
|
+
await this.io.debug(`Endpoint service ${account}:${region}:${serviceName} is available in availability zones ${azs}`);
|
|
1657
|
+
return azs;
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// lib/context-providers/hosted-zones.ts
|
|
1662
|
+
var HostedZoneContextProviderPlugin = class {
|
|
1663
|
+
constructor(aws, io) {
|
|
1664
|
+
this.aws = aws;
|
|
1665
|
+
this.io = io;
|
|
1666
|
+
}
|
|
1667
|
+
async getValue(args) {
|
|
1668
|
+
const account = args.account;
|
|
1669
|
+
const region = args.region;
|
|
1670
|
+
if (!this.isHostedZoneQuery(args)) {
|
|
1671
|
+
throw new ContextProviderError(`HostedZoneProvider requires domainName property to be set in ${args}`);
|
|
1672
|
+
}
|
|
1673
|
+
const domainName = args.domainName;
|
|
1674
|
+
await this.io.debug(`Reading hosted zone ${account}:${region}:${domainName}`);
|
|
1675
|
+
const r53 = (await initContextProviderSdk(this.aws, args)).route53();
|
|
1676
|
+
const response = await r53.listHostedZonesByName({ DNSName: domainName });
|
|
1677
|
+
if (!response.HostedZones) {
|
|
1678
|
+
throw new ContextProviderError(`Hosted Zone not found in account ${account}, region ${region}: ${domainName}`);
|
|
1679
|
+
}
|
|
1680
|
+
const candidateZones = await this.filterZones(r53, response.HostedZones, args);
|
|
1681
|
+
if (candidateZones.length !== 1) {
|
|
1682
|
+
const filteProps = `dns:${domainName}, privateZone:${args.privateZone}, vpcId:${args.vpcId}`;
|
|
1683
|
+
throw new ContextProviderError(`Found zones: ${JSON.stringify(candidateZones)} for ${filteProps}, but wanted exactly 1 zone`);
|
|
1684
|
+
}
|
|
1685
|
+
return {
|
|
1686
|
+
Id: candidateZones[0].Id,
|
|
1687
|
+
Name: candidateZones[0].Name
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
async filterZones(r53, zones, props) {
|
|
1691
|
+
let candidates = [];
|
|
1692
|
+
const domainName = props.domainName.endsWith(".") ? props.domainName : `${props.domainName}.`;
|
|
1693
|
+
await this.io.debug(`Found the following zones ${JSON.stringify(zones)}`);
|
|
1694
|
+
candidates = zones.filter((zone) => zone.Name === domainName);
|
|
1695
|
+
await this.io.debug(`Found the following matched name zones ${JSON.stringify(candidates)}`);
|
|
1696
|
+
if (props.privateZone) {
|
|
1697
|
+
candidates = candidates.filter((zone) => zone.Config && zone.Config.PrivateZone);
|
|
1698
|
+
} else {
|
|
1699
|
+
candidates = candidates.filter((zone) => !zone.Config || !zone.Config.PrivateZone);
|
|
1700
|
+
}
|
|
1701
|
+
if (props.vpcId) {
|
|
1702
|
+
const vpcZones = [];
|
|
1703
|
+
for (const zone of candidates) {
|
|
1704
|
+
const data = await r53.getHostedZone({ Id: zone.Id });
|
|
1705
|
+
if (!data.VPCs) {
|
|
1706
|
+
await this.io.debug(`Expected VPC for private zone but no VPC found ${zone.Id}`);
|
|
1707
|
+
continue;
|
|
1708
|
+
}
|
|
1709
|
+
if (data.VPCs.map((vpc) => vpc.VPCId).includes(props.vpcId)) {
|
|
1710
|
+
vpcZones.push(zone);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
return vpcZones;
|
|
1714
|
+
}
|
|
1715
|
+
return candidates;
|
|
1716
|
+
}
|
|
1717
|
+
isHostedZoneQuery(props) {
|
|
1718
|
+
return props.domainName !== void 0;
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
// lib/context-providers/keys.ts
|
|
1723
|
+
var KeyContextProviderPlugin = class {
|
|
1724
|
+
constructor(aws, io) {
|
|
1725
|
+
this.aws = aws;
|
|
1726
|
+
this.io = io;
|
|
1727
|
+
}
|
|
1728
|
+
async getValue(args) {
|
|
1729
|
+
const kms = (await initContextProviderSdk(this.aws, args)).kms();
|
|
1730
|
+
const aliasListEntry = await this.findKey(kms, args);
|
|
1731
|
+
return this.readKeyProps(aliasListEntry, args);
|
|
1732
|
+
}
|
|
1733
|
+
// TODO: use paginator function
|
|
1734
|
+
async findKey(kms, args) {
|
|
1735
|
+
await this.io.debug(`Listing keys in ${args.account}:${args.region}`);
|
|
1736
|
+
let response;
|
|
1737
|
+
let nextMarker;
|
|
1738
|
+
do {
|
|
1739
|
+
response = await kms.listAliases({
|
|
1740
|
+
Marker: nextMarker
|
|
1741
|
+
});
|
|
1742
|
+
const aliases = response.Aliases || [];
|
|
1743
|
+
for (const alias of aliases) {
|
|
1744
|
+
if (alias.AliasName == args.aliasName) {
|
|
1745
|
+
return alias;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
nextMarker = response.NextMarker;
|
|
1749
|
+
} while (nextMarker);
|
|
1750
|
+
const suppressError = "ignoreErrorOnMissingContext" in args && args.ignoreErrorOnMissingContext;
|
|
1751
|
+
const hasDummyKeyId = "dummyValue" in args && typeof args.dummyValue === "object" && args.dummyValue !== null && "keyId" in args.dummyValue;
|
|
1752
|
+
if (suppressError && hasDummyKeyId) {
|
|
1753
|
+
const keyId = args.dummyValue.keyId;
|
|
1754
|
+
return { TargetKeyId: keyId };
|
|
1755
|
+
}
|
|
1756
|
+
throw new ContextProviderError(`Could not find any key with alias named ${args.aliasName}`);
|
|
1757
|
+
}
|
|
1758
|
+
async readKeyProps(alias, args) {
|
|
1759
|
+
if (!alias.TargetKeyId) {
|
|
1760
|
+
throw new ContextProviderError(`Could not find any key with alias named ${args.aliasName}`);
|
|
1761
|
+
}
|
|
1762
|
+
await this.io.debug(`Key found ${alias.TargetKeyId}`);
|
|
1763
|
+
return {
|
|
1764
|
+
keyId: alias.TargetKeyId
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
|
|
1769
|
+
// lib/context-providers/load-balancers.ts
|
|
1770
|
+
var import_cx_api2 = require("@aws-cdk/cx-api");
|
|
1771
|
+
var LoadBalancerContextProviderPlugin = class {
|
|
1772
|
+
constructor(aws) {
|
|
1773
|
+
this.aws = aws;
|
|
1774
|
+
}
|
|
1775
|
+
async getValue(query) {
|
|
1776
|
+
if (!query.loadBalancerArn && !query.loadBalancerTags) {
|
|
1777
|
+
throw new ContextProviderError("The load balancer lookup query must specify either `loadBalancerArn` or `loadBalancerTags`");
|
|
1778
|
+
}
|
|
1779
|
+
const loadBalancer = await (await LoadBalancerProvider.getClient(this.aws, query)).getLoadBalancer();
|
|
1780
|
+
const ipAddressType = loadBalancer.IpAddressType === "ipv4" ? import_cx_api2.LoadBalancerIpAddressType.IPV4 : import_cx_api2.LoadBalancerIpAddressType.DUAL_STACK;
|
|
1781
|
+
return {
|
|
1782
|
+
loadBalancerArn: loadBalancer.LoadBalancerArn,
|
|
1783
|
+
loadBalancerCanonicalHostedZoneId: loadBalancer.CanonicalHostedZoneId,
|
|
1784
|
+
loadBalancerDnsName: loadBalancer.DNSName,
|
|
1785
|
+
vpcId: loadBalancer.VpcId,
|
|
1786
|
+
securityGroupIds: loadBalancer.SecurityGroups ?? [],
|
|
1787
|
+
ipAddressType
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
var LoadBalancerListenerContextProviderPlugin = class {
|
|
1792
|
+
constructor(aws) {
|
|
1793
|
+
this.aws = aws;
|
|
1794
|
+
}
|
|
1795
|
+
async getValue(query) {
|
|
1796
|
+
if (!query.listenerArn && !query.loadBalancerArn && !query.loadBalancerTags) {
|
|
1797
|
+
throw new ContextProviderError(
|
|
1798
|
+
"The load balancer listener query must specify at least one of: `listenerArn`, `loadBalancerArn` or `loadBalancerTags`"
|
|
1799
|
+
);
|
|
1800
|
+
}
|
|
1801
|
+
return (await LoadBalancerProvider.getClient(this.aws, query)).getListener();
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1804
|
+
var LoadBalancerProvider = class _LoadBalancerProvider {
|
|
1805
|
+
constructor(client, filter, listener) {
|
|
1806
|
+
this.client = client;
|
|
1807
|
+
this.filter = filter;
|
|
1808
|
+
this.listener = listener;
|
|
1809
|
+
}
|
|
1810
|
+
static async getClient(aws, query) {
|
|
1811
|
+
const client = (await initContextProviderSdk(aws, query)).elbv2();
|
|
1812
|
+
try {
|
|
1813
|
+
const listener = query.listenerArn ? (
|
|
1814
|
+
// Assert we're sure there's at least one so it throws if not
|
|
1815
|
+
(await client.describeListeners({ ListenerArns: [query.listenerArn] })).Listeners[0]
|
|
1816
|
+
) : void 0;
|
|
1817
|
+
return new _LoadBalancerProvider(
|
|
1818
|
+
client,
|
|
1819
|
+
{ ...query, loadBalancerArn: listener?.LoadBalancerArn || query.loadBalancerArn },
|
|
1820
|
+
listener
|
|
1821
|
+
);
|
|
1822
|
+
} catch (err) {
|
|
1823
|
+
throw new ContextProviderError(`No load balancer listeners found matching arn ${query.listenerArn}`);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
async getLoadBalancer() {
|
|
1827
|
+
const loadBalancers = await this.getLoadBalancers();
|
|
1828
|
+
if (loadBalancers.length === 0) {
|
|
1829
|
+
throw new ContextProviderError(`No load balancers found matching ${JSON.stringify(this.filter)}`);
|
|
1830
|
+
}
|
|
1831
|
+
if (loadBalancers.length > 1) {
|
|
1832
|
+
throw new ContextProviderError(
|
|
1833
|
+
`Multiple load balancers found matching ${JSON.stringify(this.filter)} - please provide more specific criteria`
|
|
1834
|
+
);
|
|
1835
|
+
}
|
|
1836
|
+
return loadBalancers[0];
|
|
1837
|
+
}
|
|
1838
|
+
async getListener() {
|
|
1839
|
+
if (this.listener) {
|
|
1840
|
+
try {
|
|
1841
|
+
const loadBalancer = await this.getLoadBalancer();
|
|
1842
|
+
return {
|
|
1843
|
+
listenerArn: this.listener.ListenerArn,
|
|
1844
|
+
listenerPort: this.listener.Port,
|
|
1845
|
+
securityGroupIds: loadBalancer.SecurityGroups || []
|
|
1846
|
+
};
|
|
1847
|
+
} catch (err) {
|
|
1848
|
+
throw new ContextProviderError(`No associated load balancer found for listener arn ${this.filter.listenerArn}`);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
const loadBalancers = await this.getLoadBalancers();
|
|
1852
|
+
if (loadBalancers.length === 0) {
|
|
1853
|
+
throw new ContextProviderError(
|
|
1854
|
+
`No associated load balancers found for load balancer listener query ${JSON.stringify(this.filter)}`
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
const listeners = (await this.getListenersForLoadBalancers(loadBalancers)).filter((listener) => {
|
|
1858
|
+
return (!this.filter.listenerPort || listener.Port === this.filter.listenerPort) && (!this.filter.listenerProtocol || listener.Protocol === this.filter.listenerProtocol);
|
|
1859
|
+
});
|
|
1860
|
+
if (listeners.length === 0) {
|
|
1861
|
+
throw new ContextProviderError(`No load balancer listeners found matching ${JSON.stringify(this.filter)}`);
|
|
1862
|
+
}
|
|
1863
|
+
if (listeners.length > 1) {
|
|
1864
|
+
throw new ContextProviderError(
|
|
1865
|
+
`Multiple load balancer listeners found matching ${JSON.stringify(this.filter)} - please provide more specific criteria`
|
|
1866
|
+
);
|
|
1867
|
+
}
|
|
1868
|
+
return {
|
|
1869
|
+
listenerArn: listeners[0].ListenerArn,
|
|
1870
|
+
listenerPort: listeners[0].Port,
|
|
1871
|
+
securityGroupIds: loadBalancers.find((lb) => listeners[0].LoadBalancerArn === lb.LoadBalancerArn)?.SecurityGroups || []
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
async getLoadBalancers() {
|
|
1875
|
+
const loadBalancerArns = this.filter.loadBalancerArn ? [this.filter.loadBalancerArn] : void 0;
|
|
1876
|
+
const loadBalancers = (await this.client.paginateDescribeLoadBalancers({
|
|
1877
|
+
LoadBalancerArns: loadBalancerArns
|
|
1878
|
+
})).filter((lb) => lb.Type === this.filter.loadBalancerType);
|
|
1879
|
+
return this.filterByTags(loadBalancers);
|
|
1880
|
+
}
|
|
1881
|
+
async filterByTags(loadBalancers) {
|
|
1882
|
+
if (!this.filter.loadBalancerTags) {
|
|
1883
|
+
return loadBalancers;
|
|
1884
|
+
}
|
|
1885
|
+
return (await this.describeTags(loadBalancers.map((lb) => lb.LoadBalancerArn))).filter((tagDescription) => {
|
|
1886
|
+
return this.filter.loadBalancerTags.every((filter) => {
|
|
1887
|
+
return tagDescription.Tags?.some((tag) => filter.key === tag.Key && filter.value === tag.Value);
|
|
1888
|
+
});
|
|
1889
|
+
}).flatMap((tag) => loadBalancers.filter((loadBalancer) => tag.ResourceArn === loadBalancer.LoadBalancerArn));
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Returns tag descriptions associated with the resources. The API doesn't support
|
|
1893
|
+
* pagination, so this function breaks the resource list into chunks and issues
|
|
1894
|
+
* the appropriate requests.
|
|
1895
|
+
*/
|
|
1896
|
+
async describeTags(resourceArns) {
|
|
1897
|
+
const chunkSize = 20;
|
|
1898
|
+
const tags = Array();
|
|
1899
|
+
for (let i = 0; i < resourceArns.length; i += chunkSize) {
|
|
1900
|
+
const chunk = resourceArns.slice(i, Math.min(i + chunkSize, resourceArns.length));
|
|
1901
|
+
const chunkTags = await this.client.describeTags({
|
|
1902
|
+
ResourceArns: chunk
|
|
1903
|
+
});
|
|
1904
|
+
tags.push(...chunkTags.TagDescriptions || []);
|
|
1905
|
+
}
|
|
1906
|
+
return tags;
|
|
1907
|
+
}
|
|
1908
|
+
async getListenersForLoadBalancers(loadBalancers) {
|
|
1909
|
+
const listeners = [];
|
|
1910
|
+
for (const loadBalancer of loadBalancers.map((lb) => lb.LoadBalancerArn)) {
|
|
1911
|
+
listeners.push(...await this.client.paginateDescribeListeners({ LoadBalancerArn: loadBalancer }));
|
|
1912
|
+
}
|
|
1913
|
+
return listeners;
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1917
|
+
// lib/context-providers/security-groups.ts
|
|
1918
|
+
var SecurityGroupContextProviderPlugin = class {
|
|
1919
|
+
constructor(aws) {
|
|
1920
|
+
this.aws = aws;
|
|
1921
|
+
}
|
|
1922
|
+
async getValue(args) {
|
|
1923
|
+
if (args.securityGroupId && args.securityGroupName) {
|
|
1924
|
+
throw new ContextProviderError(
|
|
1925
|
+
"'securityGroupId' and 'securityGroupName' can not be specified both when looking up a security group"
|
|
1926
|
+
);
|
|
1927
|
+
}
|
|
1928
|
+
if (!args.securityGroupId && !args.securityGroupName) {
|
|
1929
|
+
throw new ContextProviderError("'securityGroupId' or 'securityGroupName' must be specified to look up a security group");
|
|
1930
|
+
}
|
|
1931
|
+
const ec2 = (await initContextProviderSdk(this.aws, args)).ec2();
|
|
1932
|
+
const filters = [];
|
|
1933
|
+
if (args.vpcId) {
|
|
1934
|
+
filters.push({
|
|
1935
|
+
Name: "vpc-id",
|
|
1936
|
+
Values: [args.vpcId]
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
if (args.securityGroupName) {
|
|
1940
|
+
filters.push({
|
|
1941
|
+
Name: "group-name",
|
|
1942
|
+
Values: [args.securityGroupName]
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
const response = await ec2.describeSecurityGroups({
|
|
1946
|
+
GroupIds: args.securityGroupId ? [args.securityGroupId] : void 0,
|
|
1947
|
+
Filters: filters.length > 0 ? filters : void 0
|
|
1948
|
+
});
|
|
1949
|
+
const securityGroups = response.SecurityGroups ?? [];
|
|
1950
|
+
if (securityGroups.length === 0) {
|
|
1951
|
+
throw new ContextProviderError(`No security groups found matching ${JSON.stringify(args)}`);
|
|
1952
|
+
}
|
|
1953
|
+
if (securityGroups.length > 1) {
|
|
1954
|
+
throw new ContextProviderError(`More than one security groups found matching ${JSON.stringify(args)}`);
|
|
1955
|
+
}
|
|
1956
|
+
const [securityGroup] = securityGroups;
|
|
1957
|
+
return {
|
|
1958
|
+
securityGroupId: securityGroup.GroupId,
|
|
1959
|
+
allowAllOutbound: hasAllTrafficEgress(securityGroup)
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
function hasAllTrafficEgress(securityGroup) {
|
|
1964
|
+
let hasAllTrafficCidrV4 = false;
|
|
1965
|
+
let hasAllTrafficCidrV6 = false;
|
|
1966
|
+
for (const ipPermission of securityGroup.IpPermissionsEgress ?? []) {
|
|
1967
|
+
const isAllProtocols = ipPermission.IpProtocol === "-1";
|
|
1968
|
+
if (isAllProtocols && ipPermission.IpRanges?.some((m) => m.CidrIp === "0.0.0.0/0")) {
|
|
1969
|
+
hasAllTrafficCidrV4 = true;
|
|
1970
|
+
}
|
|
1971
|
+
if (isAllProtocols && ipPermission.Ipv6Ranges?.some((m) => m.CidrIpv6 === "::/0")) {
|
|
1972
|
+
hasAllTrafficCidrV6 = true;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
return hasAllTrafficCidrV4 && hasAllTrafficCidrV6;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
// lib/context-providers/ssm-parameters.ts
|
|
1979
|
+
var SSMContextProviderPlugin = class {
|
|
1980
|
+
constructor(aws, io) {
|
|
1981
|
+
this.aws = aws;
|
|
1982
|
+
this.io = io;
|
|
1983
|
+
}
|
|
1984
|
+
async getValue(args) {
|
|
1985
|
+
const region = args.region;
|
|
1986
|
+
const account = args.account;
|
|
1987
|
+
if (!("parameterName" in args)) {
|
|
1988
|
+
throw new ContextProviderError("parameterName must be provided in props for SSMContextProviderPlugin");
|
|
1989
|
+
}
|
|
1990
|
+
const parameterName = args.parameterName;
|
|
1991
|
+
await this.io.debug(`Reading SSM parameter ${account}:${region}:${parameterName}`);
|
|
1992
|
+
const response = await this.getSsmParameterValue(args);
|
|
1993
|
+
const parameterNotFound = !response.Parameter || response.Parameter.Value === void 0;
|
|
1994
|
+
const suppressError = "ignoreErrorOnMissingContext" in args && args.ignoreErrorOnMissingContext;
|
|
1995
|
+
if (parameterNotFound && suppressError && "dummyValue" in args) {
|
|
1996
|
+
return args.dummyValue;
|
|
1997
|
+
}
|
|
1998
|
+
if (parameterNotFound) {
|
|
1999
|
+
throw new ContextProviderError(`SSM parameter not available in account ${account}, region ${region}: ${parameterName}`);
|
|
2000
|
+
}
|
|
2001
|
+
return response.Parameter.Value;
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Gets the value of an SSM Parameter, while not throwin if the parameter does not exist.
|
|
2005
|
+
* @param account the account in which the SSM Parameter is expected to be.
|
|
2006
|
+
* @param region the region in which the SSM Parameter is expected to be.
|
|
2007
|
+
* @param parameterName the name of the SSM Parameter
|
|
2008
|
+
* @param lookupRoleArn the ARN of the lookup role.
|
|
2009
|
+
*
|
|
2010
|
+
* @returns the result of the ``GetParameter`` operation.
|
|
2011
|
+
*
|
|
2012
|
+
* @throws Error if a service error (other than ``ParameterNotFound``) occurs.
|
|
2013
|
+
*/
|
|
2014
|
+
async getSsmParameterValue(args) {
|
|
2015
|
+
const ssm = (await initContextProviderSdk(this.aws, args)).ssm();
|
|
2016
|
+
try {
|
|
2017
|
+
return await ssm.getParameter({ Name: args.parameterName });
|
|
2018
|
+
} catch (e) {
|
|
2019
|
+
if (e.name === "ParameterNotFound") {
|
|
2020
|
+
return { $metadata: {} };
|
|
2021
|
+
}
|
|
2022
|
+
throw e;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
|
|
2027
|
+
// lib/context-providers/vpcs.ts
|
|
2028
|
+
var import_cx_api3 = require("@aws-cdk/cx-api");
|
|
2029
|
+
var VpcNetworkContextProviderPlugin = class {
|
|
2030
|
+
constructor(aws, io) {
|
|
2031
|
+
this.aws = aws;
|
|
2032
|
+
this.io = io;
|
|
2033
|
+
}
|
|
2034
|
+
async getValue(args) {
|
|
2035
|
+
const ec2 = (await initContextProviderSdk(this.aws, args)).ec2();
|
|
2036
|
+
const vpcId = await this.findVpc(ec2, args);
|
|
2037
|
+
return this.readVpcProps(ec2, vpcId, args);
|
|
2038
|
+
}
|
|
2039
|
+
async findVpc(ec2, args) {
|
|
2040
|
+
const filters = Object.entries(args.filter).map(([tag, value]) => ({ Name: tag, Values: [value] }));
|
|
2041
|
+
await this.io.debug(`Listing VPCs in ${args.account}:${args.region}`);
|
|
2042
|
+
const response = await ec2.describeVpcs({ Filters: filters });
|
|
2043
|
+
const vpcs = response.Vpcs || [];
|
|
2044
|
+
if (vpcs.length === 0) {
|
|
2045
|
+
throw new ContextProviderError(`Could not find any VPCs matching ${JSON.stringify(args)}`);
|
|
2046
|
+
}
|
|
2047
|
+
if (vpcs.length > 1) {
|
|
2048
|
+
throw new ContextProviderError(`Found ${vpcs.length} VPCs matching ${JSON.stringify(args)}; please narrow the search criteria`);
|
|
2049
|
+
}
|
|
2050
|
+
return vpcs[0];
|
|
2051
|
+
}
|
|
2052
|
+
async readVpcProps(ec2, vpc, args) {
|
|
2053
|
+
const vpcId = vpc.VpcId;
|
|
2054
|
+
await this.io.debug(`Describing VPC ${vpcId}`);
|
|
2055
|
+
const filters = { Filters: [{ Name: "vpc-id", Values: [vpcId] }] };
|
|
2056
|
+
const subnetsResponse = await ec2.describeSubnets(filters);
|
|
2057
|
+
const listedSubnets = subnetsResponse.Subnets || [];
|
|
2058
|
+
const routeTablesResponse = await ec2.describeRouteTables(filters);
|
|
2059
|
+
const routeTables = new RouteTables(routeTablesResponse.RouteTables || []);
|
|
2060
|
+
const azs = Array.from(new Set(listedSubnets.map((s) => s.AvailabilityZone)));
|
|
2061
|
+
azs.sort();
|
|
2062
|
+
const subnets = listedSubnets.map((subnet) => {
|
|
2063
|
+
let type = getTag("aws-cdk:subnet-type", subnet.Tags);
|
|
2064
|
+
if (type === void 0 && subnet.MapPublicIpOnLaunch) {
|
|
2065
|
+
type = "Public" /* Public */;
|
|
2066
|
+
}
|
|
2067
|
+
if (type === void 0 && routeTables.hasRouteToIgw(subnet.SubnetId)) {
|
|
2068
|
+
type = "Public" /* Public */;
|
|
2069
|
+
}
|
|
2070
|
+
if (type === void 0 && routeTables.hasRouteToNatGateway(subnet.SubnetId)) {
|
|
2071
|
+
type = "Private" /* Private */;
|
|
2072
|
+
}
|
|
2073
|
+
if (type === void 0 && routeTables.hasRouteToTransitGateway(subnet.SubnetId)) {
|
|
2074
|
+
type = "Private" /* Private */;
|
|
2075
|
+
}
|
|
2076
|
+
if (type === void 0) {
|
|
2077
|
+
type = "Isolated" /* Isolated */;
|
|
2078
|
+
}
|
|
2079
|
+
if (!isValidSubnetType(type)) {
|
|
2080
|
+
throw new ContextProviderError(
|
|
2081
|
+
`Subnet ${subnet.SubnetArn} has invalid subnet type ${type} (must be ${"Public" /* Public */}, ${"Private" /* Private */} or ${"Isolated" /* Isolated */})`
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
2084
|
+
if (args.subnetGroupNameTag && !getTag(args.subnetGroupNameTag, subnet.Tags)) {
|
|
2085
|
+
throw new ContextProviderError(
|
|
2086
|
+
`Invalid subnetGroupNameTag: Subnet ${subnet.SubnetArn} does not have an associated tag with Key='${args.subnetGroupNameTag}'`
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
const name = getTag(args.subnetGroupNameTag || "aws-cdk:subnet-name", subnet.Tags) || type;
|
|
2090
|
+
const routeTableId = routeTables.routeTableIdForSubnetId(subnet.SubnetId);
|
|
2091
|
+
if (!routeTableId) {
|
|
2092
|
+
throw new ContextProviderError(
|
|
2093
|
+
`Subnet ${subnet.SubnetArn} does not have an associated route table (and there is no "main" table)`
|
|
2094
|
+
);
|
|
2095
|
+
}
|
|
2096
|
+
return {
|
|
2097
|
+
az: subnet.AvailabilityZone,
|
|
2098
|
+
cidr: subnet.CidrBlock,
|
|
2099
|
+
type,
|
|
2100
|
+
name,
|
|
2101
|
+
subnetId: subnet.SubnetId,
|
|
2102
|
+
routeTableId
|
|
2103
|
+
};
|
|
2104
|
+
});
|
|
2105
|
+
let grouped;
|
|
2106
|
+
let assymetricSubnetGroups;
|
|
2107
|
+
if (args.returnAsymmetricSubnets) {
|
|
2108
|
+
grouped = { azs: [], groups: [] };
|
|
2109
|
+
assymetricSubnetGroups = groupAsymmetricSubnets(subnets);
|
|
2110
|
+
} else {
|
|
2111
|
+
grouped = groupSubnets(subnets);
|
|
2112
|
+
assymetricSubnetGroups = void 0;
|
|
2113
|
+
}
|
|
2114
|
+
const vpnGatewayResponse = args.returnVpnGateways ?? true ? await ec2.describeVpnGateways({
|
|
2115
|
+
Filters: [
|
|
2116
|
+
{
|
|
2117
|
+
Name: "attachment.vpc-id",
|
|
2118
|
+
Values: [vpcId]
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
Name: "attachment.state",
|
|
2122
|
+
Values: ["attached"]
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
Name: "state",
|
|
2126
|
+
Values: ["available"]
|
|
2127
|
+
}
|
|
2128
|
+
]
|
|
2129
|
+
}) : void 0;
|
|
2130
|
+
const vpnGatewayId = vpnGatewayResponse?.VpnGateways?.length === 1 ? vpnGatewayResponse.VpnGateways[0].VpnGatewayId : void 0;
|
|
2131
|
+
return {
|
|
2132
|
+
vpcId,
|
|
2133
|
+
vpcCidrBlock: vpc.CidrBlock,
|
|
2134
|
+
ownerAccountId: vpc.OwnerId,
|
|
2135
|
+
availabilityZones: grouped.azs,
|
|
2136
|
+
isolatedSubnetIds: collapse(
|
|
2137
|
+
flatMap(findGroups("Isolated" /* Isolated */, grouped), (group) => group.subnets.map((s) => s.subnetId))
|
|
2138
|
+
),
|
|
2139
|
+
isolatedSubnetNames: collapse(
|
|
2140
|
+
flatMap(findGroups("Isolated" /* Isolated */, grouped), (group) => group.name ? [group.name] : [])
|
|
2141
|
+
),
|
|
2142
|
+
isolatedSubnetRouteTableIds: collapse(
|
|
2143
|
+
flatMap(findGroups("Isolated" /* Isolated */, grouped), (group) => group.subnets.map((s) => s.routeTableId))
|
|
2144
|
+
),
|
|
2145
|
+
privateSubnetIds: collapse(
|
|
2146
|
+
flatMap(findGroups("Private" /* Private */, grouped), (group) => group.subnets.map((s) => s.subnetId))
|
|
2147
|
+
),
|
|
2148
|
+
privateSubnetNames: collapse(
|
|
2149
|
+
flatMap(findGroups("Private" /* Private */, grouped), (group) => group.name ? [group.name] : [])
|
|
2150
|
+
),
|
|
2151
|
+
privateSubnetRouteTableIds: collapse(
|
|
2152
|
+
flatMap(findGroups("Private" /* Private */, grouped), (group) => group.subnets.map((s) => s.routeTableId))
|
|
2153
|
+
),
|
|
2154
|
+
publicSubnetIds: collapse(
|
|
2155
|
+
flatMap(findGroups("Public" /* Public */, grouped), (group) => group.subnets.map((s) => s.subnetId))
|
|
2156
|
+
),
|
|
2157
|
+
publicSubnetNames: collapse(
|
|
2158
|
+
flatMap(findGroups("Public" /* Public */, grouped), (group) => group.name ? [group.name] : [])
|
|
2159
|
+
),
|
|
2160
|
+
publicSubnetRouteTableIds: collapse(
|
|
2161
|
+
flatMap(findGroups("Public" /* Public */, grouped), (group) => group.subnets.map((s) => s.routeTableId))
|
|
2162
|
+
),
|
|
2163
|
+
vpnGatewayId,
|
|
2164
|
+
subnetGroups: assymetricSubnetGroups
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
var RouteTables = class {
|
|
2169
|
+
constructor(tables) {
|
|
2170
|
+
this.tables = tables;
|
|
2171
|
+
this.mainRouteTable = this.tables.find(
|
|
2172
|
+
(table) => !!table.Associations && table.Associations.some((assoc) => !!assoc.Main)
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
mainRouteTable;
|
|
2176
|
+
routeTableIdForSubnetId(subnetId) {
|
|
2177
|
+
const table = this.tableForSubnet(subnetId);
|
|
2178
|
+
return table && table.RouteTableId || this.mainRouteTable && this.mainRouteTable.RouteTableId;
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Whether the given subnet has a route to a NAT Gateway
|
|
2182
|
+
*/
|
|
2183
|
+
hasRouteToNatGateway(subnetId) {
|
|
2184
|
+
const table = this.tableForSubnet(subnetId) || this.mainRouteTable;
|
|
2185
|
+
return !!table && !!table.Routes && table.Routes.some((route) => !!route.NatGatewayId && route.DestinationCidrBlock === "0.0.0.0/0");
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Whether the given subnet has a route to a Transit Gateway
|
|
2189
|
+
*/
|
|
2190
|
+
hasRouteToTransitGateway(subnetId) {
|
|
2191
|
+
const table = this.tableForSubnet(subnetId) || this.mainRouteTable;
|
|
2192
|
+
return !!table && !!table.Routes && table.Routes.some((route) => !!route.TransitGatewayId && route.DestinationCidrBlock === "0.0.0.0/0");
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Whether the given subnet has a route to an IGW
|
|
2196
|
+
*/
|
|
2197
|
+
hasRouteToIgw(subnetId) {
|
|
2198
|
+
const table = this.tableForSubnet(subnetId) || this.mainRouteTable;
|
|
2199
|
+
return !!table && !!table.Routes && table.Routes.some((route) => !!route.GatewayId && route.GatewayId.startsWith("igw-"));
|
|
2200
|
+
}
|
|
2201
|
+
tableForSubnet(subnetId) {
|
|
2202
|
+
return this.tables.find(
|
|
2203
|
+
(table) => !!table.Associations && table.Associations.some((assoc) => assoc.SubnetId === subnetId)
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
function getTag(name, tags) {
|
|
2208
|
+
for (const tag of tags || []) {
|
|
2209
|
+
if (tag.Key === name) {
|
|
2210
|
+
return tag.Value;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
return void 0;
|
|
2214
|
+
}
|
|
2215
|
+
function groupSubnets(subnets) {
|
|
2216
|
+
const grouping = {};
|
|
2217
|
+
for (const subnet of subnets) {
|
|
2218
|
+
const key = [subnet.type, subnet.name].toString();
|
|
2219
|
+
if (!(key in grouping)) {
|
|
2220
|
+
grouping[key] = [];
|
|
2221
|
+
}
|
|
2222
|
+
grouping[key].push(subnet);
|
|
2223
|
+
}
|
|
2224
|
+
const groups = Object.values(grouping).map((sns) => {
|
|
2225
|
+
sns.sort((a, b) => a.az.localeCompare(b.az));
|
|
2226
|
+
return {
|
|
2227
|
+
type: sns[0].type,
|
|
2228
|
+
name: sns[0].name,
|
|
2229
|
+
subnets: sns
|
|
2230
|
+
};
|
|
2231
|
+
});
|
|
2232
|
+
const azs = groups[0].subnets.map((s) => s.az);
|
|
2233
|
+
for (const group of groups) {
|
|
2234
|
+
const groupAZs = group.subnets.map((s) => s.az);
|
|
2235
|
+
if (!arraysEqual(groupAZs, azs)) {
|
|
2236
|
+
throw new ContextProviderError(`Not all subnets in VPC have the same AZs: ${groupAZs} vs ${azs}`);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
return { azs, groups };
|
|
2240
|
+
}
|
|
2241
|
+
function groupAsymmetricSubnets(subnets) {
|
|
2242
|
+
const grouping = {};
|
|
2243
|
+
for (const subnet of subnets) {
|
|
2244
|
+
const key = [subnet.type, subnet.name].toString();
|
|
2245
|
+
if (!(key in grouping)) {
|
|
2246
|
+
grouping[key] = [];
|
|
2247
|
+
}
|
|
2248
|
+
grouping[key].push(subnet);
|
|
2249
|
+
}
|
|
2250
|
+
return Object.values(grouping).map((subnetArray) => {
|
|
2251
|
+
subnetArray.sort((subnet1, subnet2) => subnet1.az.localeCompare(subnet2.az));
|
|
2252
|
+
return {
|
|
2253
|
+
name: subnetArray[0].name,
|
|
2254
|
+
type: subnetTypeToVpcSubnetType(subnetArray[0].type),
|
|
2255
|
+
subnets: subnetArray.map((subnet) => ({
|
|
2256
|
+
subnetId: subnet.subnetId,
|
|
2257
|
+
cidr: subnet.cidr,
|
|
2258
|
+
availabilityZone: subnet.az,
|
|
2259
|
+
routeTableId: subnet.routeTableId
|
|
2260
|
+
}))
|
|
2261
|
+
};
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
function subnetTypeToVpcSubnetType(type) {
|
|
2265
|
+
switch (type) {
|
|
2266
|
+
case "Isolated" /* Isolated */:
|
|
2267
|
+
return import_cx_api3.VpcSubnetGroupType.ISOLATED;
|
|
2268
|
+
case "Private" /* Private */:
|
|
2269
|
+
return import_cx_api3.VpcSubnetGroupType.PRIVATE;
|
|
2270
|
+
case "Public" /* Public */:
|
|
2271
|
+
return import_cx_api3.VpcSubnetGroupType.PUBLIC;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
function isValidSubnetType(val) {
|
|
2275
|
+
return val === "Public" /* Public */ || val === "Private" /* Private */ || val === "Isolated" /* Isolated */;
|
|
2276
|
+
}
|
|
2277
|
+
function arraysEqual(as, bs) {
|
|
2278
|
+
if (as.length !== bs.length) {
|
|
2279
|
+
return false;
|
|
2280
|
+
}
|
|
2281
|
+
for (let i = 0; i < as.length; i++) {
|
|
2282
|
+
if (as[i] !== bs[i]) {
|
|
2283
|
+
return false;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
return true;
|
|
2287
|
+
}
|
|
2288
|
+
function findGroups(type, groups) {
|
|
2289
|
+
return groups.groups.filter((g) => g.type === type);
|
|
2290
|
+
}
|
|
2291
|
+
function flatMap(xs, fn) {
|
|
2292
|
+
const ret = new Array();
|
|
2293
|
+
for (const x of xs) {
|
|
2294
|
+
ret.push(...fn(x));
|
|
2295
|
+
}
|
|
2296
|
+
return ret;
|
|
2297
|
+
}
|
|
2298
|
+
function collapse(xs) {
|
|
2299
|
+
if (xs.length > 0) {
|
|
2300
|
+
return xs;
|
|
2301
|
+
}
|
|
2302
|
+
return void 0;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// lib/api/settings.ts
|
|
2306
|
+
var fs5 = __toESM(require("fs-extra"));
|
|
2307
|
+
|
|
2308
|
+
// lib/api/notices.ts
|
|
2309
|
+
var path4 = __toESM(require("path"));
|
|
2310
|
+
var fs7 = __toESM(require("fs-extra"));
|
|
2311
|
+
var semver2 = __toESM(require("semver"));
|
|
2312
|
+
|
|
2313
|
+
// lib/api/tree.ts
|
|
2314
|
+
var fs6 = __toESM(require("fs-extra"));
|
|
2315
|
+
|
|
2316
|
+
// lib/api/notices.ts
|
|
2317
|
+
var CACHE_FILE_PATH = path4.join(cdkCacheDir(), "notices.json");
|
|
2318
|
+
var TIME_TO_LIVE_SUCCESS = 60 * 60 * 1e3;
|
|
2319
|
+
var TIME_TO_LIVE_ERROR = 1 * 60 * 1e3;
|
|
2320
|
+
|
|
2321
|
+
// lib/api/toolkit-info.ts
|
|
2322
|
+
var chalk4 = __toESM(require("chalk"));
|
|
2323
|
+
|
|
2324
|
+
// lib/api/deployments/cfn-api.ts
|
|
2325
|
+
var cxapi = __toESM(require("@aws-cdk/cx-api"));
|
|
2326
|
+
var import_cx_api5 = require("@aws-cdk/cx-api");
|
|
2327
|
+
var import_client_cloudformation3 = require("@aws-sdk/client-cloudformation");
|
|
2328
|
+
var import_cdk_assets2 = require("cdk-assets");
|
|
2329
|
+
|
|
2330
|
+
// lib/api/deployments/asset-manifest-builder.ts
|
|
2331
|
+
var cxschema = __toESM(require("@aws-cdk/cloud-assembly-schema"));
|
|
2332
|
+
var import_cdk_assets = require("cdk-assets");
|
|
2333
|
+
|
|
2334
|
+
// lib/api/cloudformation/template-body-parameter.ts
|
|
2335
|
+
var import_cx_api4 = require("@aws-cdk/cx-api");
|
|
2336
|
+
var import_client_s32 = require("@aws-sdk/client-s3");
|
|
2337
|
+
var import_middleware_endpoint2 = require("@smithy/middleware-endpoint");
|
|
2338
|
+
var chalk3 = __toESM(require("chalk"));
|
|
2339
|
+
|
|
2340
|
+
// lib/api/cloudformation/nested-stack-helpers.ts
|
|
2341
|
+
var fs8 = __toESM(require("fs-extra"));
|
|
2342
|
+
|
|
2343
|
+
// lib/api/stack-events/stack-activity-monitor.ts
|
|
2344
|
+
var uuid = __toESM(require("uuid"));
|
|
2345
|
+
|
|
2346
|
+
// lib/api/stack-events/stack-status.ts
|
|
2347
|
+
var import_client_cloudformation2 = require("@aws-sdk/client-cloudformation");
|
|
2348
|
+
|
|
2349
|
+
// lib/api/environment/placeholders.ts
|
|
2350
|
+
var import_cx_api6 = require("@aws-cdk/cx-api");
|
|
2351
|
+
|
|
2352
|
+
// lib/context-providers/index.ts
|
|
2353
|
+
var availableContextProviders = {
|
|
2354
|
+
[cxschema2.ContextProvider.AVAILABILITY_ZONE_PROVIDER]: (s, io) => new AZContextProviderPlugin(s, io),
|
|
2355
|
+
[cxschema2.ContextProvider.SSM_PARAMETER_PROVIDER]: (s, io) => new SSMContextProviderPlugin(s, io),
|
|
2356
|
+
[cxschema2.ContextProvider.HOSTED_ZONE_PROVIDER]: (s, io) => new HostedZoneContextProviderPlugin(s, io),
|
|
2357
|
+
[cxschema2.ContextProvider.VPC_PROVIDER]: (s, io) => new VpcNetworkContextProviderPlugin(s, io),
|
|
2358
|
+
[cxschema2.ContextProvider.AMI_PROVIDER]: (s, io) => new AmiContextProviderPlugin(s, io),
|
|
2359
|
+
[cxschema2.ContextProvider.ENDPOINT_SERVICE_AVAILABILITY_ZONE_PROVIDER]: (s, io) => new EndpointServiceAZContextProviderPlugin(s, io),
|
|
2360
|
+
[cxschema2.ContextProvider.SECURITY_GROUP_PROVIDER]: (s) => new SecurityGroupContextProviderPlugin(s),
|
|
2361
|
+
[cxschema2.ContextProvider.LOAD_BALANCER_PROVIDER]: (s) => new LoadBalancerContextProviderPlugin(s),
|
|
2362
|
+
[cxschema2.ContextProvider.LOAD_BALANCER_LISTENER_PROVIDER]: (s) => new LoadBalancerListenerContextProviderPlugin(s),
|
|
2363
|
+
[cxschema2.ContextProvider.KEY_PROVIDER]: (s, io) => new KeyContextProviderPlugin(s, io),
|
|
2364
|
+
[cxschema2.ContextProvider.CC_API_PROVIDER]: (s) => new CcApiContextProviderPlugin(s)
|
|
2365
|
+
};
|
|
2366
|
+
|
|
2367
|
+
// lib/api/cloud-assembly/private/stack-assembly.ts
|
|
2368
|
+
var import_semver = require("semver");
|
|
2369
|
+
|
|
2370
|
+
// lib/api/cloud-assembly/stack-assembly.ts
|
|
2371
|
+
var chalk5 = __toESM(require("chalk"));
|
|
2372
|
+
var import_minimatch = require("minimatch");
|
|
2373
|
+
|
|
2374
|
+
// lib/api/cloud-assembly/stack-collection.ts
|
|
2375
|
+
var import_cx_api7 = require("@aws-cdk/cx-api");
|
|
2376
|
+
|
|
2377
|
+
// lib/api/cloud-assembly/private/exec.ts
|
|
2378
|
+
var split = require("split2");
|
|
2379
|
+
|
|
2380
|
+
// lib/api/cloud-assembly/private/prepare-source.ts
|
|
2381
|
+
var cxschema3 = __toESM(require("@aws-cdk/cloud-assembly-schema"));
|
|
2382
|
+
var cxapi4 = __toESM(require("@aws-cdk/cx-api"));
|
|
2383
|
+
var fs10 = __toESM(require("fs-extra"));
|
|
2384
|
+
var import_semver2 = require("semver");
|
|
2385
|
+
|
|
2386
|
+
// lib/api/cloud-assembly/environment.ts
|
|
2387
|
+
var cxapi3 = __toESM(require("@aws-cdk/cx-api"));
|
|
2388
|
+
var fs9 = __toESM(require("fs-extra"));
|
|
2389
|
+
|
|
2390
|
+
// lib/api/cloud-assembly/private/source-builder.ts
|
|
2391
|
+
var cxapi5 = __toESM(require("@aws-cdk/cx-api"));
|
|
2392
|
+
var fs11 = __toESM(require("fs-extra"));
|
|
2393
|
+
|
|
2394
|
+
// lib/api/cloud-assembly/private/stack-selectors.ts
|
|
2395
|
+
var ALL_STACKS = {
|
|
2396
|
+
strategy: "all-stacks" /* ALL_STACKS */
|
|
2397
|
+
};
|
|
2398
|
+
|
|
2399
|
+
// lib/api/io/private/span.ts
|
|
2400
|
+
var util = __toESM(require("node:util"));
|
|
2401
|
+
var uuid2 = __toESM(require("uuid"));
|
|
2402
|
+
var SpanMaker = class {
|
|
2403
|
+
definition;
|
|
2404
|
+
ioHelper;
|
|
2405
|
+
constructor(ioHelper, definition) {
|
|
2406
|
+
this.definition = definition;
|
|
2407
|
+
this.ioHelper = ioHelper;
|
|
2408
|
+
}
|
|
2409
|
+
async begin(a, b) {
|
|
2410
|
+
const spanId = uuid2.v4();
|
|
2411
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
2412
|
+
const notify = (msg) => {
|
|
2413
|
+
return this.ioHelper.notify(withSpanId(spanId, msg));
|
|
2414
|
+
};
|
|
2415
|
+
const startInput = parseArgs(a, b);
|
|
2416
|
+
const startMsg = startInput.message ?? `Starting ${this.definition.name} ...`;
|
|
2417
|
+
const startPayload = startInput.payload;
|
|
2418
|
+
await notify(this.definition.start.msg(
|
|
2419
|
+
startMsg,
|
|
2420
|
+
startPayload
|
|
2421
|
+
));
|
|
2422
|
+
const timingMsgTemplate = "\n\u2728 %s time: %ds\n";
|
|
2423
|
+
const time = () => {
|
|
2424
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - startTime;
|
|
2425
|
+
return {
|
|
2426
|
+
asMs: elapsedTime,
|
|
2427
|
+
asSec: formatTime(elapsedTime)
|
|
2428
|
+
};
|
|
2429
|
+
};
|
|
2430
|
+
return {
|
|
2431
|
+
elapsedTime: async () => {
|
|
2432
|
+
return time();
|
|
2433
|
+
},
|
|
2434
|
+
notify: async (msg) => {
|
|
2435
|
+
await notify(msg);
|
|
2436
|
+
},
|
|
2437
|
+
timing: async (maker, message2) => {
|
|
2438
|
+
const duration = time();
|
|
2439
|
+
const timingMsg = message2 ? message2 : util.format(timingMsgTemplate, this.definition.name, duration.asSec);
|
|
2440
|
+
await notify(maker.msg(timingMsg, {
|
|
2441
|
+
duration: duration.asMs
|
|
2442
|
+
}));
|
|
2443
|
+
return duration;
|
|
2444
|
+
},
|
|
2445
|
+
end: async (x, y) => {
|
|
2446
|
+
const duration = time();
|
|
2447
|
+
const endInput = parseArgs(x, y);
|
|
2448
|
+
const endMsg = endInput.message ?? util.format(timingMsgTemplate, this.definition.name, duration.asSec);
|
|
2449
|
+
const endPayload = endInput.payload;
|
|
2450
|
+
await notify(this.definition.end.msg(
|
|
2451
|
+
endMsg,
|
|
2452
|
+
{
|
|
2453
|
+
duration: duration.asMs,
|
|
2454
|
+
...endPayload
|
|
2455
|
+
}
|
|
2456
|
+
));
|
|
2457
|
+
return duration;
|
|
2458
|
+
}
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
function parseArgs(first, second) {
|
|
2463
|
+
const firstIsMessage = typeof first === "string";
|
|
2464
|
+
const message2 = firstIsMessage || second ? first : void 0;
|
|
2465
|
+
const payload = firstIsMessage || second ? second : first;
|
|
2466
|
+
return {
|
|
2467
|
+
message: message2,
|
|
2468
|
+
payload
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
function withSpanId(span, message2) {
|
|
2472
|
+
return {
|
|
2473
|
+
...message2,
|
|
2474
|
+
span
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
// lib/api/io/private/io-helper.ts
|
|
2479
|
+
var IoHelper = class _IoHelper {
|
|
2480
|
+
static fromIoHost(ioHost, action) {
|
|
2481
|
+
return new _IoHelper(ioHost, action);
|
|
2482
|
+
}
|
|
2483
|
+
ioHost;
|
|
2484
|
+
action;
|
|
2485
|
+
constructor(ioHost, action) {
|
|
2486
|
+
this.ioHost = ioHost;
|
|
2487
|
+
this.action = action;
|
|
2488
|
+
}
|
|
2489
|
+
/**
|
|
2490
|
+
* Forward a message to the IoHost, while injection the current action
|
|
2491
|
+
*/
|
|
2492
|
+
notify(msg) {
|
|
2493
|
+
return this.ioHost.notify({
|
|
2494
|
+
...msg,
|
|
2495
|
+
action: this.action
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
/**
|
|
2499
|
+
* Forward a request to the IoHost, while injection the current action
|
|
2500
|
+
*/
|
|
2501
|
+
requestResponse(msg) {
|
|
2502
|
+
return this.ioHost.requestResponse({
|
|
2503
|
+
...msg,
|
|
2504
|
+
action: this.action
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Create a new marker from a given registry entry
|
|
2509
|
+
*/
|
|
2510
|
+
span(definition) {
|
|
2511
|
+
return new SpanMaker(this, definition);
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
|
|
2515
|
+
// lib/api/io/private/level-priority.ts
|
|
2516
|
+
var levels = [
|
|
2517
|
+
"trace",
|
|
2518
|
+
"debug",
|
|
2519
|
+
"info",
|
|
2520
|
+
"warn",
|
|
2521
|
+
"result",
|
|
2522
|
+
"error"
|
|
2523
|
+
];
|
|
2524
|
+
var orderedLevels = Object.fromEntries(Object.entries(levels).map((a) => a.reverse()));
|
|
2525
|
+
|
|
2526
|
+
// lib/api/io/private/message-maker.ts
|
|
2527
|
+
function message(level, details) {
|
|
2528
|
+
const maker = (text, data) => ({
|
|
2529
|
+
time: /* @__PURE__ */ new Date(),
|
|
2530
|
+
level,
|
|
2531
|
+
code: details.code,
|
|
2532
|
+
message: text,
|
|
2533
|
+
data
|
|
2534
|
+
});
|
|
2535
|
+
return {
|
|
2536
|
+
...details,
|
|
2537
|
+
level,
|
|
2538
|
+
msg: maker,
|
|
2539
|
+
is: (m) => m.code === details.code
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
var trace = (details) => message("trace", details);
|
|
2543
|
+
var debug = (details) => message("debug", details);
|
|
2544
|
+
var info = (details) => message("info", details);
|
|
2545
|
+
var warn = (details) => message("warn", details);
|
|
2546
|
+
var error = (details) => message("error", details);
|
|
2547
|
+
var result = (details) => message("result", details);
|
|
2548
|
+
function request(level, details) {
|
|
2549
|
+
const maker = (text, data) => ({
|
|
2550
|
+
time: /* @__PURE__ */ new Date(),
|
|
2551
|
+
level,
|
|
2552
|
+
code: details.code,
|
|
2553
|
+
message: text,
|
|
2554
|
+
data,
|
|
2555
|
+
defaultResponse: details.defaultResponse
|
|
2556
|
+
});
|
|
2557
|
+
return {
|
|
2558
|
+
...details,
|
|
2559
|
+
level,
|
|
2560
|
+
req: maker
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
var confirm = (details) => request("info", {
|
|
2564
|
+
...details,
|
|
2565
|
+
defaultResponse: true
|
|
2566
|
+
});
|
|
2567
|
+
|
|
2568
|
+
// lib/api/io/private/messages.ts
|
|
2569
|
+
var IO = {
|
|
2570
|
+
// Defaults (0000)
|
|
2571
|
+
DEFAULT_TOOLKIT_INFO: info({
|
|
2572
|
+
code: "CDK_TOOLKIT_I0000",
|
|
2573
|
+
description: "Default info messages emitted from the Toolkit"
|
|
2574
|
+
}),
|
|
2575
|
+
DEFAULT_TOOLKIT_DEBUG: debug({
|
|
2576
|
+
code: "CDK_TOOLKIT_I0000",
|
|
2577
|
+
description: "Default debug messages emitted from the Toolkit"
|
|
2578
|
+
}),
|
|
2579
|
+
DEFAULT_TOOLKIT_WARN: warn({
|
|
2580
|
+
code: "CDK_TOOLKIT_W0000",
|
|
2581
|
+
description: "Default warning messages emitted from the Toolkit"
|
|
2582
|
+
}),
|
|
2583
|
+
DEFAULT_TOOLKIT_ERROR: error({
|
|
2584
|
+
code: "CDK_TOOLKIT_E0000",
|
|
2585
|
+
description: "Default error messages emitted from the Toolkit"
|
|
2586
|
+
}),
|
|
2587
|
+
DEFAULT_TOOLKIT_TRACE: trace({
|
|
2588
|
+
code: "CDK_TOOLKIT_I0000",
|
|
2589
|
+
description: "Default trace messages emitted from the Toolkit"
|
|
2590
|
+
}),
|
|
2591
|
+
// warnings & errors
|
|
2592
|
+
CDK_TOOLKIT_W0100: warn({
|
|
2593
|
+
code: "CDK_TOOLKIT_W0100",
|
|
2594
|
+
description: "Credential plugin warnings"
|
|
2595
|
+
}),
|
|
2596
|
+
// 1: Synth (1xxx)
|
|
2597
|
+
CDK_TOOLKIT_I1000: info({
|
|
2598
|
+
code: "CDK_TOOLKIT_I1000",
|
|
2599
|
+
description: "Provides synthesis times.",
|
|
2600
|
+
interface: "Duration"
|
|
2601
|
+
}),
|
|
2602
|
+
CDK_TOOLKIT_I1001: trace({
|
|
2603
|
+
code: "CDK_TOOLKIT_I1001",
|
|
2604
|
+
description: "Cloud Assembly synthesis is starting",
|
|
2605
|
+
interface: "StackSelectionDetails"
|
|
2606
|
+
}),
|
|
2607
|
+
CDK_TOOLKIT_I1901: result({
|
|
2608
|
+
code: "CDK_TOOLKIT_I1901",
|
|
2609
|
+
description: "Provides stack data",
|
|
2610
|
+
interface: "StackAndAssemblyData"
|
|
2611
|
+
}),
|
|
2612
|
+
CDK_TOOLKIT_I1902: result({
|
|
2613
|
+
code: "CDK_TOOLKIT_I1902",
|
|
2614
|
+
description: "Successfully deployed stacks",
|
|
2615
|
+
interface: "AssemblyData"
|
|
2616
|
+
}),
|
|
2617
|
+
// 2: List (2xxx)
|
|
2618
|
+
CDK_TOOLKIT_I2901: result({
|
|
2619
|
+
code: "CDK_TOOLKIT_I2901",
|
|
2620
|
+
description: "Provides details on the selected stacks and their dependencies",
|
|
2621
|
+
interface: "StackDetailsPayload"
|
|
2622
|
+
}),
|
|
2623
|
+
// 3: Import & Migrate
|
|
2624
|
+
CDK_TOOLKIT_E3900: error({
|
|
2625
|
+
code: "CDK_TOOLKIT_E3900",
|
|
2626
|
+
description: "Resource import failed",
|
|
2627
|
+
interface: "ErrorPayload"
|
|
2628
|
+
}),
|
|
2629
|
+
// 4: Diff (4xxx)
|
|
2630
|
+
CDK_TOOLKIT_I4000: trace({
|
|
2631
|
+
code: "CDK_TOOLKIT_I4000",
|
|
2632
|
+
description: "Diff stacks is starting",
|
|
2633
|
+
interface: "StackSelectionDetails"
|
|
2634
|
+
}),
|
|
2635
|
+
CDK_TOOLKIT_I4001: info({
|
|
2636
|
+
code: "CDK_TOOLKIT_I4001",
|
|
2637
|
+
description: "Output of the diff command",
|
|
2638
|
+
interface: "DiffResult"
|
|
2639
|
+
}),
|
|
2640
|
+
// 5: Deploy & Watch (5xxx)
|
|
2641
|
+
CDK_TOOLKIT_I5000: info({
|
|
2642
|
+
code: "CDK_TOOLKIT_I5000",
|
|
2643
|
+
description: "Provides deployment times",
|
|
2644
|
+
interface: "Duration"
|
|
2645
|
+
}),
|
|
2646
|
+
CDK_TOOLKIT_I5001: info({
|
|
2647
|
+
code: "CDK_TOOLKIT_I5001",
|
|
2648
|
+
description: "Provides total time in deploy action, including synth and rollback",
|
|
2649
|
+
interface: "Duration"
|
|
2650
|
+
}),
|
|
2651
|
+
CDK_TOOLKIT_I5002: info({
|
|
2652
|
+
code: "CDK_TOOLKIT_I5002",
|
|
2653
|
+
description: "Provides time for resource migration",
|
|
2654
|
+
interface: "Duration"
|
|
2655
|
+
}),
|
|
2656
|
+
CDK_TOOLKIT_W5021: warn({
|
|
2657
|
+
code: "CDK_TOOLKIT_W5021",
|
|
2658
|
+
description: "Empty non-existent stack, deployment is skipped"
|
|
2659
|
+
}),
|
|
2660
|
+
CDK_TOOLKIT_W5022: warn({
|
|
2661
|
+
code: "CDK_TOOLKIT_W5022",
|
|
2662
|
+
description: "Empty existing stack, stack will be destroyed"
|
|
2663
|
+
}),
|
|
2664
|
+
CDK_TOOLKIT_I5031: info({
|
|
2665
|
+
code: "CDK_TOOLKIT_I5031",
|
|
2666
|
+
description: "Informs about any log groups that are traced as part of the deployment"
|
|
2667
|
+
}),
|
|
2668
|
+
CDK_TOOLKIT_I5032: debug({
|
|
2669
|
+
code: "CDK_TOOLKIT_I5032",
|
|
2670
|
+
description: "Start monitoring log groups",
|
|
2671
|
+
interface: "CloudWatchLogMonitorControlEvent"
|
|
2672
|
+
}),
|
|
2673
|
+
CDK_TOOLKIT_I5033: info({
|
|
2674
|
+
code: "CDK_TOOLKIT_I5033",
|
|
2675
|
+
description: "A log event received from Cloud Watch",
|
|
2676
|
+
interface: "CloudWatchLogEvent"
|
|
2677
|
+
}),
|
|
2678
|
+
CDK_TOOLKIT_I5034: debug({
|
|
2679
|
+
code: "CDK_TOOLKIT_I5034",
|
|
2680
|
+
description: "Stop monitoring log groups",
|
|
2681
|
+
interface: "CloudWatchLogMonitorControlEvent"
|
|
2682
|
+
}),
|
|
2683
|
+
CDK_TOOLKIT_E5035: error({
|
|
2684
|
+
code: "CDK_TOOLKIT_E5035",
|
|
2685
|
+
description: "A log monitoring error",
|
|
2686
|
+
interface: "ErrorPayload"
|
|
2687
|
+
}),
|
|
2688
|
+
CDK_TOOLKIT_I5050: confirm({
|
|
2689
|
+
code: "CDK_TOOLKIT_I5050",
|
|
2690
|
+
description: "Confirm rollback during deployment",
|
|
2691
|
+
interface: "ConfirmationRequest"
|
|
2692
|
+
}),
|
|
2693
|
+
CDK_TOOLKIT_I5060: confirm({
|
|
2694
|
+
code: "CDK_TOOLKIT_I5060",
|
|
2695
|
+
description: "Confirm deploy security sensitive changes",
|
|
2696
|
+
interface: "DeployConfirmationRequest"
|
|
2697
|
+
}),
|
|
2698
|
+
CDK_TOOLKIT_I5100: info({
|
|
2699
|
+
code: "CDK_TOOLKIT_I5100",
|
|
2700
|
+
description: "Stack deploy progress",
|
|
2701
|
+
interface: "StackDeployProgress"
|
|
2702
|
+
}),
|
|
2703
|
+
// Assets (52xx)
|
|
2704
|
+
CDK_TOOLKIT_I5210: trace({
|
|
2705
|
+
code: "CDK_TOOLKIT_I5210",
|
|
2706
|
+
description: "Started building a specific asset",
|
|
2707
|
+
interface: "BuildAsset"
|
|
2708
|
+
}),
|
|
2709
|
+
CDK_TOOLKIT_I5211: trace({
|
|
2710
|
+
code: "CDK_TOOLKIT_I5211",
|
|
2711
|
+
description: "Building the asset has completed",
|
|
2712
|
+
interface: "Duration"
|
|
2713
|
+
}),
|
|
2714
|
+
CDK_TOOLKIT_I5220: trace({
|
|
2715
|
+
code: "CDK_TOOLKIT_I5220",
|
|
2716
|
+
description: "Started publishing a specific asset",
|
|
2717
|
+
interface: "PublishAsset"
|
|
2718
|
+
}),
|
|
2719
|
+
CDK_TOOLKIT_I5221: trace({
|
|
2720
|
+
code: "CDK_TOOLKIT_I5221",
|
|
2721
|
+
description: "Publishing the asset has completed",
|
|
2722
|
+
interface: "Duration"
|
|
2723
|
+
}),
|
|
2724
|
+
// Watch (53xx)
|
|
2725
|
+
CDK_TOOLKIT_I5310: debug({
|
|
2726
|
+
code: "CDK_TOOLKIT_I5310",
|
|
2727
|
+
description: "The computed settings used for file watching",
|
|
2728
|
+
interface: "WatchSettings"
|
|
2729
|
+
}),
|
|
2730
|
+
CDK_TOOLKIT_I5311: info({
|
|
2731
|
+
code: "CDK_TOOLKIT_I5311",
|
|
2732
|
+
description: "File watching started",
|
|
2733
|
+
interface: "FileWatchEvent"
|
|
2734
|
+
}),
|
|
2735
|
+
CDK_TOOLKIT_I5312: info({
|
|
2736
|
+
code: "CDK_TOOLKIT_I5312",
|
|
2737
|
+
description: "File event detected, starting deployment",
|
|
2738
|
+
interface: "FileWatchEvent"
|
|
2739
|
+
}),
|
|
2740
|
+
CDK_TOOLKIT_I5313: info({
|
|
2741
|
+
code: "CDK_TOOLKIT_I5313",
|
|
2742
|
+
description: "File event detected during active deployment, changes are queued",
|
|
2743
|
+
interface: "FileWatchEvent"
|
|
2744
|
+
}),
|
|
2745
|
+
CDK_TOOLKIT_I5314: info({
|
|
2746
|
+
code: "CDK_TOOLKIT_I5314",
|
|
2747
|
+
description: "Initial watch deployment started"
|
|
2748
|
+
}),
|
|
2749
|
+
CDK_TOOLKIT_I5315: info({
|
|
2750
|
+
code: "CDK_TOOLKIT_I5315",
|
|
2751
|
+
description: "Queued watch deployment started"
|
|
2752
|
+
}),
|
|
2753
|
+
// Hotswap (54xx)
|
|
2754
|
+
CDK_TOOLKIT_I5400: trace({
|
|
2755
|
+
code: "CDK_TOOLKIT_I5400",
|
|
2756
|
+
description: "Attempting a hotswap deployment",
|
|
2757
|
+
interface: "HotswapDeploymentAttempt"
|
|
2758
|
+
}),
|
|
2759
|
+
CDK_TOOLKIT_I5401: trace({
|
|
2760
|
+
code: "CDK_TOOLKIT_I5401",
|
|
2761
|
+
description: "Computed details for the hotswap deployment",
|
|
2762
|
+
interface: "HotswapDeploymentDetails"
|
|
2763
|
+
}),
|
|
2764
|
+
CDK_TOOLKIT_I5402: info({
|
|
2765
|
+
code: "CDK_TOOLKIT_I5402",
|
|
2766
|
+
description: "A hotswappable change is processed as part of a hotswap deployment",
|
|
2767
|
+
interface: "HotswappableChange"
|
|
2768
|
+
}),
|
|
2769
|
+
CDK_TOOLKIT_I5403: info({
|
|
2770
|
+
code: "CDK_TOOLKIT_I5403",
|
|
2771
|
+
description: "The hotswappable change has completed processing",
|
|
2772
|
+
interface: "HotswappableChange"
|
|
2773
|
+
}),
|
|
2774
|
+
CDK_TOOLKIT_I5410: info({
|
|
2775
|
+
code: "CDK_TOOLKIT_I5410",
|
|
2776
|
+
description: "Hotswap deployment has ended, a full deployment might still follow if needed",
|
|
2777
|
+
interface: "HotswapResult"
|
|
2778
|
+
}),
|
|
2779
|
+
// Stack Monitor (55xx)
|
|
2780
|
+
CDK_TOOLKIT_I5501: info({
|
|
2781
|
+
code: "CDK_TOOLKIT_I5501",
|
|
2782
|
+
description: "Stack Monitoring: Start monitoring of a single stack",
|
|
2783
|
+
interface: "StackMonitoringControlEvent"
|
|
2784
|
+
}),
|
|
2785
|
+
CDK_TOOLKIT_I5502: info({
|
|
2786
|
+
code: "CDK_TOOLKIT_I5502",
|
|
2787
|
+
description: "Stack Monitoring: Activity event for a single stack",
|
|
2788
|
+
interface: "StackActivity"
|
|
2789
|
+
}),
|
|
2790
|
+
CDK_TOOLKIT_I5503: info({
|
|
2791
|
+
code: "CDK_TOOLKIT_I5503",
|
|
2792
|
+
description: "Stack Monitoring: Finished monitoring of a single stack",
|
|
2793
|
+
interface: "StackMonitoringControlEvent"
|
|
2794
|
+
}),
|
|
2795
|
+
// Success (59xx)
|
|
2796
|
+
CDK_TOOLKIT_I5900: result({
|
|
2797
|
+
code: "CDK_TOOLKIT_I5900",
|
|
2798
|
+
description: "Deployment results on success",
|
|
2799
|
+
interface: "SuccessfulDeployStackResult"
|
|
2800
|
+
}),
|
|
2801
|
+
CDK_TOOLKIT_I5901: info({
|
|
2802
|
+
code: "CDK_TOOLKIT_I5901",
|
|
2803
|
+
description: "Generic deployment success messages"
|
|
2804
|
+
}),
|
|
2805
|
+
CDK_TOOLKIT_W5400: warn({
|
|
2806
|
+
code: "CDK_TOOLKIT_W5400",
|
|
2807
|
+
description: "Hotswap disclosure message"
|
|
2808
|
+
}),
|
|
2809
|
+
CDK_TOOLKIT_E5001: error({
|
|
2810
|
+
code: "CDK_TOOLKIT_E5001",
|
|
2811
|
+
description: "No stacks found"
|
|
2812
|
+
}),
|
|
2813
|
+
CDK_TOOLKIT_E5500: error({
|
|
2814
|
+
code: "CDK_TOOLKIT_E5500",
|
|
2815
|
+
description: "Stack Monitoring error",
|
|
2816
|
+
interface: "ErrorPayload"
|
|
2817
|
+
}),
|
|
2818
|
+
// 6: Rollback (6xxx)
|
|
2819
|
+
CDK_TOOLKIT_I6000: info({
|
|
2820
|
+
code: "CDK_TOOLKIT_I6000",
|
|
2821
|
+
description: "Provides rollback times",
|
|
2822
|
+
interface: "Duration"
|
|
2823
|
+
}),
|
|
2824
|
+
CDK_TOOLKIT_I6100: info({
|
|
2825
|
+
code: "CDK_TOOLKIT_I6100",
|
|
2826
|
+
description: "Stack rollback progress",
|
|
2827
|
+
interface: "StackRollbackProgress"
|
|
2828
|
+
}),
|
|
2829
|
+
CDK_TOOLKIT_E6001: error({
|
|
2830
|
+
code: "CDK_TOOLKIT_E6001",
|
|
2831
|
+
description: "No stacks found"
|
|
2832
|
+
}),
|
|
2833
|
+
CDK_TOOLKIT_E6900: error({
|
|
2834
|
+
code: "CDK_TOOLKIT_E6900",
|
|
2835
|
+
description: "Rollback failed",
|
|
2836
|
+
interface: "ErrorPayload"
|
|
2837
|
+
}),
|
|
2838
|
+
// 7: Destroy (7xxx)
|
|
2839
|
+
CDK_TOOLKIT_I7000: info({
|
|
2840
|
+
code: "CDK_TOOLKIT_I7000",
|
|
2841
|
+
description: "Provides destroy times",
|
|
2842
|
+
interface: "Duration"
|
|
2843
|
+
}),
|
|
2844
|
+
CDK_TOOLKIT_I7001: trace({
|
|
2845
|
+
code: "CDK_TOOLKIT_I7001",
|
|
2846
|
+
description: "Provides destroy time for a single stack",
|
|
2847
|
+
interface: "Duration"
|
|
2848
|
+
}),
|
|
2849
|
+
CDK_TOOLKIT_I7010: confirm({
|
|
2850
|
+
code: "CDK_TOOLKIT_I7010",
|
|
2851
|
+
description: "Confirm destroy stacks",
|
|
2852
|
+
interface: "ConfirmationRequest"
|
|
2853
|
+
}),
|
|
2854
|
+
CDK_TOOLKIT_I7100: info({
|
|
2855
|
+
code: "CDK_TOOLKIT_I7100",
|
|
2856
|
+
description: "Stack destroy progress",
|
|
2857
|
+
interface: "StackDestroyProgress"
|
|
2858
|
+
}),
|
|
2859
|
+
CDK_TOOLKIT_I7101: trace({
|
|
2860
|
+
code: "CDK_TOOLKIT_I7101",
|
|
2861
|
+
description: "Start stack destroying",
|
|
2862
|
+
interface: "StackDestroy"
|
|
2863
|
+
}),
|
|
2864
|
+
CDK_TOOLKIT_I7900: result({
|
|
2865
|
+
code: "CDK_TOOLKIT_I7900",
|
|
2866
|
+
description: "Stack deletion succeeded",
|
|
2867
|
+
interface: "cxapi.CloudFormationStackArtifact"
|
|
2868
|
+
}),
|
|
2869
|
+
CDK_TOOLKIT_E7010: error({
|
|
2870
|
+
code: "CDK_TOOLKIT_E7010",
|
|
2871
|
+
description: "Action was aborted due to negative confirmation of request"
|
|
2872
|
+
}),
|
|
2873
|
+
CDK_TOOLKIT_E7900: error({
|
|
2874
|
+
code: "CDK_TOOLKIT_E7900",
|
|
2875
|
+
description: "Stack deletion failed",
|
|
2876
|
+
interface: "ErrorPayload"
|
|
2877
|
+
}),
|
|
2878
|
+
// 8. Refactor (8xxx)
|
|
2879
|
+
CDK_TOOLKIT_I8900: result({
|
|
2880
|
+
code: "CDK_TOOLKIT_I8900",
|
|
2881
|
+
description: "Refactor result",
|
|
2882
|
+
interface: "RefactorResult"
|
|
2883
|
+
}),
|
|
2884
|
+
CDK_TOOLKIT_W8010: warn({
|
|
2885
|
+
code: "CDK_TOOLKIT_W8010",
|
|
2886
|
+
description: "Refactor execution not yet supported"
|
|
2887
|
+
}),
|
|
2888
|
+
// 9: Bootstrap (9xxx)
|
|
2889
|
+
CDK_TOOLKIT_I9000: info({
|
|
2890
|
+
code: "CDK_TOOLKIT_I9000",
|
|
2891
|
+
description: "Provides bootstrap times",
|
|
2892
|
+
interface: "Duration"
|
|
2893
|
+
}),
|
|
2894
|
+
CDK_TOOLKIT_I9100: info({
|
|
2895
|
+
code: "CDK_TOOLKIT_I9100",
|
|
2896
|
+
description: "Bootstrap progress",
|
|
2897
|
+
interface: "BootstrapEnvironmentProgress"
|
|
2898
|
+
}),
|
|
2899
|
+
CDK_TOOLKIT_I9900: result({
|
|
2900
|
+
code: "CDK_TOOLKIT_I9900",
|
|
2901
|
+
description: "Bootstrap results on success",
|
|
2902
|
+
interface: "cxapi.Environment"
|
|
2903
|
+
}),
|
|
2904
|
+
CDK_TOOLKIT_E9900: error({
|
|
2905
|
+
code: "CDK_TOOLKIT_E9900",
|
|
2906
|
+
description: "Bootstrap failed",
|
|
2907
|
+
interface: "ErrorPayload"
|
|
2908
|
+
}),
|
|
2909
|
+
// Notices
|
|
2910
|
+
CDK_TOOLKIT_I0100: info({
|
|
2911
|
+
code: "CDK_TOOLKIT_I0100",
|
|
2912
|
+
description: "Notices decoration (the header or footer of a list of notices)"
|
|
2913
|
+
}),
|
|
2914
|
+
CDK_TOOLKIT_W0101: warn({
|
|
2915
|
+
code: "CDK_TOOLKIT_W0101",
|
|
2916
|
+
description: "A notice that is marked as a warning"
|
|
2917
|
+
}),
|
|
2918
|
+
CDK_TOOLKIT_E0101: error({
|
|
2919
|
+
code: "CDK_TOOLKIT_E0101",
|
|
2920
|
+
description: "A notice that is marked as an error"
|
|
2921
|
+
}),
|
|
2922
|
+
CDK_TOOLKIT_I0101: info({
|
|
2923
|
+
code: "CDK_TOOLKIT_I0101",
|
|
2924
|
+
description: "A notice that is marked as informational"
|
|
2925
|
+
}),
|
|
2926
|
+
// Assembly codes
|
|
2927
|
+
DEFAULT_ASSEMBLY_TRACE: trace({
|
|
2928
|
+
code: "CDK_ASSEMBLY_I0000",
|
|
2929
|
+
description: "Default trace messages emitted from Cloud Assembly operations"
|
|
2930
|
+
}),
|
|
2931
|
+
DEFAULT_ASSEMBLY_DEBUG: debug({
|
|
2932
|
+
code: "CDK_ASSEMBLY_I0000",
|
|
2933
|
+
description: "Default debug messages emitted from Cloud Assembly operations"
|
|
2934
|
+
}),
|
|
2935
|
+
DEFAULT_ASSEMBLY_INFO: info({
|
|
2936
|
+
code: "CDK_ASSEMBLY_I0000",
|
|
2937
|
+
description: "Default info messages emitted from Cloud Assembly operations"
|
|
2938
|
+
}),
|
|
2939
|
+
DEFAULT_ASSEMBLY_WARN: warn({
|
|
2940
|
+
code: "CDK_ASSEMBLY_W0000",
|
|
2941
|
+
description: "Default warning messages emitted from Cloud Assembly operations"
|
|
2942
|
+
}),
|
|
2943
|
+
CDK_ASSEMBLY_I0010: debug({
|
|
2944
|
+
code: "CDK_ASSEMBLY_I0010",
|
|
2945
|
+
description: "Generic environment preparation debug messages"
|
|
2946
|
+
}),
|
|
2947
|
+
CDK_ASSEMBLY_W0010: warn({
|
|
2948
|
+
code: "CDK_ASSEMBLY_W0010",
|
|
2949
|
+
description: "Emitted if the found framework version does not support context overflow"
|
|
2950
|
+
}),
|
|
2951
|
+
CDK_ASSEMBLY_I0042: debug({
|
|
2952
|
+
code: "CDK_ASSEMBLY_I0042",
|
|
2953
|
+
description: "Writing updated context",
|
|
2954
|
+
interface: "UpdatedContext"
|
|
2955
|
+
}),
|
|
2956
|
+
CDK_ASSEMBLY_I0240: debug({
|
|
2957
|
+
code: "CDK_ASSEMBLY_I0240",
|
|
2958
|
+
description: "Context lookup was stopped as no further progress was made. ",
|
|
2959
|
+
interface: "MissingContext"
|
|
2960
|
+
}),
|
|
2961
|
+
CDK_ASSEMBLY_I0241: debug({
|
|
2962
|
+
code: "CDK_ASSEMBLY_I0241",
|
|
2963
|
+
description: "Fetching missing context. This is an iterative message that may appear multiple times with different missing keys.",
|
|
2964
|
+
interface: "MissingContext"
|
|
2965
|
+
}),
|
|
2966
|
+
CDK_ASSEMBLY_I1000: debug({
|
|
2967
|
+
code: "CDK_ASSEMBLY_I1000",
|
|
2968
|
+
description: "Cloud assembly output starts"
|
|
2969
|
+
}),
|
|
2970
|
+
CDK_ASSEMBLY_I1001: info({
|
|
2971
|
+
code: "CDK_ASSEMBLY_I1001",
|
|
2972
|
+
description: "Output lines emitted by the cloud assembly to stdout"
|
|
2973
|
+
}),
|
|
2974
|
+
CDK_ASSEMBLY_E1002: error({
|
|
2975
|
+
code: "CDK_ASSEMBLY_E1002",
|
|
2976
|
+
description: "Output lines emitted by the cloud assembly to stderr"
|
|
2977
|
+
}),
|
|
2978
|
+
CDK_ASSEMBLY_I1003: info({
|
|
2979
|
+
code: "CDK_ASSEMBLY_I1003",
|
|
2980
|
+
description: "Cloud assembly output finished"
|
|
2981
|
+
}),
|
|
2982
|
+
CDK_ASSEMBLY_E1111: error({
|
|
2983
|
+
code: "CDK_ASSEMBLY_E1111",
|
|
2984
|
+
description: "Incompatible CDK CLI version. Upgrade needed.",
|
|
2985
|
+
interface: "ErrorPayload"
|
|
2986
|
+
}),
|
|
2987
|
+
CDK_ASSEMBLY_I0150: debug({
|
|
2988
|
+
code: "CDK_ASSEMBLY_I0150",
|
|
2989
|
+
description: "Indicates the use of a pre-synthesized cloud assembly directory"
|
|
2990
|
+
}),
|
|
2991
|
+
CDK_ASSEMBLY_I0300: info({
|
|
2992
|
+
code: "CDK_ASSEMBLY_I0300",
|
|
2993
|
+
description: "An info message emitted by a Context Provider",
|
|
2994
|
+
interface: "ContextProviderMessageSource"
|
|
2995
|
+
}),
|
|
2996
|
+
CDK_ASSEMBLY_I0301: debug({
|
|
2997
|
+
code: "CDK_ASSEMBLY_I0301",
|
|
2998
|
+
description: "A debug message emitted by a Context Provider",
|
|
2999
|
+
interface: "ContextProviderMessageSource"
|
|
3000
|
+
}),
|
|
3001
|
+
// Assembly Annotations
|
|
3002
|
+
CDK_ASSEMBLY_I9999: info({
|
|
3003
|
+
code: "CDK_ASSEMBLY_I9999",
|
|
3004
|
+
description: "Annotations emitted by the cloud assembly",
|
|
3005
|
+
interface: "cxapi.SynthesisMessage"
|
|
3006
|
+
}),
|
|
3007
|
+
CDK_ASSEMBLY_W9999: warn({
|
|
3008
|
+
code: "CDK_ASSEMBLY_W9999",
|
|
3009
|
+
description: "Warnings emitted by the cloud assembly",
|
|
3010
|
+
interface: "cxapi.SynthesisMessage"
|
|
3011
|
+
}),
|
|
3012
|
+
CDK_ASSEMBLY_E9999: error({
|
|
3013
|
+
code: "CDK_ASSEMBLY_E9999",
|
|
3014
|
+
description: "Errors emitted by the cloud assembly",
|
|
3015
|
+
interface: "cxapi.SynthesisMessage"
|
|
3016
|
+
}),
|
|
3017
|
+
// SDK codes
|
|
3018
|
+
DEFAULT_SDK_TRACE: trace({
|
|
3019
|
+
code: "CDK_SDK_I0000",
|
|
3020
|
+
description: "An SDK trace message."
|
|
3021
|
+
}),
|
|
3022
|
+
DEFAULT_SDK_DEBUG: debug({
|
|
3023
|
+
code: "CDK_SDK_I0000",
|
|
3024
|
+
description: "An SDK debug message."
|
|
3025
|
+
}),
|
|
3026
|
+
DEFAULT_SDK_WARN: warn({
|
|
3027
|
+
code: "CDK_SDK_W0000",
|
|
3028
|
+
description: "An SDK warning message."
|
|
3029
|
+
}),
|
|
3030
|
+
CDK_SDK_I0100: trace({
|
|
3031
|
+
code: "CDK_SDK_I0100",
|
|
3032
|
+
description: "An SDK trace. SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level.",
|
|
3033
|
+
interface: "SdkTrace"
|
|
3034
|
+
})
|
|
3035
|
+
};
|
|
3036
|
+
var SPAN = {
|
|
3037
|
+
SYNTH_ASSEMBLY: {
|
|
3038
|
+
name: "Synthesis",
|
|
3039
|
+
start: IO.CDK_TOOLKIT_I1001,
|
|
3040
|
+
end: IO.CDK_TOOLKIT_I1000
|
|
3041
|
+
},
|
|
3042
|
+
DEPLOY_STACK: {
|
|
3043
|
+
name: "Deployment",
|
|
3044
|
+
start: IO.CDK_TOOLKIT_I5100,
|
|
3045
|
+
end: IO.CDK_TOOLKIT_I5001
|
|
3046
|
+
},
|
|
3047
|
+
ROLLBACK_STACK: {
|
|
3048
|
+
name: "Rollback",
|
|
3049
|
+
start: IO.CDK_TOOLKIT_I6100,
|
|
3050
|
+
end: IO.CDK_TOOLKIT_I6000
|
|
3051
|
+
},
|
|
3052
|
+
DIFF_STACK: {
|
|
3053
|
+
name: "Diff",
|
|
3054
|
+
start: IO.CDK_TOOLKIT_I4000,
|
|
3055
|
+
end: IO.CDK_TOOLKIT_I4001
|
|
3056
|
+
},
|
|
3057
|
+
DESTROY_STACK: {
|
|
3058
|
+
name: "Destroy",
|
|
3059
|
+
start: IO.CDK_TOOLKIT_I7100,
|
|
3060
|
+
end: IO.CDK_TOOLKIT_I7001
|
|
3061
|
+
},
|
|
3062
|
+
DESTROY_ACTION: {
|
|
3063
|
+
name: "Destroy",
|
|
3064
|
+
start: IO.CDK_TOOLKIT_I7101,
|
|
3065
|
+
end: IO.CDK_TOOLKIT_I7000
|
|
3066
|
+
},
|
|
3067
|
+
BOOTSTRAP_SINGLE: {
|
|
3068
|
+
name: "Bootstrap",
|
|
3069
|
+
start: IO.CDK_TOOLKIT_I9100,
|
|
3070
|
+
end: IO.CDK_TOOLKIT_I9000
|
|
3071
|
+
},
|
|
3072
|
+
BUILD_ASSET: {
|
|
3073
|
+
name: "Build Asset",
|
|
3074
|
+
start: IO.CDK_TOOLKIT_I5210,
|
|
3075
|
+
end: IO.CDK_TOOLKIT_I5211
|
|
3076
|
+
},
|
|
3077
|
+
PUBLISH_ASSET: {
|
|
3078
|
+
name: "Publish Asset",
|
|
3079
|
+
start: IO.CDK_TOOLKIT_I5220,
|
|
3080
|
+
end: IO.CDK_TOOLKIT_I5221
|
|
3081
|
+
},
|
|
3082
|
+
HOTSWAP: {
|
|
3083
|
+
name: "hotswap-deployment",
|
|
3084
|
+
start: IO.CDK_TOOLKIT_I5400,
|
|
3085
|
+
end: IO.CDK_TOOLKIT_I5410
|
|
3086
|
+
}
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
// lib/api/io/private/io-default-messages.ts
|
|
3090
|
+
var util2 = __toESM(require("util"));
|
|
3091
|
+
var IoDefaultMessages = class {
|
|
3092
|
+
constructor(ioHelper) {
|
|
3093
|
+
this.ioHelper = ioHelper;
|
|
3094
|
+
}
|
|
3095
|
+
notify(msg) {
|
|
3096
|
+
return this.ioHelper.notify(msg);
|
|
3097
|
+
}
|
|
3098
|
+
requestResponse(msg) {
|
|
3099
|
+
return this.ioHelper.requestResponse(msg);
|
|
3100
|
+
}
|
|
3101
|
+
error(input, ...args) {
|
|
3102
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_ERROR, input, ...args);
|
|
3103
|
+
}
|
|
3104
|
+
warn(input, ...args) {
|
|
3105
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
|
|
3106
|
+
}
|
|
3107
|
+
warning(input, ...args) {
|
|
3108
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
|
|
3109
|
+
}
|
|
3110
|
+
info(input, ...args) {
|
|
3111
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_INFO, input, ...args);
|
|
3112
|
+
}
|
|
3113
|
+
debug(input, ...args) {
|
|
3114
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_DEBUG, input, ...args);
|
|
3115
|
+
}
|
|
3116
|
+
trace(input, ...args) {
|
|
3117
|
+
this.emitMessage(IO.DEFAULT_TOOLKIT_TRACE, input, ...args);
|
|
3118
|
+
}
|
|
3119
|
+
result(input, ...args) {
|
|
3120
|
+
const message2 = args.length > 0 ? util2.format(input, ...args) : input;
|
|
3121
|
+
void this.ioHelper.notify({
|
|
3122
|
+
time: /* @__PURE__ */ new Date(),
|
|
3123
|
+
code: IO.DEFAULT_TOOLKIT_INFO.code,
|
|
3124
|
+
level: "result",
|
|
3125
|
+
message: message2,
|
|
3126
|
+
data: void 0
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
emitMessage(maker, input, ...args) {
|
|
3130
|
+
const message2 = args.length > 0 ? util2.format(input, ...args) : input;
|
|
3131
|
+
void this.ioHelper.notify(maker.msg(message2));
|
|
3132
|
+
}
|
|
3133
|
+
};
|
|
3134
|
+
|
|
3135
|
+
// lib/api/plugin/plugin.ts
|
|
3136
|
+
var PluginHost = class {
|
|
3137
|
+
/**
|
|
3138
|
+
* Access the currently registered CredentialProviderSources. New sources can
|
|
3139
|
+
* be registered using the +registerCredentialProviderSource+ method.
|
|
3140
|
+
*/
|
|
3141
|
+
credentialProviderSources = new Array();
|
|
3142
|
+
contextProviderPlugins = {};
|
|
3143
|
+
ioHost;
|
|
3144
|
+
alreadyLoaded = /* @__PURE__ */ new Set();
|
|
3145
|
+
/**
|
|
3146
|
+
* Loads a plug-in into this PluginHost.
|
|
3147
|
+
*
|
|
3148
|
+
* Will use `require.resolve()` to get the most accurate representation of what
|
|
3149
|
+
* code will get loaded in error messages. As such, it will not work in
|
|
3150
|
+
* unit tests with Jest virtual modules becauase of <https://github.com/jestjs/jest/issues/9543>.
|
|
3151
|
+
*
|
|
3152
|
+
* @param moduleSpec the specification (path or name) of the plug-in module to be loaded.
|
|
3153
|
+
* @param ioHost the I/O host to use for printing progress information
|
|
3154
|
+
*/
|
|
3155
|
+
load(moduleSpec, ioHost) {
|
|
3156
|
+
try {
|
|
3157
|
+
const resolved = require.resolve(moduleSpec);
|
|
3158
|
+
if (ioHost) {
|
|
3159
|
+
new IoDefaultMessages(IoHelper.fromIoHost(ioHost, "init")).debug(`Loading plug-in: ${resolved} from ${moduleSpec}`);
|
|
3160
|
+
}
|
|
3161
|
+
return this._doLoad(resolved);
|
|
3162
|
+
} catch (e) {
|
|
3163
|
+
throw new ToolkitError(`Unable to resolve plug-in: Cannot find module '${moduleSpec}': ${e}`);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
/**
|
|
3167
|
+
* Do the loading given an already-resolved module name
|
|
3168
|
+
*
|
|
3169
|
+
* @internal
|
|
3170
|
+
*/
|
|
3171
|
+
_doLoad(resolved) {
|
|
3172
|
+
try {
|
|
3173
|
+
if (this.alreadyLoaded.has(resolved)) {
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
const plugin = require(resolved);
|
|
3177
|
+
if (!isPlugin(plugin)) {
|
|
3178
|
+
throw new ToolkitError(`Module ${resolved} is not a valid plug-in, or has an unsupported version.`);
|
|
3179
|
+
}
|
|
3180
|
+
if (plugin.init) {
|
|
3181
|
+
plugin.init(this);
|
|
3182
|
+
}
|
|
3183
|
+
this.alreadyLoaded.add(resolved);
|
|
3184
|
+
} catch (e) {
|
|
3185
|
+
throw ToolkitError.withCause(`Unable to load plug-in '${resolved}'`, e);
|
|
3186
|
+
}
|
|
3187
|
+
function isPlugin(x) {
|
|
3188
|
+
return x != null && x.version === "1";
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* Allows plug-ins to register new CredentialProviderSources.
|
|
3193
|
+
*
|
|
3194
|
+
* @param source a new CredentialProviderSource to register.
|
|
3195
|
+
*/
|
|
3196
|
+
registerCredentialProviderSource(source) {
|
|
3197
|
+
this.credentialProviderSources.push(source);
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* (EXPERIMENTAL) Allow plugins to register context providers
|
|
3201
|
+
*
|
|
3202
|
+
* Context providers are objects with the following method:
|
|
3203
|
+
*
|
|
3204
|
+
* ```ts
|
|
3205
|
+
* getValue(args: {[key: string]: any}): Promise<any>;
|
|
3206
|
+
* ```
|
|
3207
|
+
*
|
|
3208
|
+
* Currently, they cannot reuse the CDK's authentication mechanisms, so they
|
|
3209
|
+
* must be prepared to either not make AWS calls or use their own source of
|
|
3210
|
+
* AWS credentials.
|
|
3211
|
+
*
|
|
3212
|
+
* This feature is experimental, and only intended to be used internally at Amazon
|
|
3213
|
+
* as a trial.
|
|
3214
|
+
*
|
|
3215
|
+
* After registering with 'my-plugin-name', the provider must be addressed as follows:
|
|
3216
|
+
*
|
|
3217
|
+
* ```ts
|
|
3218
|
+
* const value = ContextProvider.getValue(this, {
|
|
3219
|
+
* providerName: 'plugin',
|
|
3220
|
+
* props: {
|
|
3221
|
+
* pluginName: 'my-plugin-name',
|
|
3222
|
+
* myParameter1: 'xyz',
|
|
3223
|
+
* },
|
|
3224
|
+
* includeEnvironment: true | false,
|
|
3225
|
+
* dummyValue: 'what-to-return-on-the-first-pass',
|
|
3226
|
+
* })
|
|
3227
|
+
* ```
|
|
3228
|
+
*
|
|
3229
|
+
* @experimental
|
|
3230
|
+
*/
|
|
3231
|
+
registerContextProviderAlpha(pluginProviderName, provider) {
|
|
3232
|
+
if (!isContextProviderPlugin(provider)) {
|
|
3233
|
+
throw new ToolkitError(`Object you gave me does not look like a ContextProviderPlugin: ${(0, import_util27.inspect)(provider)}`);
|
|
3234
|
+
}
|
|
3235
|
+
this.contextProviderPlugins[pluginProviderName] = provider;
|
|
3236
|
+
}
|
|
3237
|
+
};
|
|
3238
|
+
|
|
3239
|
+
// lib/payloads/diff.ts
|
|
152
3240
|
var PermissionChangeType = /* @__PURE__ */ ((PermissionChangeType2) => {
|
|
153
3241
|
PermissionChangeType2["NONE"] = "none";
|
|
154
3242
|
PermissionChangeType2["BROADENING"] = "broadening";
|
|
@@ -156,7 +3244,7 @@ var PermissionChangeType = /* @__PURE__ */ ((PermissionChangeType2) => {
|
|
|
156
3244
|
return PermissionChangeType2;
|
|
157
3245
|
})(PermissionChangeType || {});
|
|
158
3246
|
|
|
159
|
-
//
|
|
3247
|
+
// lib/payloads/hotswap.ts
|
|
160
3248
|
var NonHotswappableReason = /* @__PURE__ */ ((NonHotswappableReason2) => {
|
|
161
3249
|
NonHotswappableReason2["TAGS"] = "tags";
|
|
162
3250
|
NonHotswappableReason2["PROPERTIES"] = "properties";
|
|
@@ -173,9 +3261,11 @@ var NonHotswappableReason = /* @__PURE__ */ ((NonHotswappableReason2) => {
|
|
|
173
3261
|
0 && (module.exports = {
|
|
174
3262
|
AssemblyError,
|
|
175
3263
|
AuthenticationError,
|
|
3264
|
+
ContextProviderError,
|
|
176
3265
|
ExpandStackSelection,
|
|
177
3266
|
NonHotswappableReason,
|
|
178
3267
|
PermissionChangeType,
|
|
3268
|
+
PluginHost,
|
|
179
3269
|
StackSelectionStrategy,
|
|
180
3270
|
ToolkitError
|
|
181
3271
|
});
|