diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b61a84..62789c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: run: | "$RUNNER_TEMP/checkov-venv/bin/checkov" \ --directory . \ - --framework terraform,github_actions \ + --framework terraform,github_actions,secrets \ --skip-path '\.terraform/' \ --quiet diff --git a/README.md b/README.md index f4b49b2..54c4ff1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ - [3.3 Deployment](#33-deployment--githubworkflowsdeployyml) - [3.4 Combined TEST and STAGE Destruction](#34-combined-test-and-stage-destruction--githubworkflowsdestroyyml) - [3.5 Dedicated PROD Destruction](#35-dedicated-prod-destruction--githubworkflowsdestroy-prodyml) - - [3.6 Planned Individual TEST and STAGE Destruction](#36-planned-individual-test-and-stage-destruction) + - [3.6 Individual TEST and STAGE Destruction](#36-individual-test-and-stage-destruction) 4. [Prerequisites and Credentials](#4-prerequisites-and-credentials) - [GitHub Actions Environments: Required Configuration](#github-actions-environments-required-configuration) 5. [Running the Workflow End to End](#5-running-the-workflow-end-to-end) @@ -27,10 +27,11 @@ - [5.4 Local Development, Validation, and Manual Deployment](#54-local-development-validation-and-manual-deployment) - [5.5 TEST and STAGE Destruction and Recreation](#55-test-and-stage-destruction-and-recreation) - [5.6 PROD Destruction and Recreation](#56-prod-destruction-and-recreation) + - [5.7 Individual TEST and STAGE Destruction and Recreation](#57-individual-test-and-stage-destruction-and-recreation) 6. [Destroying Resources and Cleanup](#6-destroying-resources-and-cleanup) - [6.1 Automated Destruction of TEST and STAGE](#61-automated-destruction-of-test-and-stage) - [6.2 Automated Destruction of PROD](#62-automated-destruction-of-prod) - - [6.3 Planned Single-Environment Destruction](#63-planned-single-environment-destruction) + - [6.3 Independent TEST and STAGE Destruction](#63-independent-test-and-stage-destruction) - [6.4 Manually Destroy an Individual Frontend Stack](#64-manually-destroy-an-individual-frontend-stack) - [6.5 Manually Destroy All Stacks in One Environment](#65-manually-destroy-all-stacks-in-one-environment) - [6.6 Manually Destroy All Three Environments](#66-manually-destroy-all-three-environments) @@ -51,25 +52,26 @@ The backend and database *subnets* are created as part of the network topology; ### Implementation status -| Capability | Status | -| --- |-------------------------------------------------------------------------------------------------------------| -| CI formatting, validation, linting, and security scanning | Implemented; CI passed | -| Automatic TEST deployment after successful CI on `main` | Implemented and successfully executed | -| Automatic STAGE deployment after TEST | Implemented and successfully executed | -| Manual PROD deployment after TEST and STAGE | Implemented and successfully executed | -| Human approval for PROD deployment and destruction | **Configured** through GitHub environment protection; authorized reviewers: Einar, Jørn, and Pau | -| `main` branch protection | **Configured:** `Protect main` ruleset; pull requests and passing CI required, 0 required approvals | -| Two OpenTofu stacks in each environment | Implemented | -| Environment- and stack-specific remote state | Implemented | -| Reusable network and VM modules | Implemented (local modules) | -| GitHub Actions TEST and STAGE destruction | **Implemented and successfully executed** using a matrix; frontend before network | -| TEST and STAGE recreation after destruction | **Successfully tested** through `Deploy Infrastructure` | +| Capability | Status | +| --- | --- | +| CI formatting, validation, linting, and security scanning | Implemented; CI passed | +| Automatic TEST deployment after successful CI on `main` | Implemented and successfully executed | +| Automatic STAGE deployment after TEST | Implemented and successfully executed | +| Manual PROD deployment after TEST and STAGE | Implemented and successfully executed | +| Human approval for PROD deployment and destruction | **Configured** through GitHub environment protection; authorized reviewers: Einar, Jørn, and Pau | +| `main` branch protection | **Configured:** `Protect main` ruleset; pull requests and passing CI required, 0 required approvals | +| Two OpenTofu stacks in each environment | Implemented | +| Environment- and stack-specific remote state | Implemented | +| Reusable network and VM modules | Implemented (local modules) | +| Combined TEST and STAGE destruction | **Implemented and successfully executed** using a matrix; frontend before network | +| Independent TEST-only destruction | **Implemented, destroyed and recreated successfully** using `destroy-test.yml` | +| Independent STAGE-only destruction | **Implemented, destroyed and recreated successfully** using `destroy-stage.yml` | | Dedicated PROD destruction through GitHub Actions | **Implemented and successfully executed** through `destroy-prod.yml` with approval; frontend before network | -| PROD recreation after complete destruction | **Successfully tested** through a new manual `Deploy Infrastructure` run | -| Independent TEST-only and STAGE-only destroy workflows | **Planned; not yet implemented or tested**; combined matrix remains available | -| Manual destruction using OpenTofu CLI | Documented for all three environments and for individual frontend stacks | -| Centralized CI tool versions | `.opentofu-version`, `.tflint-version`, `requirements-checkov.txt` | -| Independently tagged releases of reusable modules | **Not implemented**; modules are versioned with repository commits | +| PROD recreation after complete destruction | **Successfully tested** through a new manual `Deploy Infrastructure` run | +| Checkov secret scanning | **Enabled and CI passed**; six false positives in Kubernetes backend state identifiers reviewed and suppressed locally | +| Manual destruction using OpenTofu CLI | Documented for all three environments and for individual frontend stacks | +| Centralized CI tool versions | `.opentofu-version`, `.tflint-version`, `requirements-checkov.txt` | +| Independently tagged releases of reusable modules | **Not implemented**; modules are versioned with repository commits | The destruction and recreation workflows were developed after the original November 1 submission. This README describes the current repository state rather than claiming that post-submission changes were part of the original ZIP. Runner availability and instructor permissions still require verification through GitHub and OpenStack administration. @@ -81,6 +83,8 @@ assigment2-iac/ │ ├── ci.yml # Formatting, validation, TFLint, Checkov │ ├── deploy.yml # TEST → STAGE → conditional PROD │ ├── destroy.yml # Manually triggered TEST + STAGE destruction +│ ├── destroy-test.yml # Manually triggered TEST-only destruction +│ ├── destroy-stage.yml # Manually triggered STAGE-only destruction │ ├── destroy-prod.yml # Manually triggered, approval-gated PROD destruction │ └── runner-test.yml # Manually triggered runner health check ├── bootstrap/ @@ -107,7 +111,7 @@ assigment2-iac/ └── README.md ``` -**Planned additions (not yet present in the repository):** `.github/workflows/destroy-test.yml` and `.github/workflows/destroy-stage.yml` will provide independently triggered cleanup while retaining `destroy.yml` for combined TEST/STAGE cleanup. +**Independent destructive-operation entry points:** `destroy-test.yml` and `destroy-stage.yml` provide selective cleanup, while the verified `destroy.yml` remains available for combined non-production cleanup. `destroy-prod.yml` is independent and approval-protected. Every environment has its own network and frontend root module, its own `deployment.tfvars`, and its own `.terraform.lock.hcl`. The frontend stack uses `terraform_remote_state` to read the network ID and frontend subnet ID from the corresponding environment's network state. Therefore **network must be created before frontend, and frontend must be destroyed before network**. @@ -164,10 +168,12 @@ CI is triggered on **pull requests targeting `main`**, **pushes to `main`**, or 3. Execute `tofu fmt -check -recursive` for consistent formatting. 4. Run `tofu init -backend=false -input=false -lockfile=readonly` and `tofu validate -no-color` for the bootstrap and all six environment stacks. Using `-backend=false` avoids accessing deployment state during static validation. 5. Install the TFLint version specified in **`.tflint-version`** and lint OpenTofu configurations using `.tflint.hcl`. -6. Create an isolated Python virtual environment and install the pinned Checkov dependency from **`requirements-checkov.txt`**; scan Terraform/OpenTofu and GitHub Actions definitions. +6. Create an isolated Python virtual environment and install the pinned Checkov dependency from **`requirements-checkov.txt`**; scan Terraform/OpenTofu, GitHub Actions, and repository content for potential exposed secrets (`--framework terraform,github_actions,secrets`). The tool-version files are tracked in Git. They make deliberate upgrades easy to review, but do **not** automatically update themselves. A failed check causes CI to fail. Only a successful **push-originated** CI run on `main` meets the automatic deployment workflow's trigger condition; a pull-request CI run does not deploy infrastructure. +**Security scan findings and resolution:** Enabling Checkov's `secrets` framework initially produced six `CKV_SECRET_6` (high-entropy string) findings on `secret_suffix` values in the Kubernetes backend `providers.tf` files for TEST, STAGE, and PROD. These are deterministic **OpenTofu remote-state identifiers**, not credentials. The six findings were reviewed and addressed with narrowly scoped `checkov:skip=CKV_SECRET_6` comments on the relevant backend values rather than disabling the rule globally. After reformatting the modified `.tf` files with `tofu fmt`, CI succeeded. Secret scanning remains enabled and continues to check other repository content. Checkov provides policy coverage for supported IaC/workflow issues but does not guarantee comprehensive checks of OpenStack-specific security groups and resources. + ### 3.3 Deployment — `.github/workflows/deploy.yml` ```text @@ -228,17 +234,18 @@ Once approved, the job uses PROD-scoped OpenStack credentials, validates Kuberne **Verified:** The PROD destruction run succeeded after environment approval. A subsequent **new, manually dispatched** `Deploy Infrastructure` run successfully recreated PROD through the TEST → STAGE → approved PROD sequence. -### 3.6 Planned individual TEST and STAGE destruction +### 3.6 Individual TEST and STAGE destruction -To enable selective cleanup while retaining the tested combined matrix workflow, two additional manual workflow entry points are planned: +Two dedicated, manually triggered workflows enable independent cleanup without changing the tested combined TEST/STAGE matrix or the protected PROD workflow: -| Planned workflow | Target | Approval/credentials | Status | +| Workflow | Target environment | Expected Kubernetes state suffixes | Verification | | --- | --- | --- | --- | -| `.github/workflows/destroy-test.yml` | TEST only | `TEST` GitHub environment | **Planned; not yet added** | -| `.github/workflows/destroy-stage.yml` | STAGE only | `STAGE` GitHub environment | **Planned; not yet added** | +| `.github/workflows/destroy-test.yml` | `TEST` only | `assignment2-test-frontend`, `assignment2-test-network` | **Destroyed and recreated successfully** | +| `.github/workflows/destroy-stage.yml` | `STAGE` only | `assignment2-stage-frontend`, `assignment2-stage-network` | **Destroyed and recreated successfully** | -Each will reuse the validated operational pattern (correct environment-scoped state and credentials; saved destroy plans; frontend → network; shared concurrency and cleanup). The combined `destroy.yml` and dedicated `destroy-prod.yml` will remain intact. Separate manual entry points avoid adding `workflow_dispatch` inputs and reduce the risk of destroying both non-production environments when only one needs cleanup. Duplicating the workflow body is an interim trade-off; a future `workflow_call` reusable workflow would centralize the shared steps. +Both workflows require a manual `workflow_dispatch` from `main` and specify their GitHub environment and target path explicitly; there is **no dispatch input or matrix** that could select the other environment. They reuse the verified pattern: environment-scoped credentials, Kubernetes backend/state validation, a saved OpenTofu destroy plan, **frontend → network** ordering, the shared `infrastructure-deployment` concurrency group, and cleanup of temporary files. +**Verified:** TEST-only destruction removed TEST while STAGE and PROD remained intact; TEST was recreated through deployment. STAGE-only destruction then removed STAGE while TEST and PROD remained intact; STAGE was recreated successfully. The combined `destroy.yml` still provides intentional cleanup of both non-production environments. Keeping these workflows separate offers explicit operator scope at the cost of duplicated implementation steps. A future `workflow_call` reusable workflow could centralize the common logic. ## 4. Prerequisites and credentials The workflow assumes the following pre-existing infrastructure and permissions: @@ -384,9 +391,21 @@ A complete **deploy → destroy → recreate** lifecycle has been successfully v **Verified:** PROD destruction succeeded, and a fresh manually triggered deployment of TEST → STAGE → PROD subsequently succeeded. A rerun of a previous *manual* deployment would also retain PROD eligibility, but a new manual run was used to produce a clearer audit trail. +### 5.7 Individual TEST and STAGE destruction and recreation + +Both single-environment workflows have been verified through complete destruction and recreation: + +1. Open **Actions → Destroy Infrastructure (TEST)**, select **Run workflow** on `main`, and confirm the TEST-only destruction job succeeds. Verify STAGE and PROD remain intact. +2. To recreate TEST, open a successful **CI-triggered** `Deploy Infrastructure` run from the updated `main` revision and select **Re-run all jobs**. TEST is recreated; STAGE is checked/applied as needed; PROD is skipped. +3. Open **Actions → Destroy Infrastructure (STAGE)**, select **Run workflow** on `main`, and confirm that STAGE is removed while TEST and PROD remain intact. +4. Recreate STAGE using **Re-run all jobs** on a successful CI-triggered deployment from the updated `main` revision. TEST should have no changes, while STAGE is recreated; PROD remains skipped. +5. Capture screenshots of each successful destruction job and deployment rerun. These completed tests demonstrate that the individual workflows operate independently. + +Each destroy job removes its own **frontend first, then network**. Do not use the combined `Destroy Infrastructure (TEST, STAGE)` workflow for a single-environment cleanup, and do not start a *new manual* `Deploy Infrastructure` run for TEST/STAGE alone unless you also intend to run the protected PROD job. + ## 6. Destroying resources and cleanup -**Current status:** Both `.github/workflows/destroy.yml` (**combined TEST + STAGE**) and `.github/workflows/destroy-prod.yml` (**approved PROD-only**) have been successfully executed, and all three environments have been recreated through GitHub Actions. Normal `deploy.yml` still rejects deletions and replacements. Individually triggered `destroy-test.yml` and `destroy-stage.yml` workflows are planned but **not yet implemented**; CLI procedures below permit selective stack cleanup in the meantime. +**Current status:** All four destruction workflows have been implemented and successfully executed: `.github/workflows/destroy.yml` (combined TEST + STAGE), `.github/workflows/destroy-test.yml` (TEST only), `.github/workflows/destroy-stage.yml` (STAGE only), and `.github/workflows/destroy-prod.yml` (approval-protected PROD only). All three environments have successfully been recreated through GitHub Actions. Normal `deploy.yml` continues to reject deletions and replacements. The CLI procedures below also support targeted individual-stack cleanup. **Warning:** Destruction deletes real OpenStack resources. Obtain authorization, capture the required deployment evidence, protect all remote state, and confirm the target environment before proceeding. Never destroy `bootstrap/` while it hosts the required runner. Never destroy the external kOps cluster because the six stack states depend on it. @@ -398,7 +417,7 @@ A complete **deploy → destroy → recreate** lifecycle has been successfully v 4. Within **each** environment, the workflow initializes state, creates and applies a saved destroy plan for **frontend**, and then repeats the procedure for **network**. 5. Verify that **Destroy TEST** and **Destroy STAGE** succeed and their resources have been removed. The runner VM, external kOps cluster, and PROD resources are **not** part of this workflow. -**Scope and safety:** There is no environment or stack selector in the current GitHub Actions destroy workflow. `max-parallel: 1` serializes the matrix jobs but does not guarantee which environment executes first; `fail-fast: false` means one job's failure does not stop the other from being attempted. These jobs apply destroy plans automatically once dispatched. For an individual stack or a single environment, use the carefully reviewed CLI procedures below or introduce an explicitly scoped workflow entry point. The separate **PROD destruction** workflow is already protected by the `PROD` environment approval gate; it is not part of this matrix. +**Scope and safety:** There is no environment or stack selector in the current GitHub Actions destroy workflow. `max-parallel: 1` serializes the matrix jobs but does not guarantee which environment executes first; `fail-fast: false` means one job's failure does not stop the other from being attempted. These jobs apply destroy plans automatically once dispatched. For a single environment, use `destroy-test.yml` or `destroy-stage.yml` instead; the CLI procedures below remain available for individual-stack cleanup. The separate **PROD destruction** workflow is already protected by the `PROD` environment approval gate; it is not part of this matrix. ### 6.2 Automated destruction of PROD @@ -410,18 +429,20 @@ A complete **deploy → destroy → recreate** lifecycle has been successfully v **Verified:** The approval-protected PROD destroy workflow ran successfully, and PROD was successfully recreated afterward. The approval gate applies before the job starts; there is no additional pause to approve each individual destroy plan. -### 6.3 Planned single-environment destruction +### 6.3 Independent TEST and STAGE destruction -The intended extensions `.github/workflows/destroy-test.yml` and `.github/workflows/destroy-stage.yml` will be manually triggered, with **no `workflow_dispatch` inputs**, and will target only the named environment. They are **not yet implemented or verified**. Once created and tested, operators will have these choices: +Use the individual GitHub Actions workflows when only one non-production environment needs cleanup. Both have been implemented and verified; neither accepts `workflow_dispatch` inputs. -| Workflow | Intended destruction scope | Current availability | +| Workflow | Destruction scope | Status | | --- | --- | --- | -| `destroy-test.yml` | TEST frontend → TEST network | Planned | -| `destroy-stage.yml` | STAGE frontend → STAGE network | Planned | -| `destroy.yml` | TEST and STAGE, each frontend → network | Implemented and verified | -| `destroy-prod.yml` | PROD frontend → PROD network, with human approval | Implemented and verified | +| `destroy-test.yml` | TEST frontend → TEST network | **Implemented and verified** | +| `destroy-stage.yml` | STAGE frontend → STAGE network | **Implemented and verified** | +| `destroy.yml` | TEST and STAGE, each frontend → network | **Implemented and verified** | +| `destroy-prod.yml` | PROD frontend → PROD network, with human approval | **Implemented and verified** | + +To destroy **only TEST**, select **Actions → Destroy Infrastructure (TEST) → Run workflow → `main`**. To destroy **only STAGE**, select **Actions → Destroy Infrastructure (STAGE) → Run workflow → `main`**. The selected job validates its own environment credentials and Kubernetes state suffixes, then applies saved destroy plans for frontend and network in reverse dependency order. Verify resources were removed only in the intended environment. -All destructive workflows should share `infrastructure-deployment` concurrency and validate environment-specific credentials/state. Keep the combined workflow for intentional whole-non-production cleanup, but use individual entry points for routine single-environment cleanup once available. +All four destruction workflows share the `infrastructure-deployment` concurrency group. The combined TEST/STAGE workflow remains useful for explicitly requested whole-non-production cleanup; routine single-environment cleanup should use the dedicated entry points. Use section 5.7 to recreate an individually destroyed environment. ### 6.4 Manually destroy an individual frontend stack @@ -457,7 +478,7 @@ done Run the **section 6.5 sequence separately for PROD, STAGE, and TEST**, for example in that order. There is no dependency requiring a particular order **between** environments. **Switch to the correct OpenStack deployment credentials before each environment**. This deliberate, environment-by-environment process avoids accidentally using PROD permissions or configuration for another environment. Collect a successful OpenTofu destroy log and resource inventory screenshot for each environment if destruction evidence is required. -The deployment jobs successfully recreated TEST and STAGE after their combined destruction, and PROD after its separately approved destruction. See sections 5.5 and 5.6 for verified lifecycle procedures. The two individual TEST/STAGE workflow entry points remain planned. +The deployment jobs successfully recreated TEST and STAGE after combined destruction, TEST and STAGE again after their independent destruction tests, and PROD after separately approved destruction. See sections 5.5–5.7 for verified lifecycle procedures. ## 7. Security, state management, and design decisions @@ -465,10 +486,10 @@ The deployment jobs successfully recreated TEST and STAGE after their combined d - **Environment isolation:** TEST/STAGE/PROD have separate configuration folders, CIDRs, GitHub environments, and Kubernetes state keys. Frontend reads only the corresponding network state. - **State and locking:** the Kubernetes backend stores OpenTofu state in namespace `iac`. The pipeline checks Kubernetes API and Lease permissions before deploying. Protect access to the cluster and its Secrets, as state may include sensitive data. - **Limited authentication exposure:** OpenStack uses application credentials and GitHub environment secrets; kOps generates short-lived kubeconfig files. Deployment and destruction workflows remove temporary kubeconfig and plan files during cleanup. -- **Static quality gates and pinned tools:** formatting, validation, TFLint, and Checkov execute before automatic deployment. `.opentofu-version`, `.tflint-version`, and `requirements-checkov.txt` centralize CI tool version selection; `.terraform.lock.hcl` pins provider selections. Upgrades should be reviewed and validated in CI. +- **Static quality gates, secret scanning, and pinned tools:** formatting, validation, TFLint, and Checkov execute before automatic deployment. Checkov scans `terraform`, `github_actions`, and `secrets`. Six false-positive `CKV_SECRET_6` findings on Kubernetes `secret_suffix` state identifiers were reviewed and suppressed only at their source; CI passed after OpenTofu formatting was corrected. `.opentofu-version`, `.tflint-version`, and `requirements-checkov.txt` centralize CI tool version selection; `.terraform.lock.hcl` pins provider selections. Upgrades should be reviewed and validated in CI. - **Non-destructive deployment:** normal deployments reject planned deletion and replacement actions and apply only the saved, checked plan. -- **Controlled destruction and operator scope:** `destroy.yml` uses a manually triggered matrix for combined TEST/STAGE cleanup, with `max-parallel: 1` and no guaranteed environment order. `destroy-prod.yml` independently targets PROD behind approval. Every job verifies its environment-specific Kubernetes state and credentials, destroys frontend before network, and uses saved destroy plans. Separate TEST-only and STAGE-only entry points are planned for safer selective cleanup, while retaining combined non-production cleanup as an explicit option. -- **Workflow reuse trade-off:** dedicated entry points are easier to operate safely without dispatch inputs, but repeating the same shell steps across workflows increases maintenance. Extracting the shared logic into a reusable workflow is a potential post-assignment refactor; the verified workflows remain unchanged during the addition of TEST-only/STAGE-only entry points. +- **Controlled destruction and operator scope:** `destroy.yml` uses a manually triggered matrix for combined TEST/STAGE cleanup, with `max-parallel: 1` and no guaranteed environment order. `destroy-test.yml` and `destroy-stage.yml` support independently triggered single-environment cleanup and have both passed destruction/recreation tests. `destroy-prod.yml` independently targets PROD behind approval. Every job verifies its environment-specific Kubernetes state and credentials, destroys frontend before network, and uses saved destroy plans. The combined non-production cleanup remains an explicit option. +- **Workflow reuse trade-off:** dedicated entry points are easier to operate safely without dispatch inputs, but repeating the same shell steps across workflows increases maintenance. Extracting the shared logic into a reusable workflow is a potential post-assignment refactor; the existing tested workflows were retained when the individual TEST/STAGE workflows were added. - **PROD authorization:** both production deployment and the dedicated production destruction workflow require manual initiation and `PROD` environment approval. The repository owner, Jørn, and Pau are configured as authorized reviewers; they must also have the necessary repository permissions to execute workflows for grading. - **Network exposure:** frontend permits HTTP on port 80 from the configured `http_cidr` (currently `0.0.0.0/0`), and SSH on port 22 only from `admin_cidr`. This is a demonstration Nginx service, not a hardened application delivery platform. - **Reuse and versioning:** `modules/network` and `modules/vm` are reused across environments via relative source paths. Module code is versioned at the **repository commit level**, with the same module revision used by each environment at a given commit. There is **no independent module release/tag or registry version pinning**. @@ -481,7 +502,7 @@ The following workflow outcomes have been reported as successful and can be revi | Workflow / operation | Verified outcome | | --- | --- | -| CI checks | Passed | +| CI checks, including Checkov secrets scanning | **Passed** after targeted false-positive suppressions and `tofu fmt` correction | | Automatic deployment on `main` | TEST and STAGE succeeded; PROD skipped as expected | | Manually approved production deployment | TEST, STAGE, and PROD succeeded | | Earlier TEST-only destroy/recreate test | Destroy TEST succeeded; Deploy TEST recreated both stacks | @@ -489,7 +510,8 @@ The following workflow outcomes have been reported as successful and can be revi | Deployment rerun after matrix destruction | **TEST and STAGE recreated successfully**; PROD skipped | | Dedicated PROD destruction | **Destroy PROD succeeded** after approval; frontend and network removed | | New manually triggered deployment after PROD destruction | **TEST, STAGE, and PROD succeeded**; PROD recreated after approval | -| Individual TEST-only and STAGE-only destruction entry points | Planned; not yet implemented or tested | +| Independent TEST-only destruction and recreation | **Successful**; STAGE and PROD remained intact | +| Independent STAGE-only destruction and recreation | **Successful**; TEST and PROD remained intact | A screenshot of a full successful run end to end with destruction will be added once STAGE and PROD destruction has been completed. @@ -497,10 +519,11 @@ For an optional workload check, identifying a frontend floating IP from OpenTofu ## 9. Known limitations and improvements -1. **Individual TEST/STAGE destruction entry points pending:** `.github/workflows/destroy-test.yml` and `.github/workflows/destroy-stage.yml` are planned but have not yet been added or tested. Existing automation supports combined TEST/STAGE destruction and separately approved PROD destruction; individual stack cleanup is documented through the OpenTofu CLI. -2. **Combined matrix scope:** one manual `Destroy Infrastructure (TEST, STAGE)` run targets **both** environments, so operators must not use it when only one should be removed. Dedicated TEST/STAGE workflows will address this once implemented. +1. **Shared workflow logic is duplicated:** the combined, individual TEST/STAGE, and PROD destruction workflows repeat authentication, state validation, planning, and cleanup steps. A future reusable `workflow_call` workflow could centralize these steps, while retaining separate operator-facing entry points. +2. **Combined matrix scope:** one manual `Destroy Infrastructure (TEST, STAGE)` run targets **both** environments. The verified `destroy-test.yml` and `destroy-stage.yml` workflows should be used when only one environment needs deletion. 3. **Matrix sequencing:** `max-parallel: 1` prevents concurrent destruction jobs but does not guarantee TEST-before-STAGE ordering; `fail-fast: false` permits another matrix job to proceed if one fails. -4. **Module versions are tied to the repository commit:** separately published and pinned module releases would improve customer reuse and rollback. -5. **Runner and kOps dependencies are external:** self-hosted runner service availability, kOps cluster, Kubernetes namespace, access control, and instructor permissions require separate setup and ongoing maintenance. -6. **Bootstrap state is not remotely configured in the provided code:** its state needs separate backup and lifecycle protection. -7. **CI/CD tests are infrastructure-focused:** end-to-end application or Nginx availability tests are not implemented; the assignment permits workload-specific tests to be omitted. +4. **Security scanning coverage:** Checkov secret scanning and supported IaC/workflow policies are enabled and CI has passed. Entropy detection can produce false positives, so narrowly scoped documented suppressions are used for non-secret backend identifiers. OpenStack-specific security controls may require additional custom policies or manual review. +5. **Module versions are tied to the repository commit:** separately published and pinned module releases would improve customer reuse and rollback. +6. **Runner and kOps dependencies are external:** self-hosted runner service availability, kOps cluster, Kubernetes namespace, access control, and instructor permissions require separate setup and ongoing maintenance. +7. **Bootstrap state is not remotely configured in the provided code:** its state needs separate backup and lifecycle protection. +8. **CI/CD tests are infrastructure-focused:** end-to-end application or Nginx availability tests are not implemented; the assignment permits workload-specific tests to be omitted. diff --git a/environments/prod/frontend/providers.tf b/environments/prod/frontend/providers.tf index f34559b..2e80691 100644 --- a/environments/prod/frontend/providers.tf +++ b/environments/prod/frontend/providers.tf @@ -14,7 +14,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-prod-frontend" } } \ No newline at end of file diff --git a/environments/prod/network/providers.tf b/environments/prod/network/providers.tf index 763b0dd..84254bb 100644 --- a/environments/prod/network/providers.tf +++ b/environments/prod/network/providers.tf @@ -9,7 +9,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-prod-network" } } diff --git a/environments/stage/frontend/providers.tf b/environments/stage/frontend/providers.tf index 336a656..0dbb686 100644 --- a/environments/stage/frontend/providers.tf +++ b/environments/stage/frontend/providers.tf @@ -14,7 +14,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-stage-frontend" } } \ No newline at end of file diff --git a/environments/stage/network/providers.tf b/environments/stage/network/providers.tf index e590b22..a4f9d30 100644 --- a/environments/stage/network/providers.tf +++ b/environments/stage/network/providers.tf @@ -9,7 +9,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-stage-network" } } diff --git a/environments/test/frontend/providers.tf b/environments/test/frontend/providers.tf index f3e74cb..21aa9df 100644 --- a/environments/test/frontend/providers.tf +++ b/environments/test/frontend/providers.tf @@ -14,7 +14,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-test-frontend" } } \ No newline at end of file diff --git a/environments/test/network/providers.tf b/environments/test/network/providers.tf index 206c7f4..51601b2 100644 --- a/environments/test/network/providers.tf +++ b/environments/test/network/providers.tf @@ -9,7 +9,8 @@ terraform { } backend "kubernetes" { - namespace = "iac" + namespace = "iac" + # checkov:skip=CKV_SECRET_6: Kubernetes state identifier, not a credential secret_suffix = "assignment2-test-network" } }