@empire-builder-kit/nx 1.0.0-rc.30 → 1.0.0-rc.32
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/executors.json +8 -3
- package/package.json +14 -7
- package/src/aws/child-environment.d.ts +10 -0
- package/src/aws/child-environment.js +77 -0
- package/src/aws/child-environment.js.map +1 -0
- package/src/aws/identity.d.ts +13 -0
- package/src/aws/identity.js +41 -0
- package/src/aws/identity.js.map +1 -0
- package/src/aws-authority/index.d.ts +1 -0
- package/src/aws-authority/index.js +5 -0
- package/src/aws-authority/index.js.map +1 -0
- package/src/aws-authority/stage-authority.d.ts +240 -0
- package/src/aws-authority/stage-authority.js +2968 -0
- package/src/aws-authority/stage-authority.js.map +1 -0
- package/src/cli/main.d.ts +2 -0
- package/src/cli/main.js +11 -0
- package/src/cli/main.js.map +1 -1
- package/src/developer-agent/generator-planning.js +4 -4
- package/src/developer-agent/generator-planning.js.map +1 -1
- package/src/developer-agent/operation-registry.js +14 -6
- package/src/developer-agent/operation-registry.js.map +1 -1
- package/src/developer-agent/workspace-inspection.js +11 -2
- package/src/developer-agent/workspace-inspection.js.map +1 -1
- package/src/executors/deployment-plan/deployment-plan.js +1 -1
- package/src/executors/deployment-plan/deployment-plan.js.map +1 -1
- package/src/executors/foundation-preflight/foundation-preflight.d.ts +0 -1
- package/src/executors/foundation-preflight/foundation-preflight.js.map +1 -1
- package/src/executors/foundation-preflight/schema.json +0 -5
- package/src/executors/foundation-profile-preflight/foundation-profile-preflight.d.ts +12 -3
- package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js +95 -32
- package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js.map +1 -1
- package/src/executors/foundation-profile-preflight/production-database-safeguard.d.ts +64 -0
- package/src/executors/foundation-profile-preflight/production-database-safeguard.js +221 -0
- package/src/executors/foundation-profile-preflight/production-database-safeguard.js.map +1 -0
- package/src/executors/foundation-profile-preflight/schema.json +1 -6
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.d.ts +11 -1
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +44 -21
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js.map +1 -1
- package/src/executors/foundation-remove-preflight/schema.json +6 -1
- package/src/executors/github-bootstrap/github-bootstrap.d.ts +1 -0
- package/src/executors/github-bootstrap/github-bootstrap.js +1 -0
- package/src/executors/github-bootstrap/github-bootstrap.js.map +1 -1
- package/src/executors/github-bootstrap/schema.json +7 -1
- package/src/executors/infrastructure-plan/infrastructure-plan.d.ts +27 -369
- package/src/executors/infrastructure-plan/infrastructure-plan.js +237 -5470
- package/src/executors/infrastructure-plan/infrastructure-plan.js.map +1 -1
- package/src/executors/infrastructure-plan/schema.json +8 -64
- package/src/executors/local-deploy/federated-credential-transport.d.ts +48 -0
- package/src/executors/local-deploy/federated-credential-transport.js +252 -0
- package/src/executors/local-deploy/federated-credential-transport.js.map +1 -0
- package/src/executors/local-deploy/local-approval.d.ts +4 -9
- package/src/executors/local-deploy/local-approval.js +3 -7
- package/src/executors/local-deploy/local-approval.js.map +1 -1
- package/src/executors/local-deploy/local-deploy.d.ts +60 -43
- package/src/executors/local-deploy/local-deploy.js +955 -804
- package/src/executors/local-deploy/local-deploy.js.map +1 -1
- package/src/executors/local-deploy/schema.json +3 -20
- package/src/executors/refresh/refresh.js +2 -2
- package/src/executors/refresh/refresh.js.map +1 -1
- package/src/executors/remove/remove.js +2 -2
- package/src/executors/remove/remove.js.map +1 -1
- package/src/executors/router-waf-rehearsal/router-waf-rehearsal.d.ts +27 -1
- package/src/executors/router-waf-rehearsal/router-waf-rehearsal.js +907 -22
- package/src/executors/router-waf-rehearsal/router-waf-rehearsal.js.map +1 -1
- package/src/executors/router-waf-rehearsal/schema.json +17 -2
- package/src/executors/secret-initialize/schema.json +42 -0
- package/src/executors/secret-initialize/secret-initialize.d.ts +32 -0
- package/src/executors/secret-initialize/secret-initialize.js +243 -0
- package/src/executors/secret-initialize/secret-initialize.js.map +1 -0
- package/src/executors/secret-metadata/secret-metadata.d.ts +4 -1
- package/src/executors/secret-metadata/secret-metadata.js +76 -29
- package/src/executors/secret-metadata/secret-metadata.js.map +1 -1
- package/src/executors/sst-lifecycle/generated-secret-retirement.d.ts +53 -0
- package/src/executors/sst-lifecycle/generated-secret-retirement.js +192 -0
- package/src/executors/sst-lifecycle/generated-secret-retirement.js.map +1 -0
- package/src/executors/sst-lifecycle/governed-native-operation.d.ts +46 -0
- package/src/executors/sst-lifecycle/governed-native-operation.js +153 -0
- package/src/executors/sst-lifecycle/governed-native-operation.js.map +1 -0
- package/src/executors/sst-lifecycle/run-sst-command.d.ts +27 -7
- package/src/executors/sst-lifecycle/run-sst-command.js +474 -89
- package/src/executors/sst-lifecycle/run-sst-command.js.map +1 -1
- package/src/executors/sst-lifecycle/schema.json +0 -5
- package/src/executors/sst-lifecycle/secret-preflight.d.ts +2 -0
- package/src/executors/sst-lifecycle/secret-preflight.js +13 -7
- package/src/executors/sst-lifecycle/secret-preflight.js.map +1 -1
- package/src/executors/unlock/unlock.js +2 -2
- package/src/executors/unlock/unlock.js.map +1 -1
- package/src/foundation/provision-logical-database.js +2 -0
- package/src/foundation/provision-logical-database.js.map +1 -1
- package/src/foundation/router-waf-rate-rehearsal.d.ts +97 -0
- package/src/foundation/router-waf-rate-rehearsal.js +210 -0
- package/src/foundation/router-waf-rate-rehearsal.js.map +1 -0
- package/src/foundation/router-waf.d.ts +59 -9
- package/src/foundation/router-waf.js +427 -32
- package/src/foundation/router-waf.js.map +1 -1
- package/src/foundation/stages.d.ts +1 -0
- package/src/foundation/stages.js +11 -0
- package/src/foundation/stages.js.map +1 -1
- package/src/generators/formatting.d.ts +8 -0
- package/src/generators/formatting.js +118 -0
- package/src/generators/formatting.js.map +1 -0
- package/src/generators/function/function.js +37 -17
- package/src/generators/function/function.js.map +1 -1
- package/src/generators/post-generation-install.js +2 -2
- package/src/generators/post-generation-install.js.map +1 -1
- package/src/generators/preset/generator.js +28 -8
- package/src/generators/preset/generator.js.map +1 -1
- package/src/generators/preset/schema.d.ts +3 -0
- package/src/generators/preset/schema.json +5 -5
- package/src/generators/preset/workspace-files-developer-agent.js +15 -7
- package/src/generators/preset/workspace-files-developer-agent.js.map +1 -1
- package/src/generators/preset/workspace-files-ecr-inspector.d.ts +18 -0
- package/src/generators/preset/workspace-files-ecr-inspector.js +298 -0
- package/src/generators/preset/workspace-files-ecr-inspector.js.map +1 -0
- package/src/generators/preset/workspace-files-performance-cost.d.ts +2 -2
- package/src/generators/preset/workspace-files-performance-cost.js +8 -8
- package/src/generators/preset/workspace-files-performance-cost.js.map +1 -1
- package/src/generators/preset/workspace-files-performance-load.d.ts +1 -1
- package/src/generators/preset/workspace-files-performance-load.js +29 -24
- package/src/generators/preset/workspace-files-performance-load.js.map +1 -1
- package/src/generators/preset/workspace-files-stage-authority.d.ts +6 -0
- package/src/generators/preset/workspace-files-stage-authority.js +479 -0
- package/src/generators/preset/workspace-files-stage-authority.js.map +1 -0
- package/src/generators/preset/workspace-files-thin-deploy.d.ts +40 -0
- package/src/generators/preset/workspace-files-thin-deploy.js +1500 -0
- package/src/generators/preset/workspace-files-thin-deploy.js.map +1 -0
- package/src/generators/preset/workspace-files-thin-docs.d.ts +5 -0
- package/src/generators/preset/workspace-files-thin-docs.js +240 -0
- package/src/generators/preset/workspace-files-thin-docs.js.map +1 -0
- package/src/generators/preset/workspace-files-thin-release.d.ts +14 -0
- package/src/generators/preset/workspace-files-thin-release.js +26 -0
- package/src/generators/preset/workspace-files-thin-release.js.map +1 -0
- package/src/generators/preset/workspace-files.d.ts +2 -1
- package/src/generators/preset/workspace-files.js +448 -680
- package/src/generators/preset/workspace-files.js.map +1 -1
- package/src/generators/repository-policy/repository-policy.js +149 -19
- package/src/generators/repository-policy/repository-policy.js.map +1 -1
- package/src/generators/repository-policy/schema.d.ts +2 -0
- package/src/generators/repository-policy/schema.json +11 -1
- package/src/generators/repository-policy/tree-policy.d.ts +3 -0
- package/src/generators/repository-policy/tree-policy.js +25 -0
- package/src/generators/repository-policy/tree-policy.js.map +1 -0
- package/src/generators/slice/built-in-plan-api-files.js +1 -0
- package/src/generators/slice/built-in-plan-api-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-async-work-files.js +41 -0
- package/src/generators/slice/built-in-plan-async-work-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-authorization-infrastructure-files.js +6 -0
- package/src/generators/slice/built-in-plan-authorization-infrastructure-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-data-export-infrastructure-files.js +5 -31
- package/src/generators/slice/built-in-plan-data-export-infrastructure-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-data-files.d.ts +1 -1
- package/src/generators/slice/built-in-plan-data-files.js +89 -30
- package/src/generators/slice/built-in-plan-data-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.js +19 -0
- package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-data-retention-launcher-files.js +21 -3
- package/src/generators/slice/built-in-plan-data-retention-launcher-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.js +20 -1
- package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-foundation-files.js +3 -5
- package/src/generators/slice/built-in-plan-foundation-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-frontend-files.js +5 -1
- package/src/generators/slice/built-in-plan-frontend-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-infrastructure-files.d.ts +1 -1
- package/src/generators/slice/built-in-plan-infrastructure-files.js +199 -188
- package/src/generators/slice/built-in-plan-infrastructure-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-metadata-files.js +13 -0
- package/src/generators/slice/built-in-plan-metadata-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-native-runtime-authority-files.d.ts +2 -0
- package/src/generators/slice/built-in-plan-native-runtime-authority-files.js +307 -0
- package/src/generators/slice/built-in-plan-native-runtime-authority-files.js.map +1 -0
- package/src/generators/slice/built-in-plan-operations-files.js +65 -51
- package/src/generators/slice/built-in-plan-operations-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-performance-files.js +97 -19
- package/src/generators/slice/built-in-plan-performance-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-project-files.js +9 -68
- package/src/generators/slice/built-in-plan-project-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-secret-runtime-files.d.ts +1 -1
- package/src/generators/slice/built-in-plan-secret-runtime-files.js +87 -76
- package/src/generators/slice/built-in-plan-secret-runtime-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-testing-files.js +94 -47
- package/src/generators/slice/built-in-plan-testing-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-thin-release-files.d.ts +11 -0
- package/src/generators/slice/built-in-plan-thin-release-files.js +129 -0
- package/src/generators/slice/built-in-plan-thin-release-files.js.map +1 -0
- package/src/generators/slice/built-in-plan-verification-files.js +6 -2
- package/src/generators/slice/built-in-plan-verification-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-web-files.js +4 -2
- package/src/generators/slice/built-in-plan-web-files.js.map +1 -1
- package/src/generators/slice/built-in-plan-workload-role-files.js +26 -4
- package/src/generators/slice/built-in-plan-workload-role-files.js.map +1 -1
- package/src/generators/slice/built-in-plan.d.ts +1 -0
- package/src/generators/slice/built-in-plan.js +28 -11
- package/src/generators/slice/built-in-plan.js.map +1 -1
- package/src/generators/slice/slice.js +30 -32
- package/src/generators/slice/slice.js.map +1 -1
- package/src/generators/upgrade/upgrade.d.ts +1 -1
- package/src/generators/upgrade/upgrade.js +200 -48
- package/src/generators/upgrade/upgrade.js.map +1 -1
- package/src/generators/workload/performance-registration.d.ts +1 -0
- package/src/generators/workload/performance-registration.js +9 -11
- package/src/generators/workload/performance-registration.js.map +1 -1
- package/src/generators/workload/service-performance-files.d.ts +1 -0
- package/src/generators/workload/service-performance-files.js +27 -7
- package/src/generators/workload/service-performance-files.js.map +1 -1
- package/src/generators/workload/workload.d.ts +1 -1
- package/src/generators/workload/workload.js +55 -28
- package/src/generators/workload/workload.js.map +1 -1
- package/src/git-policy/github-bootstrap.d.ts +28 -7
- package/src/git-policy/github-bootstrap.js +205 -163
- package/src/git-policy/github-bootstrap.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/local-dev/private-state.d.ts +3 -0
- package/src/local-dev/private-state.js +17 -5
- package/src/local-dev/private-state.js.map +1 -1
- package/src/local-dev/tls.js +5 -1
- package/src/local-dev/tls.js.map +1 -1
- package/src/performance/cost-collection.d.ts +1 -1
- package/src/performance/cost-collection.js +4 -2
- package/src/performance/cost-collection.js.map +1 -1
- package/src/performance/cost-controls.d.ts +3 -1
- package/src/performance/cost-controls.js +9 -4
- package/src/performance/cost-controls.js.map +1 -1
- package/src/performance/evidence.d.ts +1 -1
- package/src/performance/evidence.js +5 -3
- package/src/performance/evidence.js.map +1 -1
- package/src/performance/load-safety.js +5 -3
- package/src/performance/load-safety.js.map +1 -1
- package/src/performance/model.d.ts +2 -2
- package/src/performance/model.js +4 -3
- package/src/performance/model.js.map +1 -1
- package/src/release/index.d.ts +0 -2
- package/src/release/index.js +0 -2
- package/src/release/index.js.map +1 -1
- package/src/release/source-authority.d.ts +4 -5
- package/src/release/source-authority.js +13 -123
- package/src/release/source-authority.js.map +1 -1
- package/src/repository-policy/aurora-preflight.d.ts +1 -1
- package/src/repository-policy/aurora-preflight.js +4 -1
- package/src/repository-policy/aurora-preflight.js.map +1 -1
- package/src/repository-policy/policy.d.ts +21 -2
- package/src/repository-policy/policy.js +290 -25
- package/src/repository-policy/policy.js.map +1 -1
- package/src/schemas/performance-policy-v1.json +3 -1
- package/src/schemas/repository-policy-v1.json +46 -2
- package/src/secrets/adapters.d.ts +7 -2
- package/src/secrets/adapters.js +34 -3
- package/src/secrets/adapters.js.map +1 -1
- package/src/secrets/aws-control-plane.d.ts +10 -1
- package/src/secrets/aws-control-plane.js +67 -0
- package/src/secrets/aws-control-plane.js.map +1 -1
- package/src/secrets/generated-aws-control-plane.d.ts +23 -0
- package/src/secrets/generated-aws-control-plane.js +259 -0
- package/src/secrets/generated-aws-control-plane.js.map +1 -0
- package/src/secrets/metadata.js +38 -10
- package/src/secrets/metadata.js.map +1 -1
- package/src/secrets/model.d.ts +8 -1
- package/src/secrets/model.js +24 -3
- package/src/secrets/model.js.map +1 -1
- package/src/secrets/operator.d.ts +89 -3
- package/src/secrets/operator.js +422 -9
- package/src/secrets/operator.js.map +1 -1
- package/src/secrets/registry.d.ts +2 -1
- package/src/secrets/registry.js +18 -1
- package/src/secrets/registry.js.map +1 -1
- package/src/secrets/workload-access.js +10 -2
- package/src/secrets/workload-access.js.map +1 -1
- package/src/supply-chain/action-pins.js +61 -7
- package/src/supply-chain/action-pins.js.map +1 -1
- package/src/supply-chain/build-output-bounds.d.ts +2 -0
- package/src/supply-chain/build-output-bounds.js +12 -0
- package/src/supply-chain/build-output-bounds.js.map +1 -0
- package/src/supply-chain/build-output.js +2 -4
- package/src/supply-chain/build-output.js.map +1 -1
- package/src/supply-chain/ecr-scanning.d.ts +5 -3
- package/src/supply-chain/ecr-scanning.js +11 -7
- package/src/supply-chain/ecr-scanning.js.map +1 -1
- package/src/supply-chain/ecs-deployed-image.d.ts +5 -3
- package/src/supply-chain/ecs-deployed-image.js +6 -4
- package/src/supply-chain/ecs-deployed-image.js.map +1 -1
- package/src/supply-chain/generated-container-release-command.js +849 -44
- package/src/supply-chain/generated-container-release-command.js.map +1 -1
- package/src/supply-chain/generated-ecr-collector-command.d.ts +0 -1
- package/src/supply-chain/generated-ecr-collector-command.js +188 -91
- package/src/supply-chain/generated-ecr-collector-command.js.map +1 -1
- package/src/supply-chain/generated-files.js +4 -3
- package/src/supply-chain/generated-files.js.map +1 -1
- package/src/supply-chain/index.d.ts +1 -1
- package/src/supply-chain/index.js +2 -1
- package/src/supply-chain/index.js.map +1 -1
- package/src/workload-roles/index.d.ts +10 -17
- package/src/workload-roles/index.js +5 -18
- package/src/workload-roles/index.js.map +1 -1
- package/src/workspace-deployment/identity.d.ts +3 -0
- package/src/workspace-deployment/identity.js +22 -0
- package/src/workspace-deployment/identity.js.map +1 -0
- package/src/workspace-deployment/index.d.ts +3 -0
- package/src/workspace-deployment/index.js +7 -0
- package/src/workspace-deployment/index.js.map +1 -0
- package/src/workspace-deployment/migration-evidence.d.ts +29 -0
- package/src/workspace-deployment/migration-evidence.js +83 -0
- package/src/workspace-deployment/migration-evidence.js.map +1 -0
- package/src/workspace-deployment/migration.d.ts +27 -0
- package/src/workspace-deployment/migration.js +109 -0
- package/src/workspace-deployment/migration.js.map +1 -0
- package/src/workspace-deployment/ownership.d.ts +81 -0
- package/src/workspace-deployment/ownership.js +381 -0
- package/src/workspace-deployment/ownership.js.map +1 -0
|
@@ -9,16 +9,17 @@ const client_sts_1 = require("@aws-sdk/client-sts");
|
|
|
9
9
|
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
10
10
|
const node_path_1 = require("node:path");
|
|
11
11
|
const index_js_1 = require("../../secrets/index.js");
|
|
12
|
+
const index_js_2 = require("../../aws-authority/index.js");
|
|
12
13
|
const secret_preflight_js_1 = require("../sst-lifecycle/secret-preflight.js");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const index_js_3 = require("../../repository-policy/index.js");
|
|
15
|
+
const identity_js_1 = require("../../aws/identity.js");
|
|
16
|
+
const index_js_4 = require("../../workspace-deployment/index.js");
|
|
16
17
|
const ROLE = /^arn:(aws|aws-us-gov|aws-cn):iam::\d{12}:role\/[A-Za-z0-9+=,.@_/-]{1,512}$/;
|
|
17
18
|
function assertSecretMetadataApplyAuthority(stage, apply, environment = process.env, deploymentProfile = 'fully-isolated') {
|
|
18
|
-
if (!apply
|
|
19
|
+
if (!apply)
|
|
19
20
|
return 'none';
|
|
20
21
|
const repository = environment.GITHUB_REPOSITORY;
|
|
21
|
-
const branch = stage === '
|
|
22
|
+
const branch = stage === 'production' ? 'main' : 'develop';
|
|
22
23
|
const ref = `refs/heads/${branch}`;
|
|
23
24
|
const expectedWorkflow = repository
|
|
24
25
|
? `${repository}/.github/workflows/secret-metadata.yml@${ref}`
|
|
@@ -30,12 +31,19 @@ function assertSecretMetadataApplyAuthority(stage, apply, environment = process.
|
|
|
30
31
|
environment.GITHUB_WORKFLOW_REF === expectedWorkflow;
|
|
31
32
|
if (exactWorkflow)
|
|
32
33
|
return 'workflow';
|
|
33
|
-
if ((0,
|
|
34
|
+
if ((0, index_js_3.requiresGithubDeployment)(deploymentProfile, stage) ||
|
|
34
35
|
environment.GITHUB_ACTIONS === 'true') {
|
|
35
36
|
throw new Error(`Protected ${stage} secret metadata apply must run from the ${branch}-branch Secret metadata workflow.`);
|
|
36
37
|
}
|
|
37
38
|
return 'local';
|
|
38
39
|
}
|
|
40
|
+
function partitionForRegion(region) {
|
|
41
|
+
if (region.startsWith('cn-'))
|
|
42
|
+
return 'aws-cn';
|
|
43
|
+
if (region.startsWith('us-gov-'))
|
|
44
|
+
return 'aws-us-gov';
|
|
45
|
+
return 'aws';
|
|
46
|
+
}
|
|
39
47
|
async function readCurrentPrincipal(input) {
|
|
40
48
|
const client = new client_sts_1.STSClient({
|
|
41
49
|
...(input.profile
|
|
@@ -43,6 +51,7 @@ async function readCurrentPrincipal(input) {
|
|
|
43
51
|
credentials: (0, credential_providers_1.fromIni)({ profile: input.profile }),
|
|
44
52
|
}
|
|
45
53
|
: {}),
|
|
54
|
+
endpoint: (0, identity_js_1.canonicalStsEndpoint)(input.region),
|
|
46
55
|
region: input.region,
|
|
47
56
|
});
|
|
48
57
|
const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
|
|
@@ -52,33 +61,32 @@ async function readCurrentPrincipal(input) {
|
|
|
52
61
|
return { accountId: identity.Account, arn: identity.Arn };
|
|
53
62
|
}
|
|
54
63
|
async function assertProtectedSecretMetadataPrincipal(input) {
|
|
55
|
-
if (!input.apply
|
|
64
|
+
if (!input.apply)
|
|
56
65
|
return;
|
|
57
66
|
const expectedAccount = input.environment.AWS_EXPECTED_ACCOUNT_ID;
|
|
58
|
-
const
|
|
67
|
+
const configuredRoleArn = input.environment.AWS_DEPLOY_ROLE_ARN;
|
|
59
68
|
const runId = input.environment.GITHUB_RUN_ID;
|
|
60
69
|
const runAttempt = input.environment.GITHUB_RUN_ATTEMPT;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
role[3] !== expectedAccount ||
|
|
70
|
+
if (!ROLE.test(input.expectedRoleArn) ||
|
|
71
|
+
expectedAccount !== input.accountId ||
|
|
72
|
+
configuredRoleArn !== input.expectedRoleArn ||
|
|
65
73
|
!/^\d+$/.test(runId ?? '') ||
|
|
66
74
|
!/^\d+$/.test(runAttempt ?? '')) {
|
|
67
|
-
throw new Error('Protected secret metadata apply requires
|
|
75
|
+
throw new Error('Protected secret metadata apply requires the exact committed stage deployment role and workflow run identity.');
|
|
68
76
|
}
|
|
69
77
|
let principal;
|
|
70
78
|
try {
|
|
71
79
|
principal = await (input.readPrincipal ?? readCurrentPrincipal)({
|
|
72
|
-
...(input.profile ? { profile: input.profile } : {}),
|
|
73
80
|
region: input.region,
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
catch {
|
|
77
84
|
throw new Error('Protected secret metadata apply could not authenticate its AWS principal.');
|
|
78
85
|
}
|
|
79
|
-
const
|
|
80
|
-
if (principal.accountId !==
|
|
81
|
-
principal.arn
|
|
86
|
+
const expectedSession = `ebk-secret-metadata-${runId}-${runAttempt}`;
|
|
87
|
+
if (principal.accountId !== input.accountId ||
|
|
88
|
+
!(0, identity_js_1.matchesExpectedAssumedRoleArn)(input.accountId, principal.arn, input.expectedRoleArn) ||
|
|
89
|
+
!principal.arn.endsWith(`/${expectedSession}`)) {
|
|
82
90
|
throw new Error('Protected secret metadata apply is not running as the exact reviewed deployment-role session.');
|
|
83
91
|
}
|
|
84
92
|
}
|
|
@@ -99,7 +107,7 @@ async function assertLocalSecretMetadataPrincipal(input) {
|
|
|
99
107
|
throw new Error('Local protected secret metadata apply could not authenticate its AWS principal.');
|
|
100
108
|
}
|
|
101
109
|
if (principal.accountId !== input.accountId ||
|
|
102
|
-
!(0,
|
|
110
|
+
!(0, identity_js_1.matchesExpectedAssumedRoleArn)(input.accountId, principal.arn, expectedRoleArn)) {
|
|
103
111
|
throw new Error('Local protected secret metadata apply is not running in the committed account as the exact temporary assumed role.');
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -118,36 +126,75 @@ function resolveSliceRoot(context) {
|
|
|
118
126
|
async function executeSecretMetadata(options, context, dependencies = {}) {
|
|
119
127
|
const environment = dependencies.environment ?? process.env;
|
|
120
128
|
const apply = options.apply === true;
|
|
121
|
-
const operatingPolicy = apply
|
|
122
|
-
? (dependencies.readOperatingPolicy ??
|
|
129
|
+
const operatingPolicy = apply
|
|
130
|
+
? (dependencies.readOperatingPolicy ?? index_js_3.readRepositoryOperatingPolicy)(context.root)
|
|
123
131
|
: undefined;
|
|
124
132
|
const authority = assertSecretMetadataApplyAuthority(options.stage, apply, environment, operatingPolicy?.deploymentProfile);
|
|
125
133
|
const aws = (0, secret_preflight_js_1.resolveSecretAwsContext)(options, environment);
|
|
134
|
+
let accountId;
|
|
135
|
+
let expectedRoleArn;
|
|
136
|
+
if (apply) {
|
|
137
|
+
if (!operatingPolicy) {
|
|
138
|
+
throw new Error('Secret metadata operating policy is unavailable.');
|
|
139
|
+
}
|
|
140
|
+
if (!(0, index_js_3.isActiveDeploymentStage)(operatingPolicy.deploymentProfile, options.stage)) {
|
|
141
|
+
throw new Error(`Secret metadata stage ${options.stage} is inactive for the ${operatingPolicy.deploymentProfile} deployment profile.`);
|
|
142
|
+
}
|
|
143
|
+
const region = (0, index_js_3.configuredDeploymentRegion)(operatingPolicy.deploymentRegion);
|
|
144
|
+
if (aws.region !== region) {
|
|
145
|
+
throw new Error(`Secret metadata apply requires committed deployment Region ${region}.`);
|
|
146
|
+
}
|
|
147
|
+
accountId = (0, index_js_3.configuredDeploymentAccountForStage)(operatingPolicy.deploymentProfile, operatingPolicy.deploymentAccounts, options.stage);
|
|
148
|
+
expectedRoleArn = (0, index_js_2.createStageAuthorityIdentity)({
|
|
149
|
+
accountId,
|
|
150
|
+
partition: partitionForRegion(region),
|
|
151
|
+
region,
|
|
152
|
+
stage: options.stage,
|
|
153
|
+
}).deploymentRoleArn;
|
|
154
|
+
}
|
|
126
155
|
if (authority === 'workflow') {
|
|
156
|
+
if (accountId === undefined ||
|
|
157
|
+
expectedRoleArn === undefined ||
|
|
158
|
+
options.profile !== undefined ||
|
|
159
|
+
options.expectedRoleArn !== undefined) {
|
|
160
|
+
throw new Error('Protected secret metadata apply uses only its exact OIDC workflow authority.');
|
|
161
|
+
}
|
|
127
162
|
await assertProtectedSecretMetadataPrincipal({
|
|
163
|
+
accountId,
|
|
128
164
|
apply,
|
|
129
165
|
environment,
|
|
130
|
-
|
|
166
|
+
expectedRoleArn,
|
|
131
167
|
readPrincipal: dependencies.readPrincipal,
|
|
132
168
|
region: aws.region,
|
|
133
169
|
stage: options.stage,
|
|
134
170
|
});
|
|
135
171
|
}
|
|
136
172
|
else if (authority === 'local') {
|
|
137
|
-
if (
|
|
173
|
+
if (accountId === undefined || expectedRoleArn === undefined) {
|
|
138
174
|
throw new Error('Local secret metadata operating policy is unavailable.');
|
|
139
175
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (aws.region !== region) {
|
|
143
|
-
throw new Error(`Local protected secret metadata apply requires committed deployment Region ${region}.`);
|
|
176
|
+
if (options.expectedRoleArn !== expectedRoleArn) {
|
|
177
|
+
throw new Error(`Local secret metadata apply requires the exact committed ${options.stage} stage authority role ${expectedRoleArn}.`);
|
|
144
178
|
}
|
|
145
179
|
await assertLocalSecretMetadataPrincipal({
|
|
146
|
-
accountId
|
|
147
|
-
expectedRoleArn
|
|
180
|
+
accountId,
|
|
181
|
+
expectedRoleArn,
|
|
148
182
|
...(aws.profile ? { profile: aws.profile } : {}),
|
|
149
183
|
readPrincipal: dependencies.readPrincipal,
|
|
150
|
-
region,
|
|
184
|
+
region: aws.region,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (apply) {
|
|
188
|
+
await (dependencies.ownership ?? index_js_4.assertWorkspaceStageOwnershipForWorkspace)(context.root, options.stage, {
|
|
189
|
+
...(environment.AWS_CONFIG_FILE
|
|
190
|
+
? { configFilepath: environment.AWS_CONFIG_FILE }
|
|
191
|
+
: {}),
|
|
192
|
+
...(environment.AWS_SHARED_CREDENTIALS_FILE
|
|
193
|
+
? {
|
|
194
|
+
credentialsFilepath: environment.AWS_SHARED_CREDENTIALS_FILE,
|
|
195
|
+
}
|
|
196
|
+
: {}),
|
|
197
|
+
...(aws.profile ? { profile: aws.profile } : {}),
|
|
151
198
|
});
|
|
152
199
|
}
|
|
153
200
|
const loaded = await (0, secret_preflight_js_1.loadSliceSecretMetadata)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-metadata.js","sourceRoot":"","sources":["../../../../../../packages/nx/src/executors/secret-metadata/secret-metadata.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"secret-metadata.js","sourceRoot":"","sources":["../../../../../../packages/nx/src/executors/secret-metadata/secret-metadata.ts"],"names":[],"mappings":";;AAwDA,gFA6BC;AA4BD,wFAiDC;AAED,gFAqCC;AAoBD,sDAsHC;AAnVD,uCAAgF;AAChF,oDAA0E;AAC1E,wEAAwD;AACxD,yCAA6C;AAE7C,qDAIgC;AAChC,2DAA4E;AAC5E,8EAI8C;AAC9C,+DAQ0C;AAC1C,uDAG+B;AAC/B,kEAAgG;AAsBhG,MAAM,IAAI,GACR,4EAA4E,CAAC;AAI/E,SAAgB,kCAAkC,CAChD,KAA6C,EAC7C,KAAc,EACd,cAAiC,OAAO,CAAC,GAAG,EAC5C,oBAAuC,gBAAgB;IAEvD,IAAI,CAAC,KAAK;QAAE,OAAO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OAAO;YACf,CAAC,CAAC,mCAAmC,CACxC,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { type RepositoryOperatingPolicy } from '../../repository-policy/index.js';
|
|
3
|
+
import { type GeneratedSecretRetirementControlPlane, type GeneratedSecretRetirementResult } from '../../secrets/index.js';
|
|
4
|
+
import { type LoadedSliceSecretMetadata } from './secret-preflight.js';
|
|
5
|
+
import type { SstCommandInvocation, SstLifecycleOptions } from './run-sst-command.js';
|
|
6
|
+
export declare const GENERATED_SECRET_RETIREMENT_EVIDENCE_DIRECTORY: string;
|
|
7
|
+
interface AwsPrincipal {
|
|
8
|
+
accountId: string;
|
|
9
|
+
arn: string;
|
|
10
|
+
}
|
|
11
|
+
export interface GeneratedSecretRetirementEvidence {
|
|
12
|
+
accountId: string;
|
|
13
|
+
actorArn: string;
|
|
14
|
+
completedAt: string;
|
|
15
|
+
deletionMode: GeneratedSecretRetirementResult['deletionMode'];
|
|
16
|
+
kind: 'ebk-generated-secret-retirement';
|
|
17
|
+
project: string;
|
|
18
|
+
recoveryWindowDays?: 7;
|
|
19
|
+
region: string;
|
|
20
|
+
result: 'succeeded';
|
|
21
|
+
schemaVersion: 1;
|
|
22
|
+
secrets: GeneratedSecretRetirementResult['secrets'];
|
|
23
|
+
sourceCommit: string;
|
|
24
|
+
stage: string;
|
|
25
|
+
startedAt: string;
|
|
26
|
+
workspace: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GeneratedSecretRetirementDependencies {
|
|
29
|
+
controlPlane?: GeneratedSecretRetirementControlPlane;
|
|
30
|
+
environment?: NodeJS.ProcessEnv;
|
|
31
|
+
loadMetadata?: (input: {
|
|
32
|
+
context: ExecutorContext;
|
|
33
|
+
cwd: string;
|
|
34
|
+
stage: string;
|
|
35
|
+
}) => Promise<LoadedSliceSecretMetadata>;
|
|
36
|
+
now?: () => Date;
|
|
37
|
+
readOperatingPolicy?: (workspaceRoot: string) => RepositoryOperatingPolicy;
|
|
38
|
+
readPrincipal?: (input: {
|
|
39
|
+
environment: NodeJS.ProcessEnv;
|
|
40
|
+
profile?: string;
|
|
41
|
+
region: string;
|
|
42
|
+
}) => Promise<AwsPrincipal>;
|
|
43
|
+
writeEvidence?: (path: string, evidence: GeneratedSecretRetirementEvidence) => void;
|
|
44
|
+
waitBeforeRetry?: (delayMs: number) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Complete the generated-secret portion of one successful native Slice remove.
|
|
48
|
+
* The invocation has already passed the normal stage/removal authorization;
|
|
49
|
+
* this function independently reattests its exact AWS identity and secret
|
|
50
|
+
* ownership before applying the stage-specific deletion policy.
|
|
51
|
+
*/
|
|
52
|
+
export declare function retireGeneratedSecretsAfterSliceRemove(options: SstLifecycleOptions, context: ExecutorContext, invocation: SstCommandInvocation, dependencies?: GeneratedSecretRetirementDependencies): Promise<GeneratedSecretRetirementEvidence>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GENERATED_SECRET_RETIREMENT_EVIDENCE_DIRECTORY = void 0;
|
|
4
|
+
exports.retireGeneratedSecretsAfterSliceRemove = retireGeneratedSecretsAfterSliceRemove;
|
|
5
|
+
const client_sts_1 = require("@aws-sdk/client-sts");
|
|
6
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const index_js_1 = require("../../aws-authority/index.js");
|
|
10
|
+
const identity_js_1 = require("../../aws/identity.js");
|
|
11
|
+
const index_js_2 = require("../../repository-policy/index.js");
|
|
12
|
+
const index_js_3 = require("../../secrets/index.js");
|
|
13
|
+
const secret_preflight_js_1 = require("./secret-preflight.js");
|
|
14
|
+
const private_state_js_1 = require("../../local-dev/private-state.js");
|
|
15
|
+
const GENERATED_SECRET_RETIREMENT_EVIDENCE_SEGMENTS = [
|
|
16
|
+
'.ebk',
|
|
17
|
+
'evidence',
|
|
18
|
+
'generated-secret-retirement',
|
|
19
|
+
];
|
|
20
|
+
exports.GENERATED_SECRET_RETIREMENT_EVIDENCE_DIRECTORY = (0, node_path_1.join)(...GENERATED_SECRET_RETIREMENT_EVIDENCE_SEGMENTS);
|
|
21
|
+
const SHA = /^[a-f0-9]{40,64}$/u;
|
|
22
|
+
const MAXIMUM_EVIDENCE_BYTES = 32 * 1024;
|
|
23
|
+
function partitionForRegion(region) {
|
|
24
|
+
if (region.startsWith('cn-'))
|
|
25
|
+
return 'aws-cn';
|
|
26
|
+
if (region.startsWith('us-gov-'))
|
|
27
|
+
return 'aws-us-gov';
|
|
28
|
+
return 'aws';
|
|
29
|
+
}
|
|
30
|
+
function profileCredentials(profile, environment) {
|
|
31
|
+
return (0, credential_providers_1.fromIni)({
|
|
32
|
+
...(environment.AWS_CONFIG_FILE
|
|
33
|
+
? { configFilepath: environment.AWS_CONFIG_FILE }
|
|
34
|
+
: {}),
|
|
35
|
+
...(environment.AWS_SHARED_CREDENTIALS_FILE
|
|
36
|
+
? { filepath: environment.AWS_SHARED_CREDENTIALS_FILE }
|
|
37
|
+
: {}),
|
|
38
|
+
profile,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function readCurrentPrincipal(input) {
|
|
42
|
+
const client = new client_sts_1.STSClient({
|
|
43
|
+
...(input.profile
|
|
44
|
+
? { credentials: profileCredentials(input.profile, input.environment) }
|
|
45
|
+
: {}),
|
|
46
|
+
endpoint: (0, identity_js_1.canonicalStsEndpoint)(input.region),
|
|
47
|
+
region: input.region,
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const identity = await client.send(new client_sts_1.GetCallerIdentityCommand({}));
|
|
51
|
+
if (!identity.Account || !identity.Arn) {
|
|
52
|
+
throw new Error('identity unavailable');
|
|
53
|
+
}
|
|
54
|
+
return { accountId: identity.Account, arn: identity.Arn };
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
client.destroy();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function writeBoundedEvidence(path, evidence) {
|
|
61
|
+
const serialized = `${JSON.stringify(evidence, null, 2)}\n`;
|
|
62
|
+
(0, private_state_js_1.atomicWritePrivateFileWithMaximumBytes)(path, serialized, MAXIMUM_EVIDENCE_BYTES);
|
|
63
|
+
}
|
|
64
|
+
function prepareEvidenceDestination(cwd, path) {
|
|
65
|
+
const projectRoot = (0, node_path_1.resolve)(cwd);
|
|
66
|
+
const expectedPath = (0, node_path_1.join)(projectRoot, ...GENERATED_SECRET_RETIREMENT_EVIDENCE_SEGMENTS, (0, node_path_1.basename)(path));
|
|
67
|
+
if ((0, node_path_1.resolve)(path) !== expectedPath) {
|
|
68
|
+
throw new Error('Generated secret retirement evidence must remain inside the exact project evidence directory.');
|
|
69
|
+
}
|
|
70
|
+
const projectIdentity = (0, node_fs_1.lstatSync)(projectRoot);
|
|
71
|
+
if (projectIdentity.isSymbolicLink() || !projectIdentity.isDirectory()) {
|
|
72
|
+
throw new Error('Generated secret retirement requires one real project directory.');
|
|
73
|
+
}
|
|
74
|
+
let current = projectRoot;
|
|
75
|
+
for (const segment of GENERATED_SECRET_RETIREMENT_EVIDENCE_SEGMENTS) {
|
|
76
|
+
current = (0, node_path_1.join)(current, segment);
|
|
77
|
+
(0, private_state_js_1.ensurePrivateDirectory)(current);
|
|
78
|
+
}
|
|
79
|
+
if ((0, node_fs_1.existsSync)(path)) {
|
|
80
|
+
(0, private_state_js_1.assertPrivatePath)(path, 'file');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function sourceCommit(environment) {
|
|
84
|
+
const commit = (environment.EBK_SOURCE_COMMIT ??
|
|
85
|
+
environment.GITHUB_SHA ??
|
|
86
|
+
'').trim();
|
|
87
|
+
if (!SHA.test(commit)) {
|
|
88
|
+
throw new Error('Generated secret retirement requires one exact lifecycle source commit.');
|
|
89
|
+
}
|
|
90
|
+
return commit;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Complete the generated-secret portion of one successful native Slice remove.
|
|
94
|
+
* The invocation has already passed the normal stage/removal authorization;
|
|
95
|
+
* this function independently reattests its exact AWS identity and secret
|
|
96
|
+
* ownership before applying the stage-specific deletion policy.
|
|
97
|
+
*/
|
|
98
|
+
async function retireGeneratedSecretsAfterSliceRemove(options, context, invocation, dependencies = {}) {
|
|
99
|
+
const environment = dependencies.environment ?? process.env;
|
|
100
|
+
const exactSourceCommit = sourceCommit(environment);
|
|
101
|
+
const startedAt = (dependencies.now ?? (() => new Date()))().toISOString();
|
|
102
|
+
const policy = (dependencies.readOperatingPolicy ?? index_js_2.readRepositoryOperatingPolicy)(context.root);
|
|
103
|
+
const stage = invocation.environment.EBK_CONSUMER_STAGE;
|
|
104
|
+
if (!(0, index_js_2.isActiveDeploymentStage)(policy.deploymentProfile, stage)) {
|
|
105
|
+
throw new Error(`Generated secret retirement stage ${stage} is inactive for the ${policy.deploymentProfile} deployment profile.`);
|
|
106
|
+
}
|
|
107
|
+
const region = (0, index_js_2.configuredDeploymentRegion)(policy.deploymentRegion);
|
|
108
|
+
const accountId = (0, index_js_2.configuredDeploymentAccountForStage)(policy.deploymentProfile, policy.deploymentAccounts, stage);
|
|
109
|
+
const expectedRoleArn = (0, index_js_1.createStageAuthorityIdentity)({
|
|
110
|
+
accountId,
|
|
111
|
+
partition: partitionForRegion(region),
|
|
112
|
+
region,
|
|
113
|
+
stage,
|
|
114
|
+
}).deploymentRoleArn;
|
|
115
|
+
if (invocation.environment.AWS_EXPECTED_ACCOUNT_ID !== accountId ||
|
|
116
|
+
invocation.environment.AWS_REGION !== region ||
|
|
117
|
+
invocation.environment.EBK_EXPECTED_DEPLOYMENT_ROLE_ARN !==
|
|
118
|
+
expectedRoleArn ||
|
|
119
|
+
(options.expectedRoleArn !== undefined &&
|
|
120
|
+
options.expectedRoleArn !== expectedRoleArn)) {
|
|
121
|
+
throw new Error('Generated secret retirement requires the exact committed account, Region, stage, and deployment role.');
|
|
122
|
+
}
|
|
123
|
+
const profile = invocation.environment.AWS_PROFILE;
|
|
124
|
+
if (profile !== undefined && options.profile !== profile) {
|
|
125
|
+
throw new Error('Generated secret retirement requires the exact invocation-private AWS profile.');
|
|
126
|
+
}
|
|
127
|
+
let principal;
|
|
128
|
+
try {
|
|
129
|
+
principal = await (dependencies.readPrincipal ?? readCurrentPrincipal)({
|
|
130
|
+
environment,
|
|
131
|
+
...(profile ? { profile } : {}),
|
|
132
|
+
region,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
throw new Error('Generated secret retirement could not authenticate its AWS principal.');
|
|
137
|
+
}
|
|
138
|
+
if (principal.accountId !== accountId ||
|
|
139
|
+
!(0, identity_js_1.matchesExpectedAssumedRoleArn)(accountId, principal.arn, expectedRoleArn)) {
|
|
140
|
+
throw new Error('Generated secret retirement is not running in the committed account as the exact temporary stage deployment role.');
|
|
141
|
+
}
|
|
142
|
+
const loaded = await (dependencies.loadMetadata ?? secret_preflight_js_1.loadSliceSecretMetadata)({
|
|
143
|
+
context,
|
|
144
|
+
cwd: invocation.cwd,
|
|
145
|
+
stage,
|
|
146
|
+
});
|
|
147
|
+
const evidencePath = (0, node_path_1.join)(invocation.cwd, exports.GENERATED_SECRET_RETIREMENT_EVIDENCE_DIRECTORY, `${stage}.json`);
|
|
148
|
+
prepareEvidenceDestination(invocation.cwd, evidencePath);
|
|
149
|
+
const controlPlane = dependencies.controlPlane ??
|
|
150
|
+
(0, index_js_3.createAwsGeneratedSecretRetirementControlPlane)({
|
|
151
|
+
clientConfiguration: {
|
|
152
|
+
...(profile
|
|
153
|
+
? { credentials: profileCredentials(profile, environment) }
|
|
154
|
+
: {}),
|
|
155
|
+
endpoint: (0, identity_js_1.canonicalAwsRegionalEndpoint)('secretsmanager', region),
|
|
156
|
+
region,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
const result = await (0, index_js_3.runGeneratedSecretRetirement)({
|
|
160
|
+
accountId,
|
|
161
|
+
controlPlane,
|
|
162
|
+
declarations: loaded.declarations,
|
|
163
|
+
partition: partitionForRegion(region),
|
|
164
|
+
region,
|
|
165
|
+
scope: loaded.scope,
|
|
166
|
+
...(dependencies.waitBeforeRetry === undefined
|
|
167
|
+
? {}
|
|
168
|
+
: { waitBeforeRetry: dependencies.waitBeforeRetry }),
|
|
169
|
+
});
|
|
170
|
+
const evidence = Object.freeze({
|
|
171
|
+
accountId,
|
|
172
|
+
actorArn: principal.arn,
|
|
173
|
+
completedAt: (dependencies.now ?? (() => new Date()))().toISOString(),
|
|
174
|
+
deletionMode: result.deletionMode,
|
|
175
|
+
kind: 'ebk-generated-secret-retirement',
|
|
176
|
+
project: loaded.scope.slice,
|
|
177
|
+
...(result.recoveryWindowDays === undefined
|
|
178
|
+
? {}
|
|
179
|
+
: { recoveryWindowDays: result.recoveryWindowDays }),
|
|
180
|
+
region,
|
|
181
|
+
result: 'succeeded',
|
|
182
|
+
schemaVersion: 1,
|
|
183
|
+
secrets: result.secrets,
|
|
184
|
+
sourceCommit: exactSourceCommit,
|
|
185
|
+
stage,
|
|
186
|
+
startedAt,
|
|
187
|
+
workspace: loaded.scope.workspace,
|
|
188
|
+
});
|
|
189
|
+
(dependencies.writeEvidence ?? writeBoundedEvidence)(evidencePath, evidence);
|
|
190
|
+
return evidence;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=generated-secret-retirement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-secret-retirement.js","sourceRoot":"","sources":["../../../../../../packages/nx/src/executors/sst-lifecycle/generated-secret-retirement.ts"],"names":[],"mappings":";;;AAyMA,wFA2HC;AApUD,oDAA0E;AAC1E,wEAA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E,MAAM,CAAC,KAAK;QACnB,GAAG,CAAC,YAAY,CAAC,eAAe,KAAK,SAAS;YAC5C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,eAAe,EAAE,YAAY,CAAC,eAAe,EAAE,CAAC;KACvD,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;QAC7B,SAAS;QACT,QAAQ,EAAE,SAAS,CAAC,GAAG;QACvB,WAAW,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE;QACrE,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,IAAI,EAAE,iCAA0C;QAChD,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;QAC3B,GAAG,CAAC,MAAM,CAAC,kBAAkB,KAAK,SAAS;YACzC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACtD,MAAM;QACN,MAAM,EAAE,WAAoB;QAC5B,aAAa,EAAE,CAAU;QACzB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,YAAY,EAAE,iBAAiB;QAC/B,KAAK;QACL,SAAS;QACT,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS;KAClC,CAAC,CAAC;IACH,CAAC,YAAY,CAAC,aAAa,IAAI,oBAAoB,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ReadStream, WriteStream } from 'node:tty';
|
|
2
|
+
import { type ExecutorContext } from '@nx/devkit';
|
|
3
|
+
import { createLocalFederatedCredentialTransport } from '../local-deploy/federated-credential-transport.js';
|
|
4
|
+
import { type SstLifecycleCommand, type SstLifecycleOptions } from './run-sst-command.js';
|
|
5
|
+
export type GovernedNativeOperation = 'refresh' | 'remove' | 'unlock';
|
|
6
|
+
export interface GovernedNativeOperationApprovalRequest {
|
|
7
|
+
action: GovernedNativeOperation;
|
|
8
|
+
challenge: string;
|
|
9
|
+
sourceCommit: string;
|
|
10
|
+
stage: 'production' | 'staging';
|
|
11
|
+
}
|
|
12
|
+
export type GovernedNativeOperationApprover = (request: GovernedNativeOperationApprovalRequest) => Promise<boolean>;
|
|
13
|
+
interface ApprovalTerminal {
|
|
14
|
+
input: ReadStream;
|
|
15
|
+
output: WriteStream;
|
|
16
|
+
}
|
|
17
|
+
interface SourceIdentity {
|
|
18
|
+
clean: boolean;
|
|
19
|
+
commit: string;
|
|
20
|
+
workingTreeDigest: string;
|
|
21
|
+
}
|
|
22
|
+
type NativeRunner = (command: SstLifecycleCommand, options: SstLifecycleOptions, context: ExecutorContext, dependencies?: {
|
|
23
|
+
environment?: NodeJS.ProcessEnv;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export interface GovernedNativeOperationDependencies {
|
|
28
|
+
approve?: GovernedNativeOperationApprover;
|
|
29
|
+
createTransport?: typeof createLocalFederatedCredentialTransport;
|
|
30
|
+
environment?: NodeJS.ProcessEnv;
|
|
31
|
+
platform?: NodeJS.Platform;
|
|
32
|
+
readSource?: (root: string) => SourceIdentity;
|
|
33
|
+
run?: NativeRunner;
|
|
34
|
+
}
|
|
35
|
+
/** Active operator acknowledgement, not an independent-review claim. */
|
|
36
|
+
export declare function createTtyGovernedNativeOperationApprover(terminal?: ApprovalTerminal): GovernedNativeOperationApprover;
|
|
37
|
+
/**
|
|
38
|
+
* Govern refresh, remove, and unlock without replacing SST's native lifecycle.
|
|
39
|
+
* Local execution flattens the operator's federated profile into one private,
|
|
40
|
+
* invocation-scoped profile; protected stages additionally require a TTY
|
|
41
|
+
* acknowledgement. GitHub OIDC proceeds through the existing native path.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runGovernedNativeOperation(command: GovernedNativeOperation, options: SstLifecycleOptions, context: ExecutorContext, dependencies?: GovernedNativeOperationDependencies): Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
export {};
|