@jjrawlins/cdk-diff-pr-github-action 1.8.0 → 1.9.0

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/.jsii CHANGED
@@ -3507,7 +3507,7 @@
3507
3507
  },
3508
3508
  "name": "@jjrawlins/cdk-diff-pr-github-action",
3509
3509
  "readme": {
3510
- "markdown": "# cdk-diff-pr-github-action\n\nA [Projen](https://projen.io/) construct library that surfaces **CloudFormation change set diffs and drift status directly on your pull requests** so reviewers can see exactly what will change before merging.\n\n## Why this exists\n\n`cdk diff` output disappears into CI logs that nobody reads. Meanwhile, a single property change on an RDS instance or EC2 \"pet\" server can trigger a **resource replacement** — destroying the database or instance and recreating it from scratch. If that replacement slips through code review unnoticed, the result is data loss and downtime.\n\nThis construct was built to make those dangerous changes impossible to miss:\n\n- **Replacement column front and center** — Every change set row shows whether CloudFormation will modify the resource in place or **replace** it, with before/after property values so reviewers can understand *why*.\n- **Comment appears on the PR itself** — No digging through workflow logs. The diff table is posted (and updated in place) as a PR comment and in the GitHub Step Summary.\n- **Drift banner** — If the stack has drifted from its template, a warning banner is prepended to the comment so reviewers know the baseline is already out of sync.\n\nIf you have ever lost an EC2 instance, an RDS database, or an ElastiCache cluster to an unexpected CloudFormation replacement, this tool is for you.\n\n---\n\nA library that provides GitHub workflows and IAM templates for:\n- Creating CloudFormation Change Sets for your CDK stacks on pull requests and commenting a formatted diff back on the PR.\n- Detecting CloudFormation drift on a schedule or manual trigger and producing a consolidated summary (optionally creating an issue).\n- Deploying IAM roles across AWS Organizations using StackSets.\n\nIt also provides ready-to-deploy IAM templates with the minimal permissions required for each workflow.\n\n**Works with or without Projen** -- The StackSet generator can be used standalone in any Node.js project.\n\nThis package exposes five constructs:\n\n- `CdkDiffStackWorkflow` — Generates one GitHub Actions workflow per stack to create a change set and render the diff back to the PR and Step Summary.\n- `CdkDiffIamTemplate` — Emits a CloudFormation template file with minimal permissions for the Change Set workflow.\n- `CdkDriftDetectionWorkflow` — Generates a GitHub Actions workflow to detect CloudFormation drift per stack, upload machine‑readable results, and aggregate a summary.\n- `CdkDriftIamTemplate` — Emits a CloudFormation template file with minimal permissions for the Drift Detection workflow.\n- `CdkDiffIamTemplateStackSet` — Creates a CloudFormation StackSet template for org-wide deployment of GitHub OIDC and IAM roles (Projen integration).\n- `CdkDiffIamTemplateStackSetGenerator` — Pure generator class for StackSet templates (no Projen dependency).\n\n## Quick start\n\n1) Add the constructs to your Projen project (in `.projenrc.ts`).\n2) Synthesize with `npx projen`.\n3) Commit the generated files.\n4) Open a pull request or run the drift detection workflow.\n\n## End-to-end example\n\nA realistic setup for a CDK Pipelines project with multiple stages and accounts. This generates one diff workflow per stack, a shared IAM template, and a scheduled drift detection workflow.\n\n```ts\n// .projenrc.ts\nimport { awscdk } from 'projen';\nimport {\n CdkDiffStackWorkflow,\n CdkDiffIamTemplate,\n CdkDriftDetectionWorkflow,\n} from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkTypeScriptApp({\n name: 'my-data-platform',\n defaultReleaseBranch: 'main',\n cdkVersion: '2.170.0',\n github: true,\n});\n\n// --- Change Set Diff Workflows (one per stack) ---\n// stackName is the CDK construct path used with `cdk deploy <target>`.\n// For CDK Pipelines, this is typically: pipeline/Stage/Stack\n// The construct automatically resolves the real CloudFormation stack name\n// from cdk.out at runtime (e.g., \"my-stage-dev-my-stack\").\n\nnew CdkDiffStackWorkflow({\n project,\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'my-pipeline/dev/DatabaseStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n {\n stackName: 'my-pipeline/dev/ComputeStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n {\n // Cross-account: prod stacks can use a different OIDC role and region\n stackName: 'my-pipeline/prod/DatabaseStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n oidcRoleArn: 'arn:aws:iam::222222222222:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n },\n ],\n});\n\n// --- IAM Template (deploy once per account) ---\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n githubOidc: {\n owner: 'my-org',\n repositories: ['my-data-platform'],\n branches: ['main'],\n },\n});\n\n// --- Drift Detection (scheduled + manual) ---\nnew CdkDriftDetectionWorkflow({\n project,\n schedule: '0 6 * * 1', // Every Monday at 6 AM UTC\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'dev-DatabaseStack',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkDriftRole',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n\nproject.synth();\n```\n\nAfter `npx projen`, this generates:\n- `.github/workflows/diff-my-pipeline-dev-databasestack.yml`\n- `.github/workflows/diff-my-pipeline-dev-computestack.yml`\n- `.github/workflows/diff-my-pipeline-prod-databasestack.yml`\n- `.github/workflows/scripts/describe-cfn-changeset.ts`\n- `.github/workflows/drift-detection.yml`\n- `.github/workflows/scripts/detect-drift.ts`\n- `cdk-diff-workflow-iam-template.yaml`\n\nWhen a pull request is opened, each diff workflow runs automatically and posts a comment like this:\n\n| Action | ID | Type | Replacement | Details |\n|--------|-----|------|-------------|---------|\n| 🔵 Modify | MyDatabase | AWS::RDS::DBInstance | **True** | 🔵 **DBInstanceClass**: `db.t3.medium` -> `db.t3.large` |\n| 🔵 Modify | MyFunction | AWS::Lambda::Function | False | 🔵 **Runtime**: `nodejs18.x` -> `nodejs20.x` |\n\nThe **Replacement: True** on the RDS instance is exactly the kind of change this tool is designed to catch before it reaches production.\n\n## Usage: CdkDiffStackWorkflow\n\n`CdkDiffStackWorkflow` renders a workflow per stack named `diff-<StackName>.yml` under `.github/workflows/`. It also generates a helper script at `.github/workflows/scripts/describe-cfn-changeset.ts` that formats the change set output and takes care of posting the PR comment and Step Summary.\n\nExample `.projenrc.ts`:\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffStackWorkflow } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ... your usual settings ...\n workflowName: 'my-lib',\n defaultReleaseBranch: 'main',\n cdkVersion: '2.85.0',\n github: true,\n});\n\nnew CdkDiffStackWorkflow({\n project,\n stacks: [\n {\n stackName: 'MyAppStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::123456789012:role/cdk-diff-role',\n changesetRoleToAssumeRegion: 'us-east-1',\n // Optional per‑stack OIDC override (if not using the defaults below)\n // oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n // oidcRegion: 'us-east-1',\n },\n ],\n // Default OIDC role/region used by all stacks unless overridden per‑stack\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: Node version used in the workflow (default: '24.x')\n // nodeVersion: '24.x',\n // Optional: Yarn command to run CDK (default: 'cdk')\n // cdkYarnCommand: 'cdk',\n // Optional: Where to place the helper script (default: '.github/workflows/scripts/describe-cfn-changeset.ts')\n // scriptOutputPath: '.github/workflows/scripts/describe-cfn-changeset.ts',\n});\n\nproject.synth();\n```\n\n### CdkDiffStackWorkflow props\n- `project` (required) — Your Projen project instance.\n- `stacks` (required) — Array of stack entries.\n- `oidcRoleArn` (required unless provided per‑stack) — Default OIDC role ARN.\n- `oidcRegion` (required unless provided per‑stack) — Default OIDC region.\n- `nodeVersion` (optional, default `'24.x'`) — Node.js version for the workflow runner.\n- `cdkYarnCommand` (optional, default `'cdk'`) — Yarn script/command to invoke CDK.\n- `scriptOutputPath` (optional, default `'.github/workflows/scripts/describe-cfn-changeset.ts'`) — Where to write the helper script.\n- `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs so `install`, `synth`, and `deploy` steps run in that directory. The describe-changeset script path is automatically prefixed with `$GITHUB_WORKSPACE/` and `NODE_PATH` is set to resolve modules from the working directory.\n\nIf neither top‑level OIDC defaults nor all per‑stack values are supplied, the construct throws a helpful error.\n\n### Stack item fields\n- `stackName` (required) — The CDK stack name to create the change set for.\n- `changesetRoleToAssumeArn` (required) — The ARN of the role used to create the change set (role chaining after OIDC).\n- `changesetRoleToAssumeRegion` (required) — The region for that role.\n- `oidcRoleArn` (optional) — Per‑stack override for the OIDC role.\n- `oidcRegion` (optional) — Per‑stack override for the OIDC region.\n\n### What gets generated\n- `.github/workflows/diff-<StackName>.yml` — One workflow per stack, triggered on PR open/sync/reopen.\n- `.github/workflows/scripts/describe-cfn-changeset.ts` — A helper script that:\n - Polls `DescribeChangeSet` until terminal\n - Filters out ignorable logical IDs or resource types using environment variables `IGNORE_LOGICAL_IDS` and `IGNORE_RESOURCE_TYPES`\n - Renders an HTML table with actions, logical IDs, types, replacements, and changed properties\n - **Checks cached drift status** via `DescribeStacks` — if the stack has drifted, a warning banner with drifted resource details is prepended to the output (non-fatal; degrades gracefully if IAM permissions are missing)\n - Prints the HTML and appends to the GitHub Step Summary\n - **Upserts the PR comment** — uses an HTML marker (`<!-- cdk-diff:stack:STACK_NAME -->`) to find and update an existing comment instead of creating duplicates on every push\n\n### Change Set Output Format\n\nThe change set script uses the CloudFormation `IncludePropertyValues` API feature to show **actual before/after values** for changed properties, not just property names.\n\n**Example PR comment:**\n\n> **Warning: Stack has drifted (2 resources out of sync)**\n>\n> Last drift check: 2025-01-15T10:30:00.000Z\n>\n> <details><summary>View drifted resources</summary>\n>\n> | Resource | Type | Drift Status |\n> |----------|------|-------------|\n> | MySecurityGroup | AWS::EC2::SecurityGroup | MODIFIED |\n> | OldBucket | AWS::S3::Bucket | DELETED |\n> </details>\n\n| Action | ID | Type | Replacement | Details |\n|--------|-----|------|-------------|---------|\n| 🔵 Modify | MyDatabase | AWS::RDS::DBInstance | **True** | 🔵 **DBInstanceClass**: `db.t3.medium` -> `db.t3.large` |\n| 🔵 Modify | MyLambdaFunction | AWS::Lambda::Function | False | 🔵 **Runtime**: `nodejs18.x` -> `nodejs20.x` |\n| 🟢 Add | NewSecurityGroup | AWS::EC2::SecurityGroup | - | |\n| 🔴 Remove | OldRole | AWS::IAM::Role | - | |\n\n**Features:**\n- **Replacement column** highlights when CloudFormation will **destroy and recreate** a resource — critical for stateful resources like databases, EC2 instances, and file systems\n- **Drift banner** — if the stack has drifted, a warning with drifted resource details appears above the change set table so reviewers know the baseline state\n- **Comment upsert** — each stack's comment is updated in place on subsequent pushes instead of creating duplicates; uses an HTML marker for reliable find-and-replace\n- **Color-coded indicators**: 🟢 Added, 🔵 Modified, 🔴 Removed\n- **Inline values for small changes**: Shows `before -> after` directly in the table\n- **Collapsible details for large values**: IAM policies, tags, and other large JSON values are wrapped in expandable `<details>` elements to keep the table readable\n- **All attribute types supported**: Properties, Tags, Metadata, etc.\n- **HTML-escaped values**: Prevents XSS from property values\n\n### Environment variables used by the change set script\n- `STACK_NAME` (required) — Stack name to describe.\n- `CHANGE_SET_NAME` (default: same as `STACK_NAME`).\n- `AWS_REGION` — Region for CloudFormation API calls. The workflow sets this via the credentials action(s).\n- `GITHUB_TOKEN` (optional) — If set with `GITHUB_COMMENT_URL`, posts a PR comment.\n- `GITHUB_COMMENT_URL` (optional) — PR comments URL.\n- `GITHUB_STEP_SUMMARY` (optional) — When present, appends the HTML to the step summary file.\n- `IGNORE_LOGICAL_IDS` (optional) — Comma‑separated logical IDs to ignore (default includes `CDKMetadata`).\n- `IGNORE_RESOURCE_TYPES` (optional) — Comma‑separated resource types to ignore (e.g., `AWS::CDK::Metadata`).\n\n## Usage: CdkDiffIamTemplate\n\nEmit an IAM template you can deploy in your account for the Change Set workflow. Supports two modes:\n\n1. **External OIDC Role** — Reference an existing GitHub OIDC role (original behavior)\n2. **Self-Contained** — Create the GitHub OIDC provider and role within the same template (new)\n\n### Option 1: Using an Existing OIDC Role (External)\n\nUse this when you already have a GitHub OIDC provider and role set up in your account.\n\n#### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDiffIamTemplate({\n project,\n roleName: 'cdk-diff-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: custom output path (default: 'cdk-diff-workflow-iam-template.yaml')\n // outputPath: 'infra/cdk-diff-iam.yaml',\n});\n\nproject.synth();\n```\n\n#### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDiffIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDiffIamTemplateGenerator.generateTemplate({\n roleName: 'cdk-diff-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n});\n\nfs.writeFileSync('cdk-diff-iam-template.yaml', template);\n```\n\n### Option 2: Self-Contained Template (Create OIDC Role)\n\nUse this when you want a single template that creates everything needed — the GitHub OIDC provider, OIDC role, and changeset role. This simplifies deployment and pairs well with the `CdkDiffStackWorkflow`.\n\n#### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n oidcRoleName: 'GitHubOIDCRole', // Optional, default: 'GitHubOIDCRole'\n githubOidc: {\n owner: 'my-org', // GitHub org or username\n repositories: ['infra-repo', 'app-repo'], // Repos allowed to assume roles\n branches: ['main', 'release/*'], // Branch patterns (default: ['*'])\n },\n // Optional: Skip OIDC provider creation if it already exists\n // skipOidcProviderCreation: true,\n});\n\nproject.synth();\n```\n\n#### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDiffIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDiffIamTemplateGenerator.generateTemplate({\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n oidcRoleName: 'GitHubOIDCRole',\n githubOidc: {\n owner: 'my-org',\n repositories: ['infra-repo'],\n branches: ['main'],\n },\n});\n\nfs.writeFileSync('cdk-diff-iam-template.yaml', template);\n```\n\n#### With Existing OIDC Provider (Skip Creation)\n\nIf your account already has a GitHub OIDC provider but you want the template to create the roles:\n\n```ts\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n skipOidcProviderCreation: true, // Account already has OIDC provider\n githubOidc: {\n owner: 'my-org',\n repositories: ['*'], // All repos in org\n },\n});\n```\n\n### Deploy Task\n\nA Projen task is added for easy deployment:\n\n```bash\nnpx projen deploy-cdkdiff-iam-template -- --parameter-overrides GitHubOIDCRoleArn=... # plus any extra AWS CLI args\n```\n\n### CdkDiffIamTemplate Props\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `roleName` | `string` | Name for the changeset IAM role (required) |\n| `oidcRoleArn` | `string?` | ARN of existing GitHub OIDC role. Required when `createOidcRole` is false. |\n| `oidcRegion` | `string?` | Region for OIDC trust condition. Required when `createOidcRole` is false. |\n| `createOidcRole` | `boolean?` | Create OIDC role within template (default: false) |\n| `oidcRoleName` | `string?` | Name of OIDC role to create (default: 'GitHubOIDCRole') |\n| `githubOidc` | `GitHubOidcConfig?` | GitHub OIDC config. Required when `createOidcRole` is true. |\n| `skipOidcProviderCreation` | `boolean?` | Skip OIDC provider if it exists (default: false) |\n| `outputPath` | `string?` | Template output path (default: 'cdk-diff-workflow-iam-template.yaml') |\n\n### What the Template Creates\n\n**External OIDC Role mode:**\n- Parameter `GitHubOIDCRoleArn` — ARN of your existing GitHub OIDC role\n- IAM role `CdkChangesetRole` with minimal permissions for change set operations\n- Outputs: `CdkChangesetRoleArn`, `CdkChangesetRoleName`\n\n**Self-Contained mode (`createOidcRole: true`):**\n- GitHub OIDC Provider (unless `skipOidcProviderCreation: true`)\n- IAM role `GitHubOIDCRole` with trust policy for GitHub Actions\n- IAM role `CdkChangesetRole` with minimal permissions (trusts the OIDC role)\n- Outputs: `GitHubOIDCProviderArn`, `GitHubOIDCRoleArn`, `GitHubOIDCRoleName`, `CdkChangesetRoleArn`, `CdkChangesetRoleName`\n\n**Changeset Role Permissions:**\n- CloudFormation Change Set operations\n- Access to CDK bootstrap S3 buckets and SSM parameters\n- `iam:PassRole` to `cloudformation.amazonaws.com`\n\nUse the created changeset role ARN as `changesetRoleToAssumeArn` in `CdkDiffStackWorkflow`.\n\n---\n\n## Usage: CdkDriftDetectionWorkflow\n\n`CdkDriftDetectionWorkflow` creates a single workflow file (default `drift-detection.yml`) that can run on a schedule and via manual dispatch. It generates a helper script at `.github/workflows/scripts/detect-drift.ts` (by default) that uses AWS SDK v3 to run drift detection, write optional machine‑readable JSON, and print an HTML report for the Step Summary.\n\nExample `.projenrc.ts`:\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDriftDetectionWorkflow } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({ github: true, /* ... */ });\n\nnew CdkDriftDetectionWorkflow({\n project,\n workflowName: 'Drift Detection', // optional; file name derived as 'drift-detection.yml'\n schedule: '0 1 * * *', // optional cron\n createIssues: true, // default true; create/update issue when drift detected on schedule\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: Node version (default '24.x')\n // nodeVersion: '24.x',\n // Optional: Where to place the helper script (default '.github/workflows/scripts/detect-drift.ts')\n // scriptOutputPath: '.github/workflows/scripts/detect-drift.ts',\n stacks: [\n {\n stackName: 'MyAppStack-Prod',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::123456789012:role/cdk-drift-role',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n // failOnDrift: true, // optional (default true)\n },\n ],\n});\n\nproject.synth();\n```\n\n### CdkDriftDetectionWorkflow props\n- `project` (required) — Your Projen project instance.\n- `stacks` (required) — Array of stacks to check.\n- `oidcRoleArn` (required) — Default OIDC role ARN used before chaining into per‑stack drift roles.\n- `oidcRegion` (required) — Default OIDC region.\n- `workflowName` (optional, default `'drift-detection'`) — Human‑friendly workflow name; the file name is derived in kebab‑case.\n- `schedule` (optional) — Cron expression for automatic runs.\n- `createIssues` (optional, default `true`) — When true, scheduled runs will create/update a GitHub issue if drift is detected.\n- `nodeVersion` (optional, default `'24.x'`) — Node.js version for the runner.\n- `scriptOutputPath` (optional, default `'.github/workflows/scripts/detect-drift.ts'`) — Where to write the helper script.\n- `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs. Artifact upload and issue-script paths are automatically prefixed.\n\n### Per‑stack fields\n- `stackName` (required) — The full CloudFormation stack name.\n- `driftDetectionRoleToAssumeArn` (required) — Role to assume (after OIDC) for making drift API calls.\n- `driftDetectionRoleToAssumeRegion` (required) — Region for that role and API calls.\n- `failOnDrift` (optional, default `true`) — Intended to fail the detection step on drift. The provided script exits with non‑zero when drift is found; the job continues to allow artifact upload and issue creation.\n\n### What gets generated\n- `.github/workflows/<kebab(workflowName)>.yml` — A workflow with one job per stack plus a final summary job.\n- `.github/workflows/scripts/detect-drift.ts` — Helper script that:\n - Starts drift detection and polls until completion\n - Lists non‑`IN_SYNC` resources and builds an HTML report\n - Writes optional JSON to `DRIFT_DETECTION_OUTPUT` when set\n - Prints to stdout and appends to the GitHub Step Summary when available\n\n### Artifacts and summary\n- Each stack job uploads `drift-results-<stack>.json` (if produced).\n- A final `Drift Detection Summary` job downloads all artifacts and prints a consolidated summary.\n\n### Manual dispatch\n- The workflow exposes an input named `stack` with choices including each configured stack and an `all` option.\n- Choose a specific stack to run drift detection for that stack only, or select `all` (or leave the input empty) to run all stacks.\n\nNote: The default workflow does not post PR comments for drift. It can create/update an Issue on scheduled runs when `createIssues` is `true`.\n\n### Post-notification steps (e.g., Slack)\n\nYou can add your own GitHub Action steps to run after the drift detection step for each stack using `postGitHubSteps`.\nProvide your own Slack payload/markdown (this library no longer generates a payload step for you).\n\nOption A: slackapi/slack-github-action (Incoming Webhook, official syntax)\n\n```ts\nnew CdkDriftDetectionWorkflow({\n project,\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n stacks: [/* ... */],\n postGitHubSteps: ({ stack }) => {\n // Build a descriptive name per stack\n const name = `Notify Slack (${stack} post-drift)`;\n const step = {\n name,\n uses: 'slackapi/slack-github-action@v2.1.1',\n // by default, post steps run only when drift is detected; you can override `if`\n if: \"always() && steps.drift.outcome == 'failure'\",\n // Use official inputs: webhook + webhook-type, and a YAML payload with blocks\n with: {\n webhook: '${{ secrets.CDK_NOTIFICATIONS_SLACK_WEBHOOK }}',\n 'webhook-type': 'incoming-webhook',\n payload: [\n 'text: \"** ${{ env.STACK_NAME }} ** has drifted!\"',\n 'blocks:',\n ' - type: \"section\"',\n ' text:',\n ' type: \"mrkdwn\"',\n ' text: \"*Stack:* ${{ env.STACK_NAME }} (region ${{ env.AWS_REGION }}) has drifted:exclamation:\"',\n ' - type: \"section\"',\n ' fields:',\n ' - type: \"mrkdwn\"',\n ' text: \"*Stack ARN*\\\\n${{ steps.drift.outputs.stack-arn }}\"',\n ' - type: \"mrkdwn\"',\n ' text: \"*Issue*\\\\n<${{ github.server_url }}/${{ github.repository }}/issues/${{ steps.issue.outputs.result }}|#${{ steps.issue.outputs.result }}>\"',\n ].join('\\n'),\n },\n };\n return [step];\n },\n});\n```\n\nNote: The Issue link requires `createIssues: true` (default) so that the `Create Issue on Drift` step runs before this Slack step and exposes `steps.issue.outputs.result`. This library orders the steps accordingly.\n\nDetails:\n- `postGitHubSteps` can be:\n - an array of step objects, or\n - a factory function `({ stack }) => step | step[]`.\n- Each step you provide is inserted after the results are uploaded.\n- Default condition: if you do not set `if` on your step, it will default to `always() && steps.drift.outcome == 'failure'`.\n- Available context/env you can use:\n - `${{ env.STACK_NAME }}`, `${{ env.DRIFT_DETECTION_OUTPUT }}`\n - `${{ steps.drift.outcome }}` — success/failure of the detect step\n - `${{ steps.drift.outputs.stack-arn }}` — Stack ARN resolved at runtime\n - `${{ steps.issue.outputs.result }}` — Issue number if the workflow created/found one (empty when not applicable)\n```\n\n## Usage: CdkDriftIamTemplate\n\nEmit an example IAM template you can deploy in your account for the Drift Detection workflow.\n\n### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDriftIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDriftIamTemplate({\n project,\n roleName: 'cdk-drift-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: custom output path (default: 'cdk-drift-workflow-iam-template.yaml')\n // outputPath: 'infra/cdk-drift-iam.yaml',\n});\n\nproject.synth();\n```\n\nA Projen task is also added:\n\n```bash\nnpx projen deploy-cdkdrift-iam-template -- --parameter-overrides GitHubOIDCRoleArn=... # plus any extra AWS CLI args\n```\n\n### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDriftIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDriftIamTemplateGenerator.generateTemplate({\n roleName: 'cdk-drift-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n});\n\nfs.writeFileSync('cdk-drift-iam-template.yaml', template);\n\n// Get the deploy command\nconst deployCmd = CdkDriftIamTemplateGenerator.generateDeployCommand('cdk-drift-iam-template.yaml');\nconsole.log('Deploy with:', deployCmd);\n```\n\n### What the template defines\n\n- Parameter `GitHubOIDCRoleArn` with a default from `oidcRoleArn` — the ARN of your existing GitHub OIDC role allowed to assume this drift role.\n- IAM role `CdkDriftRole` with minimal permissions for CloudFormation drift detection operations.\n- Outputs exporting the role name and ARN.\n\n---\n\n## Usage: CdkDiffIamTemplateStackSet (Org-Wide Deployment)\n\n`CdkDiffIamTemplateStackSet` creates a CloudFormation StackSet template for deploying GitHub OIDC provider, OIDC role, and CDK diff/drift IAM roles across an entire AWS Organization. This is the recommended approach for organizations that want to enable CDK diff/drift workflows across multiple accounts.\n\n### Architecture\n\nEach account in your organization gets:\n- **GitHub OIDC Provider** — Authenticates GitHub Actions workflows\n- **GitHubOIDCRole** — Trusts the OIDC provider with repo/branch restrictions\n- **CdkChangesetRole** — For PR change set previews (trusts GitHubOIDCRole)\n- **CdkDriftRole** — For drift detection (trusts GitHubOIDCRole)\n\nThis is a self-contained deployment with **no role chaining required**.\n\n### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplateStackSet } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({ /* ... */ });\n\nnew CdkDiffIamTemplateStackSet({\n project,\n githubOidc: {\n owner: 'my-org', // GitHub org or username\n repositories: ['infra-repo', 'app-repo'], // Repos allowed to assume roles\n branches: ['main', 'release/*'], // Branch patterns (default: ['*'])\n },\n targetOrganizationalUnitIds: ['ou-xxxx-xxxxxxxx'], // Target OUs\n regions: ['us-east-1', 'eu-west-1'], // Target regions\n // Optional settings:\n // oidcRoleName: 'GitHubOIDCRole', // default\n // changesetRoleName: 'CdkChangesetRole', // default\n // driftRoleName: 'CdkDriftRole', // default\n // roleSelection: StackSetRoleSelection.BOTH, // BOTH, CHANGESET_ONLY, or DRIFT_ONLY\n // delegatedAdmin: true, // Use --call-as DELEGATED_ADMIN (default: true)\n});\n\nproject.synth();\n```\n\nThis creates:\n- `cdk-diff-workflow-stackset-template.yaml` — CloudFormation template\n- Projen tasks for StackSet management\n\n**Projen tasks:**\n```bash\nnpx projen stackset-create # Create the StackSet\nnpx projen stackset-update # Update the StackSet template\nnpx projen stackset-deploy-instances # Deploy to target OUs/regions\nnpx projen stackset-delete-instances # Remove stack instances\nnpx projen stackset-delete # Delete the StackSet\nnpx projen stackset-describe # Show StackSet status\nnpx projen stackset-list-instances # List all instances\n```\n\n### Without Projen (Standalone Generator)\n\nFor non-Projen projects, use `CdkDiffIamTemplateStackSetGenerator` directly:\n\n```ts\nimport {\n CdkDiffIamTemplateStackSetGenerator\n} from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\n// Generate the CloudFormation template\nconst template = CdkDiffIamTemplateStackSetGenerator.generateTemplate({\n githubOidc: {\n owner: 'my-org',\n repositories: ['infra-repo'],\n branches: ['main'],\n },\n});\n\n// Write to file\nfs.writeFileSync('stackset-template.yaml', template);\n\n// Get AWS CLI commands for StackSet operations\nconst commands = CdkDiffIamTemplateStackSetGenerator.generateCommands({\n stackSetName: 'cdk-diff-workflow-iam-stackset',\n templatePath: 'stackset-template.yaml',\n targetOrganizationalUnitIds: ['ou-xxxx-xxxxxxxx'],\n regions: ['us-east-1'],\n});\n\nconsole.log('Create StackSet:', commands['stackset-create']);\nconsole.log('Deploy instances:', commands['stackset-deploy-instances']);\n```\n\n### GitHub Actions Workflow (Simplified)\n\nWith per-account OIDC, your workflow is simplified — no role chaining needed:\n\n```yaml\njobs:\n diff:\n runs-on: ubuntu-latest\n permissions:\n id-token: write\n contents: read\n steps:\n - uses: actions/checkout@v4\n\n - uses: aws-actions/configure-aws-credentials@v4\n with:\n role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubOIDCRole\n aws-region: us-east-1\n\n - name: Assume Changeset Role\n run: |\n CREDS=$(aws sts assume-role \\\n --role-arn arn:aws:iam::${{ env.ACCOUNT_ID }}:role/CdkChangesetRole \\\n --role-session-name changeset-session)\n # Export credentials...\n```\n\n### GitHubOidcConfig options\n\n| Property | Description |\n|----------|-------------|\n| `owner` | GitHub organization or username (required) |\n| `repositories` | Array of repo names, or `['*']` for all repos (required) |\n| `branches` | Array of branch patterns (default: `['*']`) |\n| `additionalClaims` | Extra OIDC claims like `['pull_request', 'environment:production']` |\n\n---\n\n## Testing\n\nThis repository includes Jest tests that snapshot the synthesized outputs from Projen and assert that:\n- Diff workflows are created per stack and contain all expected steps.\n- Drift detection workflow produces one job per stack and a summary job.\n- Only one helper script file is generated per workflow type.\n- Per‑stack OIDC overrides (where supported) are respected.\n- Helpful validation errors are thrown for missing OIDC settings.\n- The IAM template files contain the expected resources and outputs.\n\nRun tests with:\n\n```bash\nyarn test\n```\n\n## Monorepo support\n\nIf your CDK app lives in a subdirectory (e.g., `infra/`), use the `workingDirectory` option:\n\n```ts\nnew CdkDiffStackWorkflow({\n project,\n workingDirectory: 'infra',\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'MyStack-dev',\n changesetRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n\nnew CdkDriftDetectionWorkflow({\n project,\n workingDirectory: 'infra',\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'MyStack-dev',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkDriftRole',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n```\n\nThis sets `defaults.run.working-directory: infra` on all workflow jobs so that `install`, `synth`, and `deploy` steps run in the correct directory. The describe-changeset and detect-drift scripts are referenced with absolute paths so they resolve correctly from the subdirectory.\n\n**Note:** Your `infra/package.json` must include `@aws-sdk/client-cloudformation` as a dependency for the describe-changeset script to resolve modules at runtime.\n\n## Notes\n- This package assumes your repository is configured with GitHub Actions and that you have a GitHub OIDC role configured in AWS.\n- The generated scripts use the AWS SDK v3 for CloudFormation and, where applicable, the GitHub REST API.\n"
3510
+ "markdown": "# cdk-diff-pr-github-action\n\nA [Projen](https://projen.io/) construct library that surfaces **CloudFormation change set diffs and drift status directly on your pull requests** so reviewers can see exactly what will change before merging.\n\n## Why this exists\n\n`cdk diff` output disappears into CI logs that nobody reads. Meanwhile, a single property change on an RDS instance or EC2 \"pet\" server can trigger a **resource replacement** — destroying the database or instance and recreating it from scratch. If that replacement slips through code review unnoticed, the result is data loss and downtime.\n\nThis construct was built to make those dangerous changes impossible to miss:\n\n- **Replacement column front and center** — Every change set row shows whether CloudFormation will modify the resource in place or **replace** it, with before/after property values so reviewers can understand *why*.\n- **Comment appears on the PR itself** — No digging through workflow logs. The diff table is posted (and updated in place) as a PR comment and in the GitHub Step Summary.\n- **Drift banner** — If the stack has drifted from its template, a warning banner is prepended to the comment so reviewers know the baseline is already out of sync.\n\nIf you have ever lost an EC2 instance, an RDS database, or an ElastiCache cluster to an unexpected CloudFormation replacement, this tool is for you.\n\n---\n\nA library that provides GitHub workflows and IAM templates for:\n- Creating CloudFormation Change Sets for your CDK stacks on pull requests and commenting a formatted diff back on the PR.\n- Detecting CloudFormation drift on a schedule or manual trigger and producing a consolidated summary (optionally creating an issue).\n- Deploying IAM roles across AWS Organizations using StackSets.\n\nIt also provides ready-to-deploy IAM templates with the minimal permissions required for each workflow.\n\n**Works with or without Projen** -- The StackSet generator can be used standalone in any Node.js project.\n\nThis package exposes five constructs:\n\n- `CdkDiffStackWorkflow` — Generates one GitHub Actions workflow per stack to create a change set and render the diff back to the PR and Step Summary.\n- `CdkDiffIamTemplate` — Emits a CloudFormation template file with minimal permissions for the Change Set workflow.\n- `CdkDriftDetectionWorkflow` — Generates a GitHub Actions workflow to detect CloudFormation drift per stack, upload machine‑readable results, and aggregate a summary.\n- `CdkDriftIamTemplate` — Emits a CloudFormation template file with minimal permissions for the Drift Detection workflow.\n- `CdkDiffIamTemplateStackSet` — Creates a CloudFormation StackSet template for org-wide deployment of GitHub OIDC and IAM roles (Projen integration).\n- `CdkDiffIamTemplateStackSetGenerator` — Pure generator class for StackSet templates (no Projen dependency).\n\n## Quick start\n\n1) Add the constructs to your Projen project (in `.projenrc.ts`).\n2) Synthesize with `npx projen`.\n3) Commit the generated files.\n4) Open a pull request or run the drift detection workflow.\n\n## End-to-end example\n\nA realistic setup for a CDK Pipelines project with multiple stages and accounts. This generates one diff workflow per stack, a shared IAM template, and a scheduled drift detection workflow.\n\n```ts\n// .projenrc.ts\nimport { awscdk } from 'projen';\nimport {\n CdkDiffStackWorkflow,\n CdkDiffIamTemplate,\n CdkDriftDetectionWorkflow,\n} from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkTypeScriptApp({\n name: 'my-data-platform',\n defaultReleaseBranch: 'main',\n cdkVersion: '2.170.0',\n github: true,\n});\n\n// --- Change Set Diff Workflows (one per stack) ---\n// stackName is the CDK construct path used with `cdk deploy <target>`.\n// For CDK Pipelines, this is typically: pipeline/Stage/Stack\n// The construct automatically resolves the real CloudFormation stack name\n// from cdk.out at runtime (e.g., \"my-stage-dev-my-stack\").\n\nnew CdkDiffStackWorkflow({\n project,\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'my-pipeline/dev/DatabaseStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n {\n stackName: 'my-pipeline/dev/ComputeStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n {\n // Cross-account: prod stacks can use a different OIDC role and region\n stackName: 'my-pipeline/prod/DatabaseStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n oidcRoleArn: 'arn:aws:iam::222222222222:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n },\n ],\n});\n\n// --- IAM Template (deploy once per account) ---\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n githubOidc: {\n owner: 'my-org',\n repositories: ['my-data-platform'],\n branches: ['main'],\n },\n});\n\n// --- Drift Detection (scheduled + manual) ---\nnew CdkDriftDetectionWorkflow({\n project,\n schedule: '0 6 * * 1', // Every Monday at 6 AM UTC\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'dev-DatabaseStack',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::111111111111:role/CdkDriftRole',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n\nproject.synth();\n```\n\nAfter `npx projen`, this generates:\n- `.github/workflows/diff-my-pipeline-dev-databasestack.yml`\n- `.github/workflows/diff-my-pipeline-dev-computestack.yml`\n- `.github/workflows/diff-my-pipeline-prod-databasestack.yml`\n- `.github/workflows/scripts/describe-cfn-changeset.ts`\n- `.github/workflows/drift-detection.yml`\n- `.github/workflows/scripts/detect-drift.ts`\n- `cdk-diff-workflow-iam-template.yaml`\n\nWhen a pull request is opened, each diff workflow runs automatically and posts a comment like this:\n\n| Action | ID | Type | Replacement | Details |\n|--------|-----|------|-------------|---------|\n| 🔵 Modify | MyDatabase | AWS::RDS::DBInstance | **True** | 🔵 **DBInstanceClass**: `db.t3.medium` -> `db.t3.large` |\n| 🔵 Modify | MyFunction | AWS::Lambda::Function | False | 🔵 **Runtime**: `nodejs18.x` -> `nodejs20.x` |\n\nThe **Replacement: True** on the RDS instance is exactly the kind of change this tool is designed to catch before it reaches production.\n\n## Usage: CdkDiffStackWorkflow\n\n`CdkDiffStackWorkflow` renders a workflow per stack named `diff-<StackName>.yml` under `.github/workflows/`. It also generates a helper script at `.github/workflows/scripts/describe-cfn-changeset.ts` that formats the change set output and takes care of posting the PR comment and Step Summary.\n\nExample `.projenrc.ts`:\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffStackWorkflow } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ... your usual settings ...\n workflowName: 'my-lib',\n defaultReleaseBranch: 'main',\n cdkVersion: '2.85.0',\n github: true,\n});\n\nnew CdkDiffStackWorkflow({\n project,\n stacks: [\n {\n stackName: 'MyAppStack',\n changesetRoleToAssumeArn: 'arn:aws:iam::123456789012:role/cdk-diff-role',\n changesetRoleToAssumeRegion: 'us-east-1',\n // Optional per‑stack OIDC override (if not using the defaults below)\n // oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n // oidcRegion: 'us-east-1',\n },\n ],\n // Default OIDC role/region used by all stacks unless overridden per‑stack\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: Node version used in the workflow (default: '24.x')\n // nodeVersion: '24.x',\n // Optional: Yarn command to run CDK (default: 'cdk')\n // cdkYarnCommand: 'cdk',\n // Optional: Where to place the helper script (default: '.github/workflows/scripts/describe-cfn-changeset.ts')\n // scriptOutputPath: '.github/workflows/scripts/describe-cfn-changeset.ts',\n});\n\nproject.synth();\n```\n\n### CdkDiffStackWorkflow props\n- `project` (required) — Your Projen project instance.\n- `stacks` (required) — Array of stack entries.\n- `oidcRoleArn` (required unless provided per‑stack) — Default OIDC role ARN.\n- `oidcRegion` (required unless provided per‑stack) — Default OIDC region.\n- `nodeVersion` (optional, default `'24.x'`) — Node.js version for the workflow runner.\n- `cdkYarnCommand` (optional, default `'cdk'`) — Yarn script/command to invoke CDK.\n- `scriptOutputPath` (optional, default `'.github/workflows/scripts/describe-cfn-changeset.ts'`) — Where to write the helper script.\n- `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs so `install`, `synth`, and `deploy` steps run in that directory. The describe-changeset script path is automatically prefixed with `$GITHUB_WORKSPACE/` and `NODE_PATH` is set to resolve modules from the working directory.\n- `preGitHubSteps` (optional) — Additional steps to run after install but before AWS credentials and CDK operations. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`.\n- `postGitHubSteps` (optional) — Additional steps to run after all CDK operations complete. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`.\n\nIf neither top‑level OIDC defaults nor all per‑stack values are supplied, the construct throws a helpful error.\n\n### Stack item fields\n- `stackName` (required) — The CDK stack name to create the change set for.\n- `changesetRoleToAssumeArn` (required) — The ARN of the role used to create the change set (role chaining after OIDC).\n- `changesetRoleToAssumeRegion` (required) — The region for that role.\n- `oidcRoleArn` (optional) — Per‑stack override for the OIDC role.\n- `oidcRegion` (optional) — Per‑stack override for the OIDC region.\n\n### What gets generated\n- `.github/workflows/diff-<StackName>.yml` — One workflow per stack, triggered on PR open/sync/reopen.\n- `.github/workflows/scripts/describe-cfn-changeset.ts` — A helper script that:\n - Polls `DescribeChangeSet` until terminal\n - Filters out ignorable logical IDs or resource types using environment variables `IGNORE_LOGICAL_IDS` and `IGNORE_RESOURCE_TYPES`\n - Renders an HTML table with actions, logical IDs, types, replacements, and changed properties\n - **Checks cached drift status** via `DescribeStacks` — if the stack has drifted, a warning banner with drifted resource details is prepended to the output (non-fatal; degrades gracefully if IAM permissions are missing)\n - Prints the HTML and appends to the GitHub Step Summary\n - **Upserts the PR comment** — uses an HTML marker (`<!-- cdk-diff:stack:STACK_NAME -->`) to find and update an existing comment instead of creating duplicates on every push\n\n### Change Set Output Format\n\nThe change set script uses the CloudFormation `IncludePropertyValues` API feature to show **actual before/after values** for changed properties, not just property names.\n\n**Example PR comment:**\n\n> **Warning: Stack has drifted (2 resources out of sync)**\n>\n> Last drift check: 2025-01-15T10:30:00.000Z\n>\n> <details><summary>View drifted resources</summary>\n>\n> | Resource | Type | Drift Status |\n> |----------|------|-------------|\n> | MySecurityGroup | AWS::EC2::SecurityGroup | MODIFIED |\n> | OldBucket | AWS::S3::Bucket | DELETED |\n> </details>\n\n| Action | ID | Type | Replacement | Details |\n|--------|-----|------|-------------|---------|\n| 🔵 Modify | MyDatabase | AWS::RDS::DBInstance | **True** | 🔵 **DBInstanceClass**: `db.t3.medium` -> `db.t3.large` |\n| 🔵 Modify | MyLambdaFunction | AWS::Lambda::Function | False | 🔵 **Runtime**: `nodejs18.x` -> `nodejs20.x` |\n| 🟢 Add | NewSecurityGroup | AWS::EC2::SecurityGroup | - | |\n| 🔴 Remove | OldRole | AWS::IAM::Role | - | |\n\n**Features:**\n- **Replacement column** highlights when CloudFormation will **destroy and recreate** a resource — critical for stateful resources like databases, EC2 instances, and file systems\n- **Drift banner** — if the stack has drifted, a warning with drifted resource details appears above the change set table so reviewers know the baseline state\n- **Comment upsert** — each stack's comment is updated in place on subsequent pushes instead of creating duplicates; uses an HTML marker for reliable find-and-replace\n- **Color-coded indicators**: 🟢 Added, 🔵 Modified, 🔴 Removed\n- **Inline values for small changes**: Shows `before -> after` directly in the table\n- **Collapsible details for large values**: IAM policies, tags, and other large JSON values are wrapped in expandable `<details>` elements to keep the table readable\n- **All attribute types supported**: Properties, Tags, Metadata, etc.\n- **HTML-escaped values**: Prevents XSS from property values\n\n### Environment variables used by the change set script\n- `STACK_NAME` (required) — Stack name to describe.\n- `CHANGE_SET_NAME` (default: same as `STACK_NAME`).\n- `AWS_REGION` — Region for CloudFormation API calls. The workflow sets this via the credentials action(s).\n- `GITHUB_TOKEN` (optional) — If set with `GITHUB_COMMENT_URL`, posts a PR comment.\n- `GITHUB_COMMENT_URL` (optional) — PR comments URL.\n- `GITHUB_STEP_SUMMARY` (optional) — When present, appends the HTML to the step summary file.\n- `IGNORE_LOGICAL_IDS` (optional) — Comma‑separated logical IDs to ignore (default includes `CDKMetadata`).\n- `IGNORE_RESOURCE_TYPES` (optional) — Comma‑separated resource types to ignore (e.g., `AWS::CDK::Metadata`).\n\n## Usage: CdkDiffIamTemplate\n\nEmit an IAM template you can deploy in your account for the Change Set workflow. Supports two modes:\n\n1. **External OIDC Role** — Reference an existing GitHub OIDC role (original behavior)\n2. **Self-Contained** — Create the GitHub OIDC provider and role within the same template (new)\n\n### Option 1: Using an Existing OIDC Role (External)\n\nUse this when you already have a GitHub OIDC provider and role set up in your account.\n\n#### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDiffIamTemplate({\n project,\n roleName: 'cdk-diff-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: custom output path (default: 'cdk-diff-workflow-iam-template.yaml')\n // outputPath: 'infra/cdk-diff-iam.yaml',\n});\n\nproject.synth();\n```\n\n#### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDiffIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDiffIamTemplateGenerator.generateTemplate({\n roleName: 'cdk-diff-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n});\n\nfs.writeFileSync('cdk-diff-iam-template.yaml', template);\n```\n\n### Option 2: Self-Contained Template (Create OIDC Role)\n\nUse this when you want a single template that creates everything needed — the GitHub OIDC provider, OIDC role, and changeset role. This simplifies deployment and pairs well with the `CdkDiffStackWorkflow`.\n\n#### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n oidcRoleName: 'GitHubOIDCRole', // Optional, default: 'GitHubOIDCRole'\n githubOidc: {\n owner: 'my-org', // GitHub org or username\n repositories: ['infra-repo', 'app-repo'], // Repos allowed to assume roles\n branches: ['main', 'release/*'], // Branch patterns (default: ['*'])\n },\n // Optional: Skip OIDC provider creation if it already exists\n // skipOidcProviderCreation: true,\n});\n\nproject.synth();\n```\n\n#### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDiffIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDiffIamTemplateGenerator.generateTemplate({\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n oidcRoleName: 'GitHubOIDCRole',\n githubOidc: {\n owner: 'my-org',\n repositories: ['infra-repo'],\n branches: ['main'],\n },\n});\n\nfs.writeFileSync('cdk-diff-iam-template.yaml', template);\n```\n\n#### With Existing OIDC Provider (Skip Creation)\n\nIf your account already has a GitHub OIDC provider but you want the template to create the roles:\n\n```ts\nnew CdkDiffIamTemplate({\n project,\n roleName: 'CdkChangesetRole',\n createOidcRole: true,\n skipOidcProviderCreation: true, // Account already has OIDC provider\n githubOidc: {\n owner: 'my-org',\n repositories: ['*'], // All repos in org\n },\n});\n```\n\n### Deploy Task\n\nA Projen task is added for easy deployment:\n\n```bash\nnpx projen deploy-cdkdiff-iam-template -- --parameter-overrides GitHubOIDCRoleArn=... # plus any extra AWS CLI args\n```\n\n### CdkDiffIamTemplate Props\n\n| Property | Type | Description |\n|----------|------|-------------|\n| `roleName` | `string` | Name for the changeset IAM role (required) |\n| `oidcRoleArn` | `string?` | ARN of existing GitHub OIDC role. Required when `createOidcRole` is false. |\n| `oidcRegion` | `string?` | Region for OIDC trust condition. Required when `createOidcRole` is false. |\n| `createOidcRole` | `boolean?` | Create OIDC role within template (default: false) |\n| `oidcRoleName` | `string?` | Name of OIDC role to create (default: 'GitHubOIDCRole') |\n| `githubOidc` | `GitHubOidcConfig?` | GitHub OIDC config. Required when `createOidcRole` is true. |\n| `skipOidcProviderCreation` | `boolean?` | Skip OIDC provider if it exists (default: false) |\n| `outputPath` | `string?` | Template output path (default: 'cdk-diff-workflow-iam-template.yaml') |\n\n### What the Template Creates\n\n**External OIDC Role mode:**\n- Parameter `GitHubOIDCRoleArn` — ARN of your existing GitHub OIDC role\n- IAM role `CdkChangesetRole` with minimal permissions for change set operations\n- Outputs: `CdkChangesetRoleArn`, `CdkChangesetRoleName`\n\n**Self-Contained mode (`createOidcRole: true`):**\n- GitHub OIDC Provider (unless `skipOidcProviderCreation: true`)\n- IAM role `GitHubOIDCRole` with trust policy for GitHub Actions\n- IAM role `CdkChangesetRole` with minimal permissions (trusts the OIDC role)\n- Outputs: `GitHubOIDCProviderArn`, `GitHubOIDCRoleArn`, `GitHubOIDCRoleName`, `CdkChangesetRoleArn`, `CdkChangesetRoleName`\n\n**Changeset Role Permissions:**\n- CloudFormation Change Set operations\n- Access to CDK bootstrap S3 buckets and SSM parameters\n- `iam:PassRole` to `cloudformation.amazonaws.com`\n\nUse the created changeset role ARN as `changesetRoleToAssumeArn` in `CdkDiffStackWorkflow`.\n\n---\n\n## Usage: CdkDriftDetectionWorkflow\n\n`CdkDriftDetectionWorkflow` creates a single workflow file (default `drift-detection.yml`) that can run on a schedule and via manual dispatch. It generates a helper script at `.github/workflows/scripts/detect-drift.ts` (by default) that uses AWS SDK v3 to run drift detection, write optional machine‑readable JSON, and print an HTML report for the Step Summary.\n\nExample `.projenrc.ts`:\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDriftDetectionWorkflow } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({ github: true, /* ... */ });\n\nnew CdkDriftDetectionWorkflow({\n project,\n workflowName: 'Drift Detection', // optional; file name derived as 'drift-detection.yml'\n schedule: '0 1 * * *', // optional cron\n createIssues: true, // default true; create/update issue when drift detected on schedule\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: Node version (default '24.x')\n // nodeVersion: '24.x',\n // Optional: Where to place the helper script (default '.github/workflows/scripts/detect-drift.ts')\n // scriptOutputPath: '.github/workflows/scripts/detect-drift.ts',\n stacks: [\n {\n stackName: 'MyAppStack-Prod',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::123456789012:role/cdk-drift-role',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n // failOnDrift: true, // optional (default true)\n },\n ],\n});\n\nproject.synth();\n```\n\n### CdkDriftDetectionWorkflow props\n- `project` (required) — Your Projen project instance.\n- `stacks` (required) — Array of stacks to check.\n- `oidcRoleArn` (required) — Default OIDC role ARN used before chaining into per‑stack drift roles.\n- `oidcRegion` (required) — Default OIDC region.\n- `workflowName` (optional, default `'drift-detection'`) — Human‑friendly workflow name; the file name is derived in kebab‑case.\n- `schedule` (optional) — Cron expression for automatic runs.\n- `createIssues` (optional, default `true`) — When true, scheduled runs will create/update a GitHub issue if drift is detected.\n- `nodeVersion` (optional, default `'24.x'`) — Node.js version for the runner.\n- `scriptOutputPath` (optional, default `'.github/workflows/scripts/detect-drift.ts'`) — Where to write the helper script.\n- `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs. Artifact upload and issue-script paths are automatically prefixed.\n- `preGitHubSteps` (optional) — Additional steps to run after install but before AWS credentials and drift detection. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`. Pre-steps automatically receive the stack-selection condition so they only run when the stack is selected.\n- `postGitHubSteps` (optional) — Additional steps to run after drift detection and issue creation. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`. Steps default to `if: always() && steps.drift.outcome == 'failure'` unless you provide your own `if`.\n\n### Per‑stack fields\n- `stackName` (required) — The full CloudFormation stack name.\n- `driftDetectionRoleToAssumeArn` (required) — Role to assume (after OIDC) for making drift API calls.\n- `driftDetectionRoleToAssumeRegion` (required) — Region for that role and API calls.\n- `failOnDrift` (optional, default `true`) — Intended to fail the detection step on drift. The provided script exits with non‑zero when drift is found; the job continues to allow artifact upload and issue creation.\n\n### What gets generated\n- `.github/workflows/<kebab(workflowName)>.yml` — A workflow with one job per stack plus a final summary job.\n- `.github/workflows/scripts/detect-drift.ts` — Helper script that:\n - Starts drift detection and polls until completion\n - Lists non‑`IN_SYNC` resources and builds an HTML report\n - Writes optional JSON to `DRIFT_DETECTION_OUTPUT` when set\n - Prints to stdout and appends to the GitHub Step Summary when available\n\n### Artifacts and summary\n- Each stack job uploads `drift-results-<stack>.json` (if produced).\n- A final `Drift Detection Summary` job downloads all artifacts and prints a consolidated summary.\n\n### Manual dispatch\n- The workflow exposes an input named `stack` with choices including each configured stack and an `all` option.\n- Choose a specific stack to run drift detection for that stack only, or select `all` (or leave the input empty) to run all stacks.\n\nNote: The default workflow does not post PR comments for drift. It can create/update an Issue on scheduled runs when `createIssues` is `true`.\n\n### Post-notification steps (e.g., Slack)\n\nYou can add your own GitHub Action steps to run after the drift detection step for each stack using `postGitHubSteps`.\nProvide your own Slack payload/markdown (this library no longer generates a payload step for you).\n\nOption A: slackapi/slack-github-action (Incoming Webhook, official syntax)\n\n```ts\nnew CdkDriftDetectionWorkflow({\n project,\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n stacks: [/* ... */],\n postGitHubSteps: ({ stack }) => {\n // Build a descriptive name per stack\n const name = `Notify Slack (${stack} post-drift)`;\n const step = {\n name,\n uses: 'slackapi/slack-github-action@v2.1.1',\n // by default, post steps run only when drift is detected; you can override `if`\n if: \"always() && steps.drift.outcome == 'failure'\",\n // Use official inputs: webhook + webhook-type, and a YAML payload with blocks\n with: {\n webhook: '${{ secrets.CDK_NOTIFICATIONS_SLACK_WEBHOOK }}',\n 'webhook-type': 'incoming-webhook',\n payload: [\n 'text: \"** ${{ env.STACK_NAME }} ** has drifted!\"',\n 'blocks:',\n ' - type: \"section\"',\n ' text:',\n ' type: \"mrkdwn\"',\n ' text: \"*Stack:* ${{ env.STACK_NAME }} (region ${{ env.AWS_REGION }}) has drifted:exclamation:\"',\n ' - type: \"section\"',\n ' fields:',\n ' - type: \"mrkdwn\"',\n ' text: \"*Stack ARN*\\\\n${{ steps.drift.outputs.stack-arn }}\"',\n ' - type: \"mrkdwn\"',\n ' text: \"*Issue*\\\\n<${{ github.server_url }}/${{ github.repository }}/issues/${{ steps.issue.outputs.result }}|#${{ steps.issue.outputs.result }}>\"',\n ].join('\\n'),\n },\n };\n return [step];\n },\n});\n```\n\nNote: The Issue link requires `createIssues: true` (default) so that the `Create Issue on Drift` step runs before this Slack step and exposes `steps.issue.outputs.result`. This library orders the steps accordingly.\n\nDetails:\n- `postGitHubSteps` can be:\n - an array of step objects, or\n - a factory function `({ stack }) => step | step[]`.\n- Each step you provide is inserted after the results are uploaded.\n- Default condition: if you do not set `if` on your step, it will default to `always() && steps.drift.outcome == 'failure'`.\n- Available context/env you can use:\n - `${{ env.STACK_NAME }}`, `${{ env.DRIFT_DETECTION_OUTPUT }}`\n - `${{ steps.drift.outcome }}` — success/failure of the detect step\n - `${{ steps.drift.outputs.stack-arn }}` — Stack ARN resolved at runtime\n - `${{ steps.issue.outputs.result }}` — Issue number if the workflow created/found one (empty when not applicable)\n```\n\n## Usage: CdkDriftIamTemplate\n\nEmit an example IAM template you can deploy in your account for the Drift Detection workflow.\n\n### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDriftIamTemplate } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({\n // ...\n});\n\nnew CdkDriftIamTemplate({\n project,\n roleName: 'cdk-drift-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n // Optional: custom output path (default: 'cdk-drift-workflow-iam-template.yaml')\n // outputPath: 'infra/cdk-drift-iam.yaml',\n});\n\nproject.synth();\n```\n\nA Projen task is also added:\n\n```bash\nnpx projen deploy-cdkdrift-iam-template -- --parameter-overrides GitHubOIDCRoleArn=... # plus any extra AWS CLI args\n```\n\n### Without Projen (Standalone Generator)\n\n```ts\nimport { CdkDriftIamTemplateGenerator } from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\nconst template = CdkDriftIamTemplateGenerator.generateTemplate({\n roleName: 'cdk-drift-role',\n oidcRoleArn: 'arn:aws:iam::123456789012:role/github-oidc-role',\n oidcRegion: 'us-east-1',\n});\n\nfs.writeFileSync('cdk-drift-iam-template.yaml', template);\n\n// Get the deploy command\nconst deployCmd = CdkDriftIamTemplateGenerator.generateDeployCommand('cdk-drift-iam-template.yaml');\nconsole.log('Deploy with:', deployCmd);\n```\n\n### What the template defines\n\n- Parameter `GitHubOIDCRoleArn` with a default from `oidcRoleArn` — the ARN of your existing GitHub OIDC role allowed to assume this drift role.\n- IAM role `CdkDriftRole` with minimal permissions for CloudFormation drift detection operations.\n- Outputs exporting the role name and ARN.\n\n---\n\n## Usage: CdkDiffIamTemplateStackSet (Org-Wide Deployment)\n\n`CdkDiffIamTemplateStackSet` creates a CloudFormation StackSet template for deploying GitHub OIDC provider, OIDC role, and CDK diff/drift IAM roles across an entire AWS Organization. This is the recommended approach for organizations that want to enable CDK diff/drift workflows across multiple accounts.\n\n### Architecture\n\nEach account in your organization gets:\n- **GitHub OIDC Provider** — Authenticates GitHub Actions workflows\n- **GitHubOIDCRole** — Trusts the OIDC provider with repo/branch restrictions\n- **CdkChangesetRole** — For PR change set previews (trusts GitHubOIDCRole)\n- **CdkDriftRole** — For drift detection (trusts GitHubOIDCRole)\n\nThis is a self-contained deployment with **no role chaining required**.\n\n### With Projen\n\n```ts\nimport { awscdk } from 'projen';\nimport { CdkDiffIamTemplateStackSet } from '@jjrawlins/cdk-diff-pr-github-action';\n\nconst project = new awscdk.AwsCdkConstructLibrary({ /* ... */ });\n\nnew CdkDiffIamTemplateStackSet({\n project,\n githubOidc: {\n owner: 'my-org', // GitHub org or username\n repositories: ['infra-repo', 'app-repo'], // Repos allowed to assume roles\n branches: ['main', 'release/*'], // Branch patterns (default: ['*'])\n },\n targetOrganizationalUnitIds: ['ou-xxxx-xxxxxxxx'], // Target OUs\n regions: ['us-east-1', 'eu-west-1'], // Target regions\n // Optional settings:\n // oidcRoleName: 'GitHubOIDCRole', // default\n // changesetRoleName: 'CdkChangesetRole', // default\n // driftRoleName: 'CdkDriftRole', // default\n // roleSelection: StackSetRoleSelection.BOTH, // BOTH, CHANGESET_ONLY, or DRIFT_ONLY\n // delegatedAdmin: true, // Use --call-as DELEGATED_ADMIN (default: true)\n});\n\nproject.synth();\n```\n\nThis creates:\n- `cdk-diff-workflow-stackset-template.yaml` — CloudFormation template\n- Projen tasks for StackSet management\n\n**Projen tasks:**\n```bash\nnpx projen stackset-create # Create the StackSet\nnpx projen stackset-update # Update the StackSet template\nnpx projen stackset-deploy-instances # Deploy to target OUs/regions\nnpx projen stackset-delete-instances # Remove stack instances\nnpx projen stackset-delete # Delete the StackSet\nnpx projen stackset-describe # Show StackSet status\nnpx projen stackset-list-instances # List all instances\n```\n\n### Without Projen (Standalone Generator)\n\nFor non-Projen projects, use `CdkDiffIamTemplateStackSetGenerator` directly:\n\n```ts\nimport {\n CdkDiffIamTemplateStackSetGenerator\n} from '@jjrawlins/cdk-diff-pr-github-action';\nimport * as fs from 'fs';\n\n// Generate the CloudFormation template\nconst template = CdkDiffIamTemplateStackSetGenerator.generateTemplate({\n githubOidc: {\n owner: 'my-org',\n repositories: ['infra-repo'],\n branches: ['main'],\n },\n});\n\n// Write to file\nfs.writeFileSync('stackset-template.yaml', template);\n\n// Get AWS CLI commands for StackSet operations\nconst commands = CdkDiffIamTemplateStackSetGenerator.generateCommands({\n stackSetName: 'cdk-diff-workflow-iam-stackset',\n templatePath: 'stackset-template.yaml',\n targetOrganizationalUnitIds: ['ou-xxxx-xxxxxxxx'],\n regions: ['us-east-1'],\n});\n\nconsole.log('Create StackSet:', commands['stackset-create']);\nconsole.log('Deploy instances:', commands['stackset-deploy-instances']);\n```\n\n### GitHub Actions Workflow (Simplified)\n\nWith per-account OIDC, your workflow is simplified — no role chaining needed:\n\n```yaml\njobs:\n diff:\n runs-on: ubuntu-latest\n permissions:\n id-token: write\n contents: read\n steps:\n - uses: actions/checkout@v4\n\n - uses: aws-actions/configure-aws-credentials@v4\n with:\n role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/GitHubOIDCRole\n aws-region: us-east-1\n\n - name: Assume Changeset Role\n run: |\n CREDS=$(aws sts assume-role \\\n --role-arn arn:aws:iam::${{ env.ACCOUNT_ID }}:role/CdkChangesetRole \\\n --role-session-name changeset-session)\n # Export credentials...\n```\n\n### GitHubOidcConfig options\n\n| Property | Description |\n|----------|-------------|\n| `owner` | GitHub organization or username (required) |\n| `repositories` | Array of repo names, or `['*']` for all repos (required) |\n| `branches` | Array of branch patterns (default: `['*']`) |\n| `additionalClaims` | Extra OIDC claims like `['pull_request', 'environment:production']` |\n\n---\n\n## Testing\n\nThis repository includes Jest tests that snapshot the synthesized outputs from Projen and assert that:\n- Diff workflows are created per stack and contain all expected steps.\n- Drift detection workflow produces one job per stack and a summary job.\n- Only one helper script file is generated per workflow type.\n- Per‑stack OIDC overrides (where supported) are respected.\n- Helpful validation errors are thrown for missing OIDC settings.\n- The IAM template files contain the expected resources and outputs.\n\nRun tests with:\n\n```bash\nyarn test\n```\n\n## Monorepo support\n\nIf your CDK app lives in a subdirectory (e.g., `infra/`), use the `workingDirectory` option:\n\n```ts\nnew CdkDiffStackWorkflow({\n project,\n workingDirectory: 'infra',\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'MyStack-dev',\n changesetRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkChangesetRole',\n changesetRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n\nnew CdkDriftDetectionWorkflow({\n project,\n workingDirectory: 'infra',\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [\n {\n stackName: 'MyStack-dev',\n driftDetectionRoleToAssumeArn: 'arn:aws:iam::222222222222:role/CdkDriftRole',\n driftDetectionRoleToAssumeRegion: 'us-east-1',\n },\n ],\n});\n```\n\nThis sets `defaults.run.working-directory: infra` on all workflow jobs so that `install`, `synth`, and `deploy` steps run in the correct directory. The describe-changeset and detect-drift scripts are referenced with absolute paths so they resolve correctly from the subdirectory.\n\n**Note:** Your `infra/package.json` must include `@aws-sdk/client-cloudformation` as a dependency for the describe-changeset script to resolve modules at runtime.\n\n## Pre/post workflow steps\n\nBoth `CdkDiffStackWorkflow` and `CdkDriftDetectionWorkflow` support `preGitHubSteps` and `postGitHubSteps` for running custom steps before and after CDK operations. This is useful for building source code, sending Slack notifications, or running arbitrary commands.\n\nYou can provide a static array of steps, or a factory function that receives context:\n\n```ts\nnew CdkDiffStackWorkflow({\n project,\n workingDirectory: 'infra',\n oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',\n oidcRegion: 'us-east-1',\n stacks: [/* ... */],\n preGitHubSteps: ({ stack, workingDirectory }) => [\n // Build at project root (overrides working-directory default)\n { name: 'Build app', run: 'npm run build', 'working-directory': '.' },\n ],\n postGitHubSteps: ({ stack }) => [\n { name: 'Notify Slack', uses: 'slackapi/slack-github-action@v2', with: { /* ... */ } },\n ],\n});\n```\n\n> **Note:** When `workingDirectory` is set, all `run:` steps inherit that directory by default. To run a step at the repository root, add `working-directory: '.'` to that step.\n\n## Notes\n- This package assumes your repository is configured with GitHub Actions and that you have a GitHub OIDC role configured in AWS.\n- The generated scripts use the AWS SDK v3 for CloudFormation and, where applicable, the GitHub REST API.\n"
3511
3511
  },
3512
3512
  "repository": {
3513
3513
  "type": "git",
@@ -4376,7 +4376,7 @@
4376
4376
  "kind": "interface",
4377
4377
  "locationInModule": {
4378
4378
  "filename": "src/CdkDiffStackWorkflow.ts",
4379
- "line": 11
4379
+ "line": 23
4380
4380
  },
4381
4381
  "name": "CdkDiffStack",
4382
4382
  "properties": [
@@ -4388,7 +4388,7 @@
4388
4388
  "immutable": true,
4389
4389
  "locationInModule": {
4390
4390
  "filename": "src/CdkDiffStackWorkflow.ts",
4391
- "line": 13
4391
+ "line": 25
4392
4392
  },
4393
4393
  "name": "changesetRoleToAssumeArn",
4394
4394
  "type": {
@@ -4403,7 +4403,7 @@
4403
4403
  "immutable": true,
4404
4404
  "locationInModule": {
4405
4405
  "filename": "src/CdkDiffStackWorkflow.ts",
4406
- "line": 14
4406
+ "line": 26
4407
4407
  },
4408
4408
  "name": "changesetRoleToAssumeRegion",
4409
4409
  "type": {
@@ -4418,7 +4418,7 @@
4418
4418
  "immutable": true,
4419
4419
  "locationInModule": {
4420
4420
  "filename": "src/CdkDiffStackWorkflow.ts",
4421
- "line": 12
4421
+ "line": 24
4422
4422
  },
4423
4423
  "name": "stackName",
4424
4424
  "type": {
@@ -4433,7 +4433,7 @@
4433
4433
  "immutable": true,
4434
4434
  "locationInModule": {
4435
4435
  "filename": "src/CdkDiffStackWorkflow.ts",
4436
- "line": 16
4436
+ "line": 28
4437
4437
  },
4438
4438
  "name": "oidcRegion",
4439
4439
  "optional": true,
@@ -4449,7 +4449,7 @@
4449
4449
  "immutable": true,
4450
4450
  "locationInModule": {
4451
4451
  "filename": "src/CdkDiffStackWorkflow.ts",
4452
- "line": 15
4452
+ "line": 27
4453
4453
  },
4454
4454
  "name": "oidcRoleArn",
4455
4455
  "optional": true,
@@ -4472,7 +4472,7 @@
4472
4472
  },
4473
4473
  "locationInModule": {
4474
4474
  "filename": "src/CdkDiffStackWorkflow.ts",
4475
- "line": 41
4475
+ "line": 71
4476
4476
  },
4477
4477
  "parameters": [
4478
4478
  {
@@ -4486,7 +4486,7 @@
4486
4486
  "kind": "class",
4487
4487
  "locationInModule": {
4488
4488
  "filename": "src/CdkDiffStackWorkflow.ts",
4489
- "line": 38
4489
+ "line": 68
4490
4490
  },
4491
4491
  "name": "CdkDiffStackWorkflow",
4492
4492
  "symbolId": "src/CdkDiffStackWorkflow:CdkDiffStackWorkflow"
@@ -4501,7 +4501,7 @@
4501
4501
  "kind": "interface",
4502
4502
  "locationInModule": {
4503
4503
  "filename": "src/CdkDiffStackWorkflow.ts",
4504
- "line": 19
4504
+ "line": 31
4505
4505
  },
4506
4506
  "name": "CdkDiffStackWorkflowProps",
4507
4507
  "properties": [
@@ -4513,7 +4513,7 @@
4513
4513
  "immutable": true,
4514
4514
  "locationInModule": {
4515
4515
  "filename": "src/CdkDiffStackWorkflow.ts",
4516
- "line": 20
4516
+ "line": 32
4517
4517
  },
4518
4518
  "name": "project",
4519
4519
  "type": {
@@ -4528,7 +4528,7 @@
4528
4528
  "immutable": true,
4529
4529
  "locationInModule": {
4530
4530
  "filename": "src/CdkDiffStackWorkflow.ts",
4531
- "line": 21
4531
+ "line": 33
4532
4532
  },
4533
4533
  "name": "stacks",
4534
4534
  "type": {
@@ -4548,7 +4548,7 @@
4548
4548
  "immutable": true,
4549
4549
  "locationInModule": {
4550
4550
  "filename": "src/CdkDiffStackWorkflow.ts",
4551
- "line": 25
4551
+ "line": 37
4552
4552
  },
4553
4553
  "name": "cdkYarnCommand",
4554
4554
  "optional": true,
@@ -4564,7 +4564,7 @@
4564
4564
  "immutable": true,
4565
4565
  "locationInModule": {
4566
4566
  "filename": "src/CdkDiffStackWorkflow.ts",
4567
- "line": 24
4567
+ "line": 36
4568
4568
  },
4569
4569
  "name": "nodeVersion",
4570
4570
  "optional": true,
@@ -4580,7 +4580,7 @@
4580
4580
  "immutable": true,
4581
4581
  "locationInModule": {
4582
4582
  "filename": "src/CdkDiffStackWorkflow.ts",
4583
- "line": 23
4583
+ "line": 35
4584
4584
  },
4585
4585
  "name": "oidcRegion",
4586
4586
  "optional": true,
@@ -4596,7 +4596,7 @@
4596
4596
  "immutable": true,
4597
4597
  "locationInModule": {
4598
4598
  "filename": "src/CdkDiffStackWorkflow.ts",
4599
- "line": 22
4599
+ "line": 34
4600
4600
  },
4601
4601
  "name": "oidcRoleArn",
4602
4602
  "optional": true,
@@ -4604,6 +4604,42 @@
4604
4604
  "primitive": "string"
4605
4605
  }
4606
4606
  },
4607
+ {
4608
+ "abstract": true,
4609
+ "docs": {
4610
+ "remarks": "Accepts a static array of steps, or a factory function receiving context:\n`(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`\n\nWhen `workingDirectory` is set, all `run:` steps inherit that directory.\nTo run a step at the repository root, add `working-directory: '.'` to that step.",
4611
+ "stability": "experimental",
4612
+ "summary": "Additional GitHub Actions steps to run after all CDK operations complete."
4613
+ },
4614
+ "immutable": true,
4615
+ "locationInModule": {
4616
+ "filename": "src/CdkDiffStackWorkflow.ts",
4617
+ "line": 66
4618
+ },
4619
+ "name": "postGitHubSteps",
4620
+ "optional": true,
4621
+ "type": {
4622
+ "primitive": "any"
4623
+ }
4624
+ },
4625
+ {
4626
+ "abstract": true,
4627
+ "docs": {
4628
+ "remarks": "Accepts a static array of steps, or a factory function receiving context:\n`(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`\n\nWhen `workingDirectory` is set, all `run:` steps inherit that directory.\nTo run a step at the repository root, add `working-directory: '.'` to that step.",
4629
+ "stability": "experimental",
4630
+ "summary": "Additional GitHub Actions steps to run before CDK operations (after install, before AWS creds)."
4631
+ },
4632
+ "immutable": true,
4633
+ "locationInModule": {
4634
+ "filename": "src/CdkDiffStackWorkflow.ts",
4635
+ "line": 57
4636
+ },
4637
+ "name": "preGitHubSteps",
4638
+ "optional": true,
4639
+ "type": {
4640
+ "primitive": "any"
4641
+ }
4642
+ },
4607
4643
  {
4608
4644
  "abstract": true,
4609
4645
  "docs": {
@@ -4612,7 +4648,7 @@
4612
4648
  "immutable": true,
4613
4649
  "locationInModule": {
4614
4650
  "filename": "src/CdkDiffStackWorkflow.ts",
4615
- "line": 26
4651
+ "line": 38
4616
4652
  },
4617
4653
  "name": "scriptOutputPath",
4618
4654
  "optional": true,
@@ -4631,7 +4667,7 @@
4631
4667
  "immutable": true,
4632
4668
  "locationInModule": {
4633
4669
  "filename": "src/CdkDiffStackWorkflow.ts",
4634
- "line": 36
4670
+ "line": 48
4635
4671
  },
4636
4672
  "name": "workingDirectory",
4637
4673
  "optional": true,
@@ -4654,7 +4690,7 @@
4654
4690
  },
4655
4691
  "locationInModule": {
4656
4692
  "filename": "src/CdkDriftDetectionWorkflow.ts",
4657
- "line": 75
4693
+ "line": 87
4658
4694
  },
4659
4695
  "parameters": [
4660
4696
  {
@@ -4668,7 +4704,7 @@
4668
4704
  "kind": "class",
4669
4705
  "locationInModule": {
4670
4706
  "filename": "src/CdkDriftDetectionWorkflow.ts",
4671
- "line": 72
4707
+ "line": 84
4672
4708
  },
4673
4709
  "name": "CdkDriftDetectionWorkflow",
4674
4710
  "symbolId": "src/CdkDriftDetectionWorkflow:CdkDriftDetectionWorkflow"
@@ -4804,6 +4840,24 @@
4804
4840
  "primitive": "any"
4805
4841
  }
4806
4842
  },
4843
+ {
4844
+ "abstract": true,
4845
+ "docs": {
4846
+ "remarks": "Accepts a static array of steps, or a factory function receiving context:\n`(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`\n\nWhen `workingDirectory` is set, all `run:` steps inherit that directory.\nTo run a step at the repository root, add `working-directory: '.'` to that step.\n\nPre-steps automatically receive the stack-selection condition (`if`) so they\nonly run when the stack is selected via dispatch.",
4847
+ "stability": "experimental",
4848
+ "summary": "Additional GitHub Actions steps to run before drift detection (after install, before AWS creds)."
4849
+ },
4850
+ "immutable": true,
4851
+ "locationInModule": {
4852
+ "filename": "src/CdkDriftDetectionWorkflow.ts",
4853
+ "line": 69
4854
+ },
4855
+ "name": "preGitHubSteps",
4856
+ "optional": true,
4857
+ "type": {
4858
+ "primitive": "any"
4859
+ }
4860
+ },
4807
4861
  {
4808
4862
  "abstract": true,
4809
4863
  "docs": {
@@ -5401,6 +5455,6 @@
5401
5455
  "symbolId": "src/CdkDiffIamTemplateStackSet:StackSetRoleSelection"
5402
5456
  }
5403
5457
  },
5404
- "version": "1.8.0",
5405
- "fingerprint": "gOPm1rvgC24rKxRefMcHRBmTZTxskniMczkswaBzoY4="
5458
+ "version": "1.9.0",
5459
+ "fingerprint": "TSOSxDZa5reP5/7kL692PAaEgLo68kfbJNX2QLyeRUY="
5406
5460
  }
package/API.md CHANGED
@@ -796,6 +796,8 @@ const cdkDiffStackWorkflowProps: CdkDiffStackWorkflowProps = { ... }
796
796
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.nodeVersion">nodeVersion</a></code> | <code>string</code> | *No description.* |
797
797
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.oidcRegion">oidcRegion</a></code> | <code>string</code> | *No description.* |
798
798
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.oidcRoleArn">oidcRoleArn</a></code> | <code>string</code> | *No description.* |
799
+ | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.postGitHubSteps">postGitHubSteps</a></code> | <code>any</code> | Additional GitHub Actions steps to run after all CDK operations complete. |
800
+ | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.preGitHubSteps">preGitHubSteps</a></code> | <code>any</code> | Additional GitHub Actions steps to run before CDK operations (after install, before AWS creds). |
799
801
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.scriptOutputPath">scriptOutputPath</a></code> | <code>string</code> | *No description.* |
800
802
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.workingDirectory">workingDirectory</a></code> | <code>string</code> | Working directory for the CDK app, relative to the repository root. |
801
803
 
@@ -861,6 +863,42 @@ public readonly oidcRoleArn: string;
861
863
 
862
864
  ---
863
865
 
866
+ ##### `postGitHubSteps`<sup>Optional</sup> <a name="postGitHubSteps" id="@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.postGitHubSteps"></a>
867
+
868
+ ```typescript
869
+ public readonly postGitHubSteps: any;
870
+ ```
871
+
872
+ - *Type:* any
873
+
874
+ Additional GitHub Actions steps to run after all CDK operations complete.
875
+
876
+ Accepts a static array of steps, or a factory function receiving context:
877
+ `(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`
878
+
879
+ When `workingDirectory` is set, all `run:` steps inherit that directory.
880
+ To run a step at the repository root, add `working-directory: '.'` to that step.
881
+
882
+ ---
883
+
884
+ ##### `preGitHubSteps`<sup>Optional</sup> <a name="preGitHubSteps" id="@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.preGitHubSteps"></a>
885
+
886
+ ```typescript
887
+ public readonly preGitHubSteps: any;
888
+ ```
889
+
890
+ - *Type:* any
891
+
892
+ Additional GitHub Actions steps to run before CDK operations (after install, before AWS creds).
893
+
894
+ Accepts a static array of steps, or a factory function receiving context:
895
+ `(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`
896
+
897
+ When `workingDirectory` is set, all `run:` steps inherit that directory.
898
+ To run a step at the repository root, add `working-directory: '.'` to that step.
899
+
900
+ ---
901
+
864
902
  ##### `scriptOutputPath`<sup>Optional</sup> <a name="scriptOutputPath" id="@jjrawlins/cdk-diff-pr-github-action.CdkDiffStackWorkflowProps.property.scriptOutputPath"></a>
865
903
 
866
904
  ```typescript
@@ -910,6 +948,7 @@ const cdkDriftDetectionWorkflowProps: CdkDriftDetectionWorkflowProps = { ... }
910
948
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.oidcRegion">oidcRegion</a></code> | <code>string</code> | *No description.* |
911
949
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.oidcRoleArn">oidcRoleArn</a></code> | <code>string</code> | *No description.* |
912
950
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.postGitHubSteps">postGitHubSteps</a></code> | <code>any</code> | Optional additional GitHub Action steps to run after drift detection for each stack. |
951
+ | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.preGitHubSteps">preGitHubSteps</a></code> | <code>any</code> | Additional GitHub Actions steps to run before drift detection (after install, before AWS creds). |
913
952
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.schedule">schedule</a></code> | <code>string</code> | *No description.* |
914
953
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.scriptOutputPath">scriptOutputPath</a></code> | <code>string</code> | *No description.* |
915
954
  | <code><a href="#@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.workflowName">workflowName</a></code> | <code>string</code> | *No description.* |
@@ -993,6 +1032,27 @@ directly in your step without relying on a pre-generated payload.
993
1032
 
994
1033
  ---
995
1034
 
1035
+ ##### `preGitHubSteps`<sup>Optional</sup> <a name="preGitHubSteps" id="@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.preGitHubSteps"></a>
1036
+
1037
+ ```typescript
1038
+ public readonly preGitHubSteps: any;
1039
+ ```
1040
+
1041
+ - *Type:* any
1042
+
1043
+ Additional GitHub Actions steps to run before drift detection (after install, before AWS creds).
1044
+
1045
+ Accepts a static array of steps, or a factory function receiving context:
1046
+ `(ctx: { stack: string; workingDirectory?: string }) => GitHubStep[]`
1047
+
1048
+ When `workingDirectory` is set, all `run:` steps inherit that directory.
1049
+ To run a step at the repository root, add `working-directory: '.'` to that step.
1050
+
1051
+ Pre-steps automatically receive the stack-selection condition (`if`) so they
1052
+ only run when the stack is selected via dispatch.
1053
+
1054
+ ---
1055
+
996
1056
  ##### `schedule`<sup>Optional</sup> <a name="schedule" id="@jjrawlins/cdk-diff-pr-github-action.CdkDriftDetectionWorkflowProps.property.schedule"></a>
997
1057
 
998
1058
  ```typescript
package/README.md CHANGED
@@ -194,6 +194,8 @@ project.synth();
194
194
  - `cdkYarnCommand` (optional, default `'cdk'`) — Yarn script/command to invoke CDK.
195
195
  - `scriptOutputPath` (optional, default `'.github/workflows/scripts/describe-cfn-changeset.ts'`) — Where to write the helper script.
196
196
  - `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs so `install`, `synth`, and `deploy` steps run in that directory. The describe-changeset script path is automatically prefixed with `$GITHUB_WORKSPACE/` and `NODE_PATH` is set to resolve modules from the working directory.
197
+ - `preGitHubSteps` (optional) — Additional steps to run after install but before AWS credentials and CDK operations. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`.
198
+ - `postGitHubSteps` (optional) — Additional steps to run after all CDK operations complete. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`.
197
199
 
198
200
  If neither top‑level OIDC defaults nor all per‑stack values are supplied, the construct throws a helpful error.
199
201
 
@@ -465,6 +467,8 @@ project.synth();
465
467
  - `nodeVersion` (optional, default `'24.x'`) — Node.js version for the runner.
466
468
  - `scriptOutputPath` (optional, default `'.github/workflows/scripts/detect-drift.ts'`) — Where to write the helper script.
467
469
  - `workingDirectory` (optional) — Subdirectory where the CDK app lives (e.g., `'infra'`). Sets `defaults.run.working-directory` on all jobs. Artifact upload and issue-script paths are automatically prefixed.
470
+ - `preGitHubSteps` (optional) — Additional steps to run after install but before AWS credentials and drift detection. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`. Pre-steps automatically receive the stack-selection condition so they only run when the stack is selected.
471
+ - `postGitHubSteps` (optional) — Additional steps to run after drift detection and issue creation. Accepts a static array or a factory `({ stack, workingDirectory }) => steps[]`. Steps default to `if: always() && steps.drift.outcome == 'failure'` unless you provide your own `if`.
468
472
 
469
473
  ### Per‑stack fields
470
474
  - `stackName` (required) — The full CloudFormation stack name.
@@ -793,6 +797,31 @@ This sets `defaults.run.working-directory: infra` on all workflow jobs so that `
793
797
 
794
798
  **Note:** Your `infra/package.json` must include `@aws-sdk/client-cloudformation` as a dependency for the describe-changeset script to resolve modules at runtime.
795
799
 
800
+ ## Pre/post workflow steps
801
+
802
+ Both `CdkDiffStackWorkflow` and `CdkDriftDetectionWorkflow` support `preGitHubSteps` and `postGitHubSteps` for running custom steps before and after CDK operations. This is useful for building source code, sending Slack notifications, or running arbitrary commands.
803
+
804
+ You can provide a static array of steps, or a factory function that receives context:
805
+
806
+ ```ts
807
+ new CdkDiffStackWorkflow({
808
+ project,
809
+ workingDirectory: 'infra',
810
+ oidcRoleArn: 'arn:aws:iam::111111111111:role/GitHubOIDCRole',
811
+ oidcRegion: 'us-east-1',
812
+ stacks: [/* ... */],
813
+ preGitHubSteps: ({ stack, workingDirectory }) => [
814
+ // Build at project root (overrides working-directory default)
815
+ { name: 'Build app', run: 'npm run build', 'working-directory': '.' },
816
+ ],
817
+ postGitHubSteps: ({ stack }) => [
818
+ { name: 'Notify Slack', uses: 'slackapi/slack-github-action@v2', with: { /* ... */ } },
819
+ ],
820
+ });
821
+ ```
822
+
823
+ > **Note:** When `workingDirectory` is set, all `run:` steps inherit that directory by default. To run a step at the repository root, add `working-directory: '.'` to that step.
824
+
796
825
  ## Notes
797
826
  - This package assumes your repository is configured with GitHub Actions and that you have a GitHub OIDC role configured in AWS.
798
827
  - The generated scripts use the AWS SDK v3 for CloudFormation and, where applicable, the GitHub REST API.
@@ -17,5 +17,15 @@ type CdkDiffStackWorkflowProps struct {
17
17
  OidcRoleArn *string `field:"optional" json:"oidcRoleArn" yaml:"oidcRoleArn"`
18
18
  // Experimental.
19
19
  ScriptOutputPath *string `field:"optional" json:"scriptOutputPath" yaml:"scriptOutputPath"`
20
+ // Working directory for the CDK app, relative to the repository root.
21
+ //
22
+ // Useful for monorepos where infrastructure lives in a subdirectory (e.g., 'infra').
23
+ //
24
+ // When set, all workflow run steps will use `defaults.run.working-directory`
25
+ // and script paths will be adjusted to use absolute references.
26
+ // Default: - repository root.
27
+ //
28
+ // Experimental.
29
+ WorkingDirectory *string `field:"optional" json:"workingDirectory" yaml:"workingDirectory"`
20
30
  }
21
31
 
@@ -28,5 +28,15 @@ type CdkDriftDetectionWorkflowProps struct {
28
28
  ScriptOutputPath *string `field:"optional" json:"scriptOutputPath" yaml:"scriptOutputPath"`
29
29
  // Experimental.
30
30
  WorkflowName *string `field:"optional" json:"workflowName" yaml:"workflowName"`
31
+ // Working directory for the CDK app, relative to the repository root.
32
+ //
33
+ // Useful for monorepos where infrastructure lives in a subdirectory (e.g., 'infra').
34
+ //
35
+ // When set, all workflow run steps will use `defaults.run.working-directory`
36
+ // and artifact/script paths will be adjusted accordingly.
37
+ // Default: - repository root.
38
+ //
39
+ // Experimental.
40
+ WorkingDirectory *string `field:"optional" json:"workingDirectory" yaml:"workingDirectory"`
31
41
  }
32
42