Conversation
Extend the scheduled drift-detection workflow with an optional remediation
phase that reverts drifted CloudFormation stacks back to their deployed
template using a `REVERT_DRIFT` change-set. This is CloudFormation-only: it
operates on the live stack and its deployed template, with no CDK synth.
New public API (src/drift/base.ts):
- `RemediationPolicy` ('off' | 'manual' | 'auto')
- `DriftRemediationOptions` (include/exclude resource-type globs)
- `defaultRemediation` workflow option and per-stage `remediation` override
- `resolveRemediation()` helper and `DEFAULT_EXCLUDE_RESOURCE_TYPES`
New CLI (src/drift/revert-drift.ts, registered as the `revert-drift` bin):
- `classifyDrift()` splits drift into revertable / excluded / deletion buckets
with glob-based include/exclude filtering
- `DriftReverter` runs `create-change-set --use-previous-template` +
`execute-change-set --deployment-mode REVERT_DRIFT`
New steps (src/drift/step.ts): `DriftRemediationStep`, `DriftVerificationStep`.
Per-engine wiring (all strictly gated on policy != 'off'):
- GitHub: `remediate` job (with a deployment-environment gate for `manual`)
and a `verify` job after remediation
- GitLab: `remediation` + `verify` stages, `when: manual` / `when: on_success`
by policy, dotenv propagation for stage credentials
- Bash: `run_remediation_<stage>` / `run_verify_<stage>` functions, a `--yes`
flag, and an interactive confirmation for `manual`
Safety defaults: `off` by default (zero behavior change on upgrade — all 119
existing snapshots pass unchanged); sensitive resources
(`AWS::RDS::*`, `AWS::DynamoDB::Table`) are excluded by default; deletion drift
is reported but never reverted; drift in an excluded type blocks automatic
reversion. Adds 11 tests (classification, policy resolution, and per-engine
remediation snapshots); 210 tests pass, jsii compiles clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extend the scheduled drift-detection workflow with an optional remediation
phase that reverts drifted CloudFormation stacks back to their deployed
template using a
REVERT_DRIFTchange-set. This is CloudFormation-only: itoperates on the live stack and its deployed template, with no CDK synth.
New public API (src/drift/base.ts):
RemediationPolicy('off' | 'manual' | 'auto')DriftRemediationOptions(include/exclude resource-type globs)defaultRemediationworkflow option and per-stageremediationoverrideresolveRemediation()helper andDEFAULT_EXCLUDE_RESOURCE_TYPESNew CLI (src/drift/revert-drift.ts, registered as the
revert-driftbin):classifyDrift()splits drift into revertable / excluded / deletion bucketswith glob-based include/exclude filtering
DriftReverterrunscreate-change-set --use-previous-template+execute-change-set --deployment-mode REVERT_DRIFTNew steps (src/drift/step.ts):
DriftRemediationStep,DriftVerificationStep.Per-engine wiring (all strictly gated on policy != 'off'):
remediatejob (with a deployment-environment gate formanual)and a
verifyjob after remediationremediation+verifystages,when: manual/when: on_successby policy, dotenv propagation for stage credentials
run_remediation_<stage>/run_verify_<stage>functions, a--yesflag, and an interactive confirmation for
manualSafety defaults:
offby default (zero behavior change on upgrade — all 119existing snapshots pass unchanged); sensitive resources
(
AWS::RDS::*,AWS::DynamoDB::Table) are excluded by default; deletion driftis reported but never reverted; drift in an excluded type blocks automatic
reversion. Adds 11 tests (classification, policy resolution, and per-engine
remediation snapshots); 210 tests pass, jsii compiles clean.