@codedrifters/configulator 0.0.425 → 0.0.427
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/lib/index.d.mts +194 -15
- package/lib/index.d.ts +195 -16
- package/lib/index.js +357 -51
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +355 -54
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -41929,7 +41929,7 @@ import { merge as merge4 } from "ts-deepmerge";
|
|
|
41929
41929
|
var import_utils11 = __toESM(require_lib());
|
|
41930
41930
|
import { Component as Component22 } from "projen";
|
|
41931
41931
|
import { BuildWorkflow } from "projen/lib/build";
|
|
41932
|
-
import { GitHub as GitHub5, WorkflowSteps as WorkflowSteps2 } from "projen/lib/github";
|
|
41932
|
+
import { GitHub as GitHub5, GithubWorkflow, WorkflowSteps as WorkflowSteps2 } from "projen/lib/github";
|
|
41933
41933
|
import { JobPermission as JobPermission5 } from "projen/lib/github/workflows-model";
|
|
41934
41934
|
|
|
41935
41935
|
// src/workflows/deploy-gate.ts
|
|
@@ -41939,7 +41939,17 @@ var DEPLOY_GATE = {
|
|
|
41939
41939
|
* required reviewers, wait timers, deployment branch policies — apply before
|
|
41940
41940
|
* the job is sent to a runner.
|
|
41941
41941
|
*/
|
|
41942
|
-
ENVIRONMENT: "environment"
|
|
41942
|
+
ENVIRONMENT: "environment",
|
|
41943
|
+
/**
|
|
41944
|
+
* Split the workflow in two. A **plan** workflow builds and diffs but never
|
|
41945
|
+
* deploys; a dispatch-only **apply** workflow deploys the exact cloud
|
|
41946
|
+
* assembly a nominated plan run produced.
|
|
41947
|
+
*
|
|
41948
|
+
* Needs no protection rule, so unlike {@link DEPLOY_GATE.ENVIRONMENT} it
|
|
41949
|
+
* works on every GitHub plan. `environmentName` is optional here and layers
|
|
41950
|
+
* an environment onto the apply jobs.
|
|
41951
|
+
*/
|
|
41952
|
+
PLAN_APPLY: "plan-apply"
|
|
41943
41953
|
};
|
|
41944
41954
|
var resolveEnvironmentGate = (gate, environmentName, componentName) => {
|
|
41945
41955
|
const trimmed = environmentName?.trim();
|
|
@@ -41951,7 +41961,7 @@ var resolveEnvironmentGate = (gate, environmentName, componentName) => {
|
|
|
41951
41961
|
}
|
|
41952
41962
|
return void 0;
|
|
41953
41963
|
}
|
|
41954
|
-
if (!trimmed) {
|
|
41964
|
+
if (gate === DEPLOY_GATE.ENVIRONMENT && !trimmed) {
|
|
41955
41965
|
throw new Error(
|
|
41956
41966
|
`${componentName} requires a non-empty \`environmentName\` when \`gate\` is "${gate}"`
|
|
41957
41967
|
);
|
|
@@ -41973,6 +41983,105 @@ var renderHomeRepositoryCondition = (homeRepository, componentName) => {
|
|
|
41973
41983
|
return `github.repository == '${homeRepository}'`;
|
|
41974
41984
|
};
|
|
41975
41985
|
|
|
41986
|
+
// src/workflows/plan-apply.ts
|
|
41987
|
+
var VALIDATE_PLAN_JOB_ID = "validate-plan";
|
|
41988
|
+
var PLAN_RUN_ID_INPUT = "plan_run_id";
|
|
41989
|
+
var BUILD_ARTIFACT_NAME = "build-artifact";
|
|
41990
|
+
var PERMISSION_BACKUP_FILE = "permissions-backup.acl";
|
|
41991
|
+
var renderPlanValidationScript = (options) => {
|
|
41992
|
+
const {
|
|
41993
|
+
planWorkflowPath,
|
|
41994
|
+
allowedBranches,
|
|
41995
|
+
requireCurrentHead,
|
|
41996
|
+
verifyArtifactDigest
|
|
41997
|
+
} = options;
|
|
41998
|
+
return [
|
|
41999
|
+
"const raw = (process.env.PLAN_RUN_ID ?? '').trim();",
|
|
42000
|
+
"const runId = Number(raw);",
|
|
42001
|
+
"if (!/^[0-9]+$/.test(raw) || !Number.isSafeInteger(runId) || runId <= 0) {",
|
|
42002
|
+
' core.setFailed(`plan_run_id must be a positive run id, got "${raw}"`);',
|
|
42003
|
+
" return;",
|
|
42004
|
+
"}",
|
|
42005
|
+
"",
|
|
42006
|
+
"const { owner, repo } = context.repo;",
|
|
42007
|
+
"const { data: run } = await github.rest.actions.getWorkflowRun({",
|
|
42008
|
+
" owner,",
|
|
42009
|
+
" repo,",
|
|
42010
|
+
" run_id: runId,",
|
|
42011
|
+
"});",
|
|
42012
|
+
"",
|
|
42013
|
+
`const expectedPath = ${JSON.stringify(planWorkflowPath)};`,
|
|
42014
|
+
"if (run.path !== expectedPath) {",
|
|
42015
|
+
' core.setFailed(`Run ${runId} belongs to workflow "${run.path}", expected "${expectedPath}".`);',
|
|
42016
|
+
" return;",
|
|
42017
|
+
"}",
|
|
42018
|
+
"",
|
|
42019
|
+
'if (run.status !== "completed" || run.conclusion !== "success") {',
|
|
42020
|
+
' core.setFailed(`Run ${runId} is status "${run.status}" / conclusion "${run.conclusion}", expected a completed successful plan run.`);',
|
|
42021
|
+
" return;",
|
|
42022
|
+
"}",
|
|
42023
|
+
"",
|
|
42024
|
+
`const allowedBranches = ${JSON.stringify(allowedBranches)};`,
|
|
42025
|
+
'const branch = run.head_branch ?? "";',
|
|
42026
|
+
"const branchAllowed = allowedBranches.some((pattern) =>",
|
|
42027
|
+
' pattern.includes("*")',
|
|
42028
|
+
' ? branch.startsWith(pattern.slice(0, pattern.indexOf("*")))',
|
|
42029
|
+
" : branch === pattern,",
|
|
42030
|
+
");",
|
|
42031
|
+
"if (!branchAllowed) {",
|
|
42032
|
+
' core.setFailed(`Run ${runId} ran on branch "${branch}", which no deployment target in this workflow accepts (allowed: ${allowedBranches.join(", ")}).`);',
|
|
42033
|
+
" return;",
|
|
42034
|
+
"}",
|
|
42035
|
+
...requireCurrentHead ? [
|
|
42036
|
+
"",
|
|
42037
|
+
"const { data: liveBranch } = await github.rest.repos.getBranch({",
|
|
42038
|
+
" owner,",
|
|
42039
|
+
" repo,",
|
|
42040
|
+
" branch,",
|
|
42041
|
+
"});",
|
|
42042
|
+
"if (liveBranch.commit.sha !== run.head_sha) {",
|
|
42043
|
+
' core.setFailed(`Run ${runId} planned ${run.head_sha} but "${branch}" now points at ${liveBranch.commit.sha}. Re-run the plan workflow against the current head.`);',
|
|
42044
|
+
" return;",
|
|
42045
|
+
"}"
|
|
42046
|
+
] : [],
|
|
42047
|
+
"",
|
|
42048
|
+
"const artifacts = await github.paginate(",
|
|
42049
|
+
" github.rest.actions.listWorkflowRunArtifacts,",
|
|
42050
|
+
" { owner, repo, run_id: runId, per_page: 100 },",
|
|
42051
|
+
");",
|
|
42052
|
+
`const artifactName = ${JSON.stringify(BUILD_ARTIFACT_NAME)};`,
|
|
42053
|
+
"const artifact = artifacts.find((a) => a.name === artifactName);",
|
|
42054
|
+
"if (!artifact) {",
|
|
42055
|
+
' core.setFailed(`Run ${runId} published no "${artifactName}" artifact. Only a plan run whose build job completed can be applied.`);',
|
|
42056
|
+
" return;",
|
|
42057
|
+
"}",
|
|
42058
|
+
"if (artifact.expired) {",
|
|
42059
|
+
' core.setFailed(`The "${artifactName}" artifact on run ${runId} expired at ${artifact.expires_at}. Artifact retention is this gate\'s approval window \u2014 re-run the plan workflow.`);',
|
|
42060
|
+
" return;",
|
|
42061
|
+
"}",
|
|
42062
|
+
...verifyArtifactDigest ? [
|
|
42063
|
+
"if (!artifact.digest) {",
|
|
42064
|
+
' core.setFailed(`The "${artifactName}" artifact on run ${runId} reports no digest, so it cannot be verified. Disable planApply.verifyArtifactDigest or re-run the plan workflow.`);',
|
|
42065
|
+
" return;",
|
|
42066
|
+
"}",
|
|
42067
|
+
'core.setOutput("artifact_digest", artifact.digest);'
|
|
42068
|
+
] : [],
|
|
42069
|
+
"",
|
|
42070
|
+
'core.setOutput("head_sha", run.head_sha);',
|
|
42071
|
+
'core.setOutput("head_branch", branch);',
|
|
42072
|
+
"await core.summary",
|
|
42073
|
+
" .addHeading(`Applying plan run ${runId}`, 2)",
|
|
42074
|
+
" .addTable([",
|
|
42075
|
+
' [{ data: "Field", header: true }, { data: "Value", header: true }],',
|
|
42076
|
+
' ["Plan run", `<a href="${run.html_url}">${runId}</a>`],',
|
|
42077
|
+
' ["Branch", branch],',
|
|
42078
|
+
' ["Commit", run.head_sha],',
|
|
42079
|
+
' ["Artifact expires", artifact.expires_at ?? "unknown"],',
|
|
42080
|
+
" ])",
|
|
42081
|
+
" .write();"
|
|
42082
|
+
].join("\n");
|
|
42083
|
+
};
|
|
42084
|
+
|
|
41976
42085
|
// src/workflows/aws-deploy-workflow.ts
|
|
41977
42086
|
var PROD_DEPLOY_NAME = "prod-deploy";
|
|
41978
42087
|
var DIFF_OUTPUT_FILE = "cdk-diff.txt";
|
|
@@ -42044,6 +42153,20 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42044
42153
|
target.region
|
|
42045
42154
|
].join("-");
|
|
42046
42155
|
};
|
|
42156
|
+
/**
|
|
42157
|
+
* Build the deterministic GitHub Actions job name for a target's apply job.
|
|
42158
|
+
* Mirrors {@link buildJobName} with an `apply` verb.
|
|
42159
|
+
*/
|
|
42160
|
+
this.buildApplyJobName = (target) => {
|
|
42161
|
+
return [
|
|
42162
|
+
target.awsStageType,
|
|
42163
|
+
target.deploymentTargetRole,
|
|
42164
|
+
"apply",
|
|
42165
|
+
target.project.name,
|
|
42166
|
+
target.account,
|
|
42167
|
+
target.region
|
|
42168
|
+
].join("-");
|
|
42169
|
+
};
|
|
42047
42170
|
/**
|
|
42048
42171
|
* Build the CI artifact name for a target's captured diff.
|
|
42049
42172
|
*
|
|
@@ -42062,6 +42185,163 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42062
42185
|
target.region
|
|
42063
42186
|
].join("-");
|
|
42064
42187
|
};
|
|
42188
|
+
/**
|
|
42189
|
+
* Create the dispatch-only apply workflow and its validation job.
|
|
42190
|
+
*
|
|
42191
|
+
* The workflow file name defaults to the plan workflow's name suffixed with
|
|
42192
|
+
* `-apply`. A name already in use throws rather than silently colliding on
|
|
42193
|
+
* the underlying `.github/workflows/<name>.yml` file — the usual cause is two
|
|
42194
|
+
* `AwsDeployWorkflow`s sharing one build workflow, and the fix is an explicit
|
|
42195
|
+
* `planApply.applyWorkflowName`.
|
|
42196
|
+
*/
|
|
42197
|
+
this.createApplyWorkflow = (github, homeRepositoryCondition) => {
|
|
42198
|
+
const { applyWorkflowName, requireCurrentHead, verifyArtifactDigest } = this.planApplyOptions;
|
|
42199
|
+
if (github.tryFindWorkflow(applyWorkflowName)) {
|
|
42200
|
+
throw new Error(
|
|
42201
|
+
`AwsDeployWorkflow cannot create the apply workflow "${applyWorkflowName}" because a workflow with that name already exists. Set \`planApply.applyWorkflowName\` to something unique.`
|
|
42202
|
+
);
|
|
42203
|
+
}
|
|
42204
|
+
const workflow = new GithubWorkflow(github, applyWorkflowName);
|
|
42205
|
+
workflow.on({
|
|
42206
|
+
workflowDispatch: {
|
|
42207
|
+
inputs: {
|
|
42208
|
+
[PLAN_RUN_ID_INPUT]: {
|
|
42209
|
+
description: "Run id of the plan workflow run to apply. Its build artifact is deployed verbatim.",
|
|
42210
|
+
required: true,
|
|
42211
|
+
type: "string"
|
|
42212
|
+
}
|
|
42213
|
+
}
|
|
42214
|
+
}
|
|
42215
|
+
});
|
|
42216
|
+
const allowedBranches = Array.from(
|
|
42217
|
+
new Set(
|
|
42218
|
+
this.awsDeploymentTargets.flatMap(
|
|
42219
|
+
(target) => target.branches.map((b) => b.branch)
|
|
42220
|
+
)
|
|
42221
|
+
)
|
|
42222
|
+
);
|
|
42223
|
+
workflow.addJob(VALIDATE_PLAN_JOB_ID, {
|
|
42224
|
+
name: "Validate plan run",
|
|
42225
|
+
runsOn: ["ubuntu-latest"],
|
|
42226
|
+
permissions: {
|
|
42227
|
+
actions: JobPermission5.READ,
|
|
42228
|
+
contents: JobPermission5.READ
|
|
42229
|
+
},
|
|
42230
|
+
...homeRepositoryCondition ? { if: `\${{ ${homeRepositoryCondition} }}` } : {},
|
|
42231
|
+
outputs: {
|
|
42232
|
+
head_sha: { stepId: "validate_plan_run", outputName: "head_sha" },
|
|
42233
|
+
head_branch: { stepId: "validate_plan_run", outputName: "head_branch" },
|
|
42234
|
+
...verifyArtifactDigest ? {
|
|
42235
|
+
artifact_digest: {
|
|
42236
|
+
stepId: "validate_plan_run",
|
|
42237
|
+
outputName: "artifact_digest"
|
|
42238
|
+
}
|
|
42239
|
+
} : {}
|
|
42240
|
+
},
|
|
42241
|
+
steps: [
|
|
42242
|
+
{
|
|
42243
|
+
name: "Validate plan run",
|
|
42244
|
+
id: "validate_plan_run",
|
|
42245
|
+
uses: "actions/github-script@v9",
|
|
42246
|
+
/**
|
|
42247
|
+
* The dispatch input reaches the script through the environment
|
|
42248
|
+
* rather than a `${{ }}` interpolation, so a crafted run id cannot
|
|
42249
|
+
* inject JavaScript into the validation itself.
|
|
42250
|
+
*/
|
|
42251
|
+
env: {
|
|
42252
|
+
PLAN_RUN_ID: `\${{ inputs.${PLAN_RUN_ID_INPUT} }}`
|
|
42253
|
+
},
|
|
42254
|
+
with: {
|
|
42255
|
+
script: renderPlanValidationScript({
|
|
42256
|
+
planWorkflowPath: `.github/workflows/${this.buildWorkflow.name}.yml`,
|
|
42257
|
+
allowedBranches,
|
|
42258
|
+
requireCurrentHead,
|
|
42259
|
+
verifyArtifactDigest
|
|
42260
|
+
})
|
|
42261
|
+
}
|
|
42262
|
+
}
|
|
42263
|
+
]
|
|
42264
|
+
});
|
|
42265
|
+
return workflow;
|
|
42266
|
+
};
|
|
42267
|
+
/**
|
|
42268
|
+
* Register one target's apply job on the apply workflow.
|
|
42269
|
+
*
|
|
42270
|
+
* Differences from the `single`-gate deploy job, all of them forced by the
|
|
42271
|
+
* apply run having no build job of its own:
|
|
42272
|
+
*
|
|
42273
|
+
* - `needs` starts at the validation job rather than `build`, so a plan run
|
|
42274
|
+
* that fails any check skips every apply job instead of deploying.
|
|
42275
|
+
* - `actions: read` is added, which is what lets `actions/download-artifact`
|
|
42276
|
+
* reach across runs.
|
|
42277
|
+
* - No `pull-requests: write`, and no sticky PR comment step: an apply is
|
|
42278
|
+
* always a `workflow_dispatch`, so the comment could never fire.
|
|
42279
|
+
* - No branch filter on `github.ref`. The ref an operator happens to
|
|
42280
|
+
* dispatch from is unrelated to what was planned; the branch that matters
|
|
42281
|
+
* is the plan run's, and the validation job checks that one.
|
|
42282
|
+
*
|
|
42283
|
+
* When `environmentName` is also supplied, it lands here rather than on the
|
|
42284
|
+
* plan's jobs — a second approver on top of whoever dispatched the apply.
|
|
42285
|
+
* `validate-plan` stays ungated so its verdict is available to read *before*
|
|
42286
|
+
* the approval is given.
|
|
42287
|
+
*/
|
|
42288
|
+
this.addApplyJob = (workflow, target, homeRepositoryCondition) => {
|
|
42289
|
+
const applyJobName = this.buildApplyJobName(target);
|
|
42290
|
+
const { verifyArtifactDigest } = this.planApplyOptions;
|
|
42291
|
+
const artifactsDirectory = this.rootProject.artifactsDirectory;
|
|
42292
|
+
workflow.addJob(applyJobName, {
|
|
42293
|
+
name: `Apply ${this.project.name} ${target.awsStageType}/${target.deploymentTargetRole}/${target.account}/${target.region}`,
|
|
42294
|
+
needs: [
|
|
42295
|
+
VALIDATE_PLAN_JOB_ID,
|
|
42296
|
+
...this.deployAfterTargets.map((p) => this.buildApplyJobName(p))
|
|
42297
|
+
],
|
|
42298
|
+
runsOn: ["ubuntu-latest"],
|
|
42299
|
+
permissions: {
|
|
42300
|
+
actions: JobPermission5.READ,
|
|
42301
|
+
contents: JobPermission5.READ,
|
|
42302
|
+
idToken: JobPermission5.WRITE
|
|
42303
|
+
},
|
|
42304
|
+
...this.environmentName ? { environment: this.environmentName } : void 0,
|
|
42305
|
+
/**
|
|
42306
|
+
* Shares the deploy job's group name so an apply can never overlap a
|
|
42307
|
+
* same-target deploy. `cancel-in-progress` is spelled out rather than
|
|
42308
|
+
* left to GitHub's default: cancelling a half-finished `cdk deploy`
|
|
42309
|
+
* strands a CloudFormation stack mid-update.
|
|
42310
|
+
*/
|
|
42311
|
+
concurrency: {
|
|
42312
|
+
group: this.buildJobName(target),
|
|
42313
|
+
"cancel-in-progress": false
|
|
42314
|
+
},
|
|
42315
|
+
...homeRepositoryCondition ? { if: `\${{ ${homeRepositoryCondition} }}` } : {},
|
|
42316
|
+
steps: [
|
|
42317
|
+
/**
|
|
42318
|
+
* Cross-run download of the plan's assembly. `run-id` plus an explicit
|
|
42319
|
+
* `github-token` is what makes `actions/download-artifact` look outside
|
|
42320
|
+
* the current run; without both it silently searches this run and finds
|
|
42321
|
+
* nothing.
|
|
42322
|
+
*/
|
|
42323
|
+
{
|
|
42324
|
+
name: "Download plan build artifacts",
|
|
42325
|
+
uses: "actions/download-artifact@v8",
|
|
42326
|
+
with: {
|
|
42327
|
+
name: BUILD_ARTIFACT_NAME,
|
|
42328
|
+
path: artifactsDirectory,
|
|
42329
|
+
"run-id": `\${{ inputs.${PLAN_RUN_ID_INPUT} }}`,
|
|
42330
|
+
"github-token": "${{ secrets.GITHUB_TOKEN }}",
|
|
42331
|
+
...verifyArtifactDigest ? {
|
|
42332
|
+
"artifact-digest": `\${{ needs.${VALIDATE_PLAN_JOB_ID}.outputs.artifact_digest }}`
|
|
42333
|
+
} : {}
|
|
42334
|
+
}
|
|
42335
|
+
},
|
|
42336
|
+
{
|
|
42337
|
+
name: "Restore build artifact permissions",
|
|
42338
|
+
continueOnError: true,
|
|
42339
|
+
run: `cd ${artifactsDirectory} && setfacl --restore=${PERMISSION_BACKUP_FILE}`
|
|
42340
|
+
},
|
|
42341
|
+
...this.deploySteps(target, { stickyPrComment: false })
|
|
42342
|
+
]
|
|
42343
|
+
});
|
|
42344
|
+
};
|
|
42065
42345
|
/**
|
|
42066
42346
|
* Builds a GitHub Actions condition string that checks if the current branch
|
|
42067
42347
|
* matches any of the provided branch patterns.
|
|
@@ -42090,7 +42370,15 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42090
42370
|
}
|
|
42091
42371
|
return conditions.join(" || ");
|
|
42092
42372
|
};
|
|
42093
|
-
|
|
42373
|
+
/**
|
|
42374
|
+
* Steps for a target's deploy job.
|
|
42375
|
+
*
|
|
42376
|
+
* `stickyPrComment` drops the sticky-PR-comment step when false. Apply jobs
|
|
42377
|
+
* pass false: they only ever run on `workflow_dispatch` and so could never
|
|
42378
|
+
* satisfy that step's own `pull_request` guard.
|
|
42379
|
+
*/
|
|
42380
|
+
this.deploySteps = (target, options = {}) => {
|
|
42381
|
+
const { stickyPrComment = true } = options;
|
|
42094
42382
|
const {
|
|
42095
42383
|
awsStageType,
|
|
42096
42384
|
deploymentTargetRole,
|
|
@@ -42105,14 +42393,6 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42105
42393
|
return [
|
|
42106
42394
|
...this.setupPnpm(),
|
|
42107
42395
|
...this.setupNode(),
|
|
42108
|
-
/**
|
|
42109
|
-
* Install CDK, pinned to the same version that synthesized the cloud
|
|
42110
|
-
* assembly being deployed. See {@link CdkCli.cliVersion}.
|
|
42111
|
-
*/
|
|
42112
|
-
{
|
|
42113
|
-
name: "Install CDK",
|
|
42114
|
-
run: `pnpm add "aws-cdk@${cdkCli.cliVersion}"`
|
|
42115
|
-
},
|
|
42116
42396
|
/**
|
|
42117
42397
|
* Configure AWS creds.
|
|
42118
42398
|
*/
|
|
@@ -42169,23 +42449,25 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42169
42449
|
* comment is keyed by the deploy job name so dev/stage/prod comments
|
|
42170
42450
|
* don't collide on the same PR.
|
|
42171
42451
|
*/
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
|
|
42178
|
-
|
|
42452
|
+
...stickyPrComment ? [
|
|
42453
|
+
{
|
|
42454
|
+
name: "Sticky PR comment with deploy endpoints",
|
|
42455
|
+
if: "github.event_name == 'pull_request' && hashFiles('deploy-urls.md') != ''",
|
|
42456
|
+
uses: "marocchino/sticky-pull-request-comment@v3",
|
|
42457
|
+
with: {
|
|
42458
|
+
header: deployJobName,
|
|
42459
|
+
path: "deploy-urls.md"
|
|
42460
|
+
}
|
|
42179
42461
|
}
|
|
42180
|
-
|
|
42462
|
+
] : []
|
|
42181
42463
|
];
|
|
42182
42464
|
};
|
|
42183
42465
|
/**
|
|
42184
42466
|
* Steps for a target's optional `cdk diff` job.
|
|
42185
42467
|
*
|
|
42186
42468
|
* Mirrors {@link deploySteps}' toolchain and credential setup — same pnpm /
|
|
42187
|
-
* Node setup, same version-pinned `aws-cdk`
|
|
42188
|
-
*
|
|
42469
|
+
* Node setup, same version-pinned `aws-cdk` CLI, same OIDC role — so a diff
|
|
42470
|
+
* is computed by the same CLI that will run the deploy.
|
|
42189
42471
|
*
|
|
42190
42472
|
* The `cdk diff` flags come from the {@link CdkCli} precedence chain via
|
|
42191
42473
|
* `diffOptionsFor(target)`, so `method`, `securityOnly`, `fail`, and the rest
|
|
@@ -42213,14 +42495,6 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42213
42495
|
return [
|
|
42214
42496
|
...this.setupPnpm(),
|
|
42215
42497
|
...this.setupNode(),
|
|
42216
|
-
/**
|
|
42217
|
-
* Install CDK, pinned to the same version that synthesized the cloud
|
|
42218
|
-
* assembly being diffed. See {@link CdkCli.cliVersion}.
|
|
42219
|
-
*/
|
|
42220
|
-
{
|
|
42221
|
-
name: "Install CDK",
|
|
42222
|
-
run: `pnpm add "aws-cdk@${cdkCli.cliVersion}"`
|
|
42223
|
-
},
|
|
42224
42498
|
/**
|
|
42225
42499
|
* Configure AWS creds.
|
|
42226
42500
|
*/
|
|
@@ -42321,8 +42595,15 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42321
42595
|
(target) => target.awsStageType === this.awsStageType && target.ciDeployment
|
|
42322
42596
|
) ?? [];
|
|
42323
42597
|
this.deployAfterTargets = options.deployAfterTargets ?? [];
|
|
42598
|
+
this.gate = options.gate;
|
|
42599
|
+
const isPlanApply = this.gate === DEPLOY_GATE.PLAN_APPLY;
|
|
42600
|
+
if (isPlanApply && options.diff?.enabled === false) {
|
|
42601
|
+
throw new Error(
|
|
42602
|
+
"AwsDeployWorkflow cannot disable `diff` under the `plan-apply` gate: the diff jobs are what keep the plan workflow publishing the build artifact the apply workflow deploys."
|
|
42603
|
+
);
|
|
42604
|
+
}
|
|
42324
42605
|
this.diffOptions = {
|
|
42325
|
-
enabled: options.diff?.enabled ??
|
|
42606
|
+
enabled: options.diff?.enabled ?? isPlanApply,
|
|
42326
42607
|
artifact: options.diff?.artifact ?? true,
|
|
42327
42608
|
summary: options.diff?.summary ?? true
|
|
42328
42609
|
};
|
|
@@ -42408,6 +42689,17 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42408
42689
|
...buildWorkflowOptions?.preBuildSteps ?? []
|
|
42409
42690
|
]
|
|
42410
42691
|
});
|
|
42692
|
+
this.planApplyOptions = {
|
|
42693
|
+
applyWorkflowName: options.planApply?.applyWorkflowName ?? `${this.buildWorkflow.name}-apply`,
|
|
42694
|
+
requireCurrentHead: options.planApply?.requireCurrentHead ?? false,
|
|
42695
|
+
verifyArtifactDigest: options.planApply?.verifyArtifactDigest ?? false
|
|
42696
|
+
};
|
|
42697
|
+
if (isPlanApply) {
|
|
42698
|
+
this.applyWorkflow = this.createApplyWorkflow(
|
|
42699
|
+
github,
|
|
42700
|
+
homeRepositoryCondition
|
|
42701
|
+
);
|
|
42702
|
+
}
|
|
42411
42703
|
this.awsDeploymentTargets.forEach((target) => {
|
|
42412
42704
|
const deployJobName = this.buildJobName(target);
|
|
42413
42705
|
const branchFilterCondition = this.buildBranchFilterCondition(
|
|
@@ -42418,27 +42710,31 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42418
42710
|
...homeRepositoryCondition ? [homeRepositoryCondition] : [],
|
|
42419
42711
|
...branchFilterCondition ? [`(${branchFilterCondition})`] : []
|
|
42420
42712
|
].join(" && ") + " }}";
|
|
42421
|
-
|
|
42422
|
-
|
|
42423
|
-
|
|
42424
|
-
|
|
42425
|
-
|
|
42426
|
-
|
|
42427
|
-
|
|
42428
|
-
|
|
42429
|
-
|
|
42430
|
-
|
|
42431
|
-
|
|
42432
|
-
|
|
42433
|
-
|
|
42434
|
-
|
|
42435
|
-
|
|
42436
|
-
|
|
42437
|
-
|
|
42438
|
-
|
|
42439
|
-
|
|
42440
|
-
|
|
42441
|
-
|
|
42713
|
+
if (this.applyWorkflow) {
|
|
42714
|
+
this.addApplyJob(this.applyWorkflow, target, homeRepositoryCondition);
|
|
42715
|
+
} else {
|
|
42716
|
+
const gatedOnDiff = !!this.environmentName && this.diffOptions.enabled;
|
|
42717
|
+
this.buildWorkflow.addPostBuildJob(deployJobName, {
|
|
42718
|
+
name: `Deploy ${this.project.name} ${target.awsStageType}/${target.deploymentTargetRole}/${target.account}/${target.region}`,
|
|
42719
|
+
needs: [
|
|
42720
|
+
"build",
|
|
42721
|
+
...gatedOnDiff ? [this.buildDiffJobName(target)] : [],
|
|
42722
|
+
...this.deployAfterTargets.map((p) => {
|
|
42723
|
+
return this.buildJobName(p);
|
|
42724
|
+
})
|
|
42725
|
+
],
|
|
42726
|
+
runsOn: ["ubuntu-latest"],
|
|
42727
|
+
permissions: {
|
|
42728
|
+
contents: JobPermission5.READ,
|
|
42729
|
+
idToken: JobPermission5.WRITE,
|
|
42730
|
+
pullRequests: JobPermission5.WRITE
|
|
42731
|
+
},
|
|
42732
|
+
...this.environmentName ? { environment: this.environmentName } : void 0,
|
|
42733
|
+
concurrency: deployJobName,
|
|
42734
|
+
if: jobCondition,
|
|
42735
|
+
steps: [...this.deploySteps(target)]
|
|
42736
|
+
});
|
|
42737
|
+
}
|
|
42442
42738
|
if (this.diffOptions.enabled) {
|
|
42443
42739
|
const diffJobName = this.buildDiffJobName(target);
|
|
42444
42740
|
this.buildWorkflow.addPostBuildJob(diffJobName, {
|
|
@@ -42484,7 +42780,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42484
42780
|
|
|
42485
42781
|
// src/workflows/aws-teardown-workflow.ts
|
|
42486
42782
|
import { Component as Component23 } from "projen";
|
|
42487
|
-
import { GitHub as GitHub6, GithubWorkflow } from "projen/lib/github";
|
|
42783
|
+
import { GitHub as GitHub6, GithubWorkflow as GithubWorkflow2 } from "projen/lib/github";
|
|
42488
42784
|
import { JobPermission as JobPermission6 } from "projen/lib/github/workflows-model";
|
|
42489
42785
|
var DEFAULT_TEARDOWN_BRANCH_PATTERNS = [
|
|
42490
42786
|
"feat/*",
|
|
@@ -42549,7 +42845,7 @@ var AwsTeardownWorkflow = class extends Component23 {
|
|
|
42549
42845
|
homeRepository,
|
|
42550
42846
|
"AwsTeardownWorkflow"
|
|
42551
42847
|
);
|
|
42552
|
-
const workflow = new
|
|
42848
|
+
const workflow = new GithubWorkflow2(github, "teardown-dev");
|
|
42553
42849
|
workflow.on({
|
|
42554
42850
|
workflowDispatch: {},
|
|
42555
42851
|
schedule: [
|
|
@@ -43347,6 +43643,7 @@ export {
|
|
|
43347
43643
|
AwsDeploymentConfig,
|
|
43348
43644
|
AwsDeploymentTarget,
|
|
43349
43645
|
AwsTeardownWorkflow,
|
|
43646
|
+
BUILD_ARTIFACT_NAME,
|
|
43350
43647
|
BUILT_IN_BUNDLES,
|
|
43351
43648
|
BUNDLE_OWNERSHIP,
|
|
43352
43649
|
CDK_BOOTSTRAP_DEFAULTS_BY_STAGE,
|
|
@@ -43445,7 +43742,9 @@ export {
|
|
|
43445
43742
|
MONOREPO_LAYOUT,
|
|
43446
43743
|
MonorepoProject,
|
|
43447
43744
|
Nvmrc,
|
|
43745
|
+
PERMISSION_BACKUP_FILE,
|
|
43448
43746
|
PHASE_LABEL_TYPE_MAP,
|
|
43747
|
+
PLAN_RUN_ID_INPUT,
|
|
43449
43748
|
PROD_DEPLOY_NAME,
|
|
43450
43749
|
PROGRESS_FILES_FORMAT_VALUES,
|
|
43451
43750
|
PnpmWorkspace,
|
|
@@ -43479,6 +43778,7 @@ export {
|
|
|
43479
43778
|
TypeScriptConfig,
|
|
43480
43779
|
TypeScriptProject,
|
|
43481
43780
|
UNKNOWN_TYPE_FALLBACK_TIER,
|
|
43781
|
+
VALIDATE_PLAN_JOB_ID,
|
|
43482
43782
|
VALID_PRIORITY_VALUES,
|
|
43483
43783
|
VALID_STATUS_VALUES,
|
|
43484
43784
|
VERSION,
|
|
@@ -43623,6 +43923,7 @@ export {
|
|
|
43623
43923
|
renderNextRequirementIdProcedure,
|
|
43624
43924
|
renderPhaseTypeInvariantSection,
|
|
43625
43925
|
renderPhaseTypeInvariantShellHelpers,
|
|
43926
|
+
renderPlanValidationScript,
|
|
43626
43927
|
renderPriorityRulesSection,
|
|
43627
43928
|
renderProgressFileName,
|
|
43628
43929
|
renderProgressFilePath,
|