Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup OpenTofu
uses: opentofu/setup-opentofu@v2
with:
tofu_version: "1.12.6"
tofu_version_file: .opentofu-version
tofu_wrapper: false

# Enforce consistent formatting across all OpenTofu configurations
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Setup TFLint
uses: terraform-linters/setup-tflint@v6
with:
tflint_version: v0.64.0
tflint_version_file: .tflint-version

# Inspect all OpenTofu root modules and reusable modules.
# Use the shared configuration from the repository root.
Expand All @@ -112,8 +112,14 @@ jobs:
# Install Checkov in an isolated Python environment.
- name: Install Checkov
run: |
set -euo pipefail
python3 -m venv "$RUNNER_TEMP/checkov-venv"
"$RUNNER_TEMP/checkov-venv/bin/python" -m pip install "checkov==3.4.0"
"$RUNNER_TEMP/checkov-venv/bin/python" -m pip install \
-r requirements-checkov.txt
"$RUNNER_TEMP/checkov-venv/bin/checkov" --version
# Scan OpenTofu configurations and GitHub Actions workflows.
- name: Run Checkov
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Destroy Infrastructure (TEST)
name: Destroy Infrastructure (TEST, STAGE)

on:
workflow_dispatch:
Expand All @@ -12,12 +12,22 @@ permissions:

jobs:
destroy:
name: Destroy TEST
name: Destroy ${{ matrix.environment }}
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
runs-on: [self-hosted, linux, assignment2]
timeout-minutes: 60

environment: TEST
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- environment: TEST
path: test
- environment: STAGE
path: stage

environment: ${{ matrix.environment }}

env:
OS_AUTH_TYPE: v3applicationcredential
Expand All @@ -28,7 +38,7 @@ jobs:
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
KOPS_STATE_STORE: swift://demo-kops
TARGET_ENV: test
TARGET_ENV: ${{ matrix.path }}

steps:
- name: Checkout
Expand All @@ -50,7 +60,10 @@ jobs:
tofu version
command -v jq
test "$TARGET_ENV" = "test"
case "$TARGET_ENV" in
test|stage) ;;
*) echo "::error::Unsupported environment: $TARGET_ENV"; exit 1 ;;
esac
: "${OS_AUTH_URL:?Missing OS_AUTH_URL}"
: "${OS_REGION_NAME:?Missing OS_REGION_NAME}"
Expand Down Expand Up @@ -135,7 +148,7 @@ jobs:
kubectl auth can-i get secrets -n iac --quiet
kubectl auth can-i create leases.coordination.k8s.io -n iac --quiet
- name: Destroy TEST frontend then network
- name: Destroy frontend then network
shell: bash
env:
TF_IN_AUTOMATION: "true"
Expand All @@ -153,8 +166,8 @@ jobs:
PLAN_FILE="$RUNNER_TEMP/destroy-$TARGET_ENV-$STACK.tfplan"
PLAN_JSON="$RUNNER_TEMP/destroy-$TARGET_ENV-$STACK.json"
# Verify that the backend belongs to TEST.
grep -Eq "secret_suffix[[:space:]]*=[[:space:]]*\"assignment2-test-$STACK\"" \
# Verify that the backend belongs to the selected environment.
grep -Eq "secret_suffix[[:space:]]*=[[:space:]]*\"assignment2-$TARGET_ENV-$STACK\"" \
"$STACK_DIR/providers.tf"
echo "::group::Destroy $TARGET_ENV $STACK"
Expand Down
1 change: 1 addition & 0 deletions .tflint-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.66.0
1 change: 1 addition & 0 deletions requirements-checkov.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
checkov==3.4.3