Skip to content

feat(0-bootstrap): support pre-created projects and workloads - #355

Merged
aghassemlouei merged 1 commit into
google:mainfrom
digitalresistor:feat/bootstrap-deletion-policy
Oct 26, 2026
Merged

aghassemlouei merged 1 commit into
google:mainfrom
digitalresistor:feat/bootstrap-deletion-policy

Conversation

@digitalresistor

Copy link
Copy Markdown
Contributor

Description

Import pre-created Stage 0 projects and the Assured Workloads workload without Terraform replacing or later deleting them.

Some organizations create the automation, log export, or billing export project and the Assured Workloads workload outside Terraform, for example when only a human user can use the billing account. They then import these resources into the Stage 0 state. Two gaps break that flow today.

  • The modules/project/ module already exposes a deletion_policy input, but the fast/stages-aw/0-bootstrap/ stage never passes it, so a destroy deletes every imported project.
  • The Assured Workloads API never returns the resource_settings field, so an imported workload plans a replacement, and the replacement fails without billing access.

The change closes both gaps.

  • The new project_deletion_policies object variable has automation, billing, and logging keys.
  • These keys match the keys of the existing project_parent_ids variable.
  • Each key defaults to DELETE, so existing deployments plan no change.
  • The ABANDON value removes the project from the Terraform state on destroy and leaves the project in the organization.
  • Destroy still removes the resources and the lien that the stage manages inside an abandoned project.
  • The PREVENT value makes Terraform refuse any destroy action on the project.
  • A validation block accepts the same values as the deletion_policy variable in the project module.
  • The google_assured_workloads_workload.primary resource now ignores changes to the resource_settings argument as well as the billing_account argument.
  • The Assured Workloads API marks both fields as input-only, so a refresh never detects drift in them, and a prefix change still replaces the workload through the display_name argument.
  • The stage README gains a "Pre-created resources" subsection and a regenerated variables table.
  • The new tests/test_bootstrap_precreated.py test file checks the module wiring, the defaults, the allowed values, and the ignored workload fields.

No GitHub issue exists for this change. The stellar CLI work in #306 uses the new variable.

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: None. The change affects only how Stage 0 adopts and destroys pre-created resources.

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

  • terraform init -backend=false and terraform validate in the fast/stages-aw/0-bootstrap/ stage report a valid configuration.
  • A local terraform test run with an uncommitted .tftest.hcl file and mock google and google-beta providers plans deletion_policy = "DELETE" on all three google_project.project[0] resources with the defaults.
  • The same mock run with overrides plans ABANDON on the automation and log export projects and PREVENT on the billing export project.
  • An invalid value such as KEEP fails the variable validation.
  • The default mock plan matches the plan from main exactly, with 327 resources in both.
  • tools/tfdoc.py regenerated the README table, and tools/check_documentation.py passes for the stage.
  • terraform fmt -check passes for the stage.
  • tools/lint.sh passes every check except the tflint step, because tflint is not installed locally.
  • tools/run_tests.sh passes, including the 107 unit tests.
  • Removing the deletion_policy line from one module makes the new test fail.
  • No tftest.yaml inventory covers the stage, so no inventory changed.
  • Stages 1 to 3 do not read these modules, so they need no change.
  • terraform validate passes after the ignore_changes update.
  • The new test fails when the resource_settings argument leaves the ignore_changes list.
  • A live import of a pre-created workload still waits for a lab run.

Some organizations create the Stage 0 projects and the Assured Workloads
workload outside Terraform, for example when only a human user can use
the billing account, and import them into the stage state.

- Add the project_deletion_policies variable so imported projects can
  survive terraform destroy with ABANDON; every key defaults to DELETE.
- Ignore changes to the workload resource_settings, which the API never
  returns, so an imported workload does not plan a replacement.
- Document pre-created resources in the stage README.
@github-actions github-actions Bot added the Scope - Fast Related to Fabric FAST deployment stages in the fast directory label Oct 24, 2026
@aghassemlouei aghassemlouei added Enhancement New feature or request 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 labels Oct 26, 2026

@aghassemlouei aghassemlouei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified locally with tools/run_tests.sh, tools/lint.sh, and Terraform variable validation. Wiring project_deletion_policies to the three Stage 0 projects and adding resource_settings to lifecycle.ignore_changes on google_assured_workloads_workload.primary cleanly supports importing pre-created workloads and shared-billing projects without planning a replacement.

@aghassemlouei
aghassemlouei merged commit 4c67f6b into google:main Oct 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request 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.

2 participants