ci(terraform): add Terraform Standard pipeline for AWS LandingZone baseline
This commit is contained in:
parent
a3f054e8e8
commit
bbdf79f816
146
.github/workflows/terraform-standard-iac-pipeline-aws-global-landingzone-baseline.yaml
vendored
Normal file
146
.github/workflows/terraform-standard-iac-pipeline-aws-global-landingzone-baseline.yaml
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
name: Terraform Standard - AWS Global LandingZone Baseline
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'iac-template/terraform-standard/**'
|
||||
- '.github/workflows/terraform-standard-iac-pipeline-aws-global-landingzone-baseline.yaml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
deploy_action:
|
||||
description: "Deployment action"
|
||||
type: choice
|
||||
options: [init, plan, apply, destroy]
|
||||
default: plan
|
||||
deploy_dry_run:
|
||||
description: "Dry-run mode"
|
||||
type: choice
|
||||
options: ['true', 'false']
|
||||
default: 'true'
|
||||
|
||||
env:
|
||||
TF_WORKDIR: iac-template/terraform-standard
|
||||
DEPLOY_ACTION: ${{ github.event.inputs.deploy_action || 'plan' }}
|
||||
DEPLOY_DRY_RUN: ${{ github.event.inputs.deploy_dry_run || 'true' }}
|
||||
|
||||
jobs:
|
||||
# -------------------------------------------------------
|
||||
# 1. Bootstrap Stage (Matrix)
|
||||
# -------------------------------------------------------
|
||||
bootstrap:
|
||||
name: "Bootstrap: DynamoDB / S3 / IAM"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- bootstrap-dynamodb
|
||||
- bootstrap-s3
|
||||
- bootstrap-iam
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: 1.9.5
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
|
||||
- name: Terraform Init
|
||||
working-directory: ${{ env.TF_WORKDIR }}/${{ matrix.target }}
|
||||
run: terraform init -upgrade
|
||||
|
||||
- name: Terraform Plan (bootstrap)
|
||||
if: env.DEPLOY_DRY_RUN == 'true'
|
||||
working-directory: ${{ env.TF_WORKDIR }}/${{ matrix.target }}
|
||||
run: terraform plan -no-color
|
||||
|
||||
- name: Terraform Apply (bootstrap)
|
||||
if: env.DEPLOY_DRY_RUN == 'false'
|
||||
working-directory: ${{ env.TF_WORKDIR }}/${{ matrix.target }}
|
||||
run: terraform apply -auto-approve
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 2. Landing Zone Baseline Stage
|
||||
# -------------------------------------------------------
|
||||
landingzone:
|
||||
name: "Deploy LandingZone Baseline"
|
||||
needs: bootstrap
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: 1.9.5
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
|
||||
- name: Terraform Init (LandingZone)
|
||||
working-directory: ${{ env.TF_WORKDIR }}/envs/dev-landingzone
|
||||
run: terraform init -upgrade
|
||||
|
||||
- name: Terraform Plan (LandingZone)
|
||||
id: tfplan
|
||||
working-directory: ${{ env.TF_WORKDIR }}/envs/dev-landingzone
|
||||
run: terraform plan -no-color > plan_output.txt
|
||||
|
||||
- name: Upload LandingZone Plan Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: landingzone-plan
|
||||
path: ${{ env.TF_WORKDIR }}/envs/dev-landingzone/plan_output.txt
|
||||
|
||||
- name: Terraform Apply (LandingZone)
|
||||
if: env.DEPLOY_DRY_RUN == 'false'
|
||||
working-directory: ${{ env.TF_WORKDIR }}/envs/dev-landingzone
|
||||
run: terraform apply -auto-approve
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 3. Validation Stage
|
||||
# -------------------------------------------------------
|
||||
validation:
|
||||
name: "Validate LandingZone Baseline"
|
||||
needs: landingzone
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run Validation Checks
|
||||
run: |
|
||||
echo "⚙️ Running LandingZone baseline validation..."
|
||||
chmod +x scripts/validation/validate-landingzone.sh
|
||||
scripts/validation/validate-landingzone.sh \
|
||||
${{ env.TF_WORKDIR }}/envs/dev-landingzone
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 4. Delivery / Notification Stage
|
||||
# -------------------------------------------------------
|
||||
delivery:
|
||||
name: "Delivery: Notify Rollout"
|
||||
needs: validation
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Notify
|
||||
run: |
|
||||
echo "📣 Sending LandingZone rollout notification..."
|
||||
chmod +x scripts/notifications/notify-landingzone.sh
|
||||
scripts/notifications/notify-landingzone.sh
|
||||
Loading…
Reference in New Issue
Block a user