Skip to content

fix(0-bootstrap): use DENY condition on custom.kmsRotation so key destroy succeeds - #284

Merged
Calvin-Cheng1 merged 1 commit into
mainfrom
feat/org-policy-kms-destroy-regime-and-exceptions
Oct 22, 2026
Merged

Calvin-Cheng1 merged 1 commit into
mainfrom
feat/org-policy-kms-destroy-regime-and-exceptions

Conversation

@aghassemlouei

@aghassemlouei aghassemlouei commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description

  • Switch the custom.kmsRotation custom organization policy constraint in fast/stages-aw/0-bootstrap/data/custom-constraint-policies/cloudkms.yaml to the Cloud Foundation Fabric action_type: DENY implementation (has(resource.rotationPeriod) && resource.rotationPeriod > duration('7776000s')) across both CREATE and UPDATE so keys cannot be created or updated with a rotation period exceeding 90 days while terraform destroy can clear rotationPeriod via UPDATE prior to key version destruction, fixing [Bug] Custom KMS Org policy breaks terraform destroy operations of KMS keys #9.
  • Align .gemini/styleguide.md with the updated custom.kmsRotation DENY constraint definition.

Fixes #9

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • DoD IL4
    • DoD IL5
    • General / All
  • NIST 800-53r5 Controls: SC-12, SC-13, SC-28, CM-6

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/stages-aw/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in docs/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL4, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

  • Executed bash tools/run_tests.sh, ruff check ., ruff format --check ., and python3 tools/check_documentation.py (all Python unit tests, shell syntax checks, shell unit tests, and CodeQL AST checks pass).

@aghassemlouei aghassemlouei added compliance Enhancement New feature or request labels Oct 8, 2026
@github-actions github-actions Bot added the Scope - Fast Related to Fabric FAST deployment stages in the fast directory label Oct 8, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from 7177ea2 to eabe838 Compare October 9, 2026 01:32
@aghassemlouei
aghassemlouei marked this pull request as ready for review October 9, 2026 01:58
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch 2 times, most recently from 67c9bf6 to 0a44a04 Compare October 13, 2026 14:47
@aghassemlouei aghassemlouei added Bug Something isn't working Level of Effort - Medium Moderate task requiring thought and testing; typically takes a couple of days to a week Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Stage 0 labels Oct 13, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from 0a44a04 to 1ab3f87 Compare October 13, 2026 17:18
@aghassemlouei

Copy link
Copy Markdown
Member Author

/gemini review

gemini-code-assist[bot]

This comment was marked as outdated.

@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch 3 times, most recently from 7de4512 to f0f7a0e Compare October 20, 2026 02:30
@aghassemlouei aghassemlouei changed the title feat(org-policies): allow KMS key destroy, gate requireOsLogin by regime, and support 1-resman policy overrides fix(0-bootstrap): scope custom.kmsRotation to CREATE so key destroy succeeds Oct 20, 2026
@aghassemlouei aghassemlouei added Status - Ready for Review and removed Enhancement New feature or request Level of Effort - Medium Moderate task requiring thought and testing; typically takes a couple of days to a week Scope - Fast Related to Fabric FAST deployment stages in the fast directory Scope - Stage 0 labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from f0f7a0e to a2e6b18 Compare October 20, 2026 15:06

@Calvin-Cheng1 Calvin-Cheng1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest using the CFF implementation of this update adds a gap where keys could be created with duration < 90 but updated to be < 90 after the fact.

custom.cloudkmsAllowedRotationPeriod:
action_type: DENY
condition: |-
has(resource.rotationPeriod) && resource.rotationPeriod > duration("7776000s")
method_types:

  • CREATE
  • UPDATE
    resource_types:
  • cloudkms.googleapis.com/CryptoKey

@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from a2e6b18 to 9dc9158 Compare October 20, 2026 22:33
@aghassemlouei aghassemlouei added Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Scope - Stage 0 and removed Fast labels Oct 20, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from 9dc9158 to 70780db Compare October 20, 2026 22:57
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch 3 times, most recently from 2d27768 to 6807456 Compare October 21, 2026 00:06
@aghassemlouei aghassemlouei changed the title fix(0-bootstrap): scope custom.kmsRotation to CREATE so key destroy succeeds fix(0-bootstrap): use DENY condition on custom.kmsRotation so key destroy succeeds Oct 21, 2026
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from 6807456 to f22a660 Compare October 21, 2026 00:16
@aghassemlouei

Copy link
Copy Markdown
Member Author

Thanks for catching the UPDATE bypass, @Calvin-Cheng1! Updated custom.kmsRotation in f22a660 to use the CFF action_type: DENY condition (has(resource.rotationPeriod) && resource.rotationPeriod > duration('7776000s')) across both CREATE and UPDATE while keeping the custom.kmsRotation constraint key name for compatibility with cloudkms_policy.yaml and scripts/destroy.sh.

@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from f22a660 to 3d84609 Compare October 21, 2026 00:18
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch 2 times, most recently from cb0f161 to c49b660 Compare October 21, 2026 03:00
@aghassemlouei
aghassemlouei force-pushed the feat/org-policy-kms-destroy-regime-and-exceptions branch from c49b660 to 888b0bf Compare October 22, 2026 02:14
@Calvin-Cheng1
Calvin-Cheng1 merged commit e107746 into main Oct 22, 2026
22 checks passed
@Calvin-Cheng1
Calvin-Cheng1 deleted the feat/org-policy-kms-destroy-regime-and-exceptions branch October 22, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Fast Related to Fabric FAST deployment stages in the fast directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Custom KMS Org policy breaks terraform destroy operations of KMS keys

4 participants