79 lines
2.2 KiB
YAML
79 lines
2.2 KiB
YAML
name: AWS Cloud IAC Pipeline (Resources Matrix)
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'iac-template/terraform-hcl-standard/aws-cloud/component/ec2/**'
|
|
- 'iac-template/terraform-hcl-standard/aws-cloud/component/s3/**'
|
|
- '.github/workflows/terraform-standard-iac-pipeline-aws-resources-matrix.yaml'
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
type: choice
|
|
options: ['true', 'false']
|
|
default: 'true'
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
env:
|
|
BASE_DIR: iac-template/terraform-hcl-standard/aws-cloud/component
|
|
AWS_REGION: ap-northeast-1
|
|
DRY_RUN: ${{ github.event.inputs.dry_run || 'true' }}
|
|
AWS_ROLE_ARN: arn:aws:iam::950604983695:role/IacDeployRole
|
|
|
|
jobs:
|
|
terraform:
|
|
name: "${{ matrix.component }} :: pipeline (dry_run=${{ inputs.dry_run }})"
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
component:
|
|
- s3
|
|
- ec2
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: hashicorp/setup-terraform@v3
|
|
with:
|
|
terraform_version: 1.9.5
|
|
|
|
- uses: terraform-linters/setup-tflint@v4
|
|
with:
|
|
tflint_version: v0.51.0
|
|
|
|
- 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: ${{ env.AWS_REGION }}
|
|
role-to-assume: ${{ env.AWS_ROLE_ARN }}
|
|
role-session-name: github-actions
|
|
role-skip-session-tagging: true
|
|
|
|
- name: Init
|
|
working-directory: ${{ env.BASE_DIR }}/${{ matrix.component }}
|
|
run: make init
|
|
|
|
- name: Plan
|
|
working-directory: ${{ env.BASE_DIR }}/${{ matrix.component }}
|
|
run: make plan
|
|
|
|
- name: Apply
|
|
working-directory: ${{ env.BASE_DIR }}/${{ matrix.component }}
|
|
if: ${{ env.DRY_RUN == 'false' }}
|
|
run: make apply
|
|
|
|
- name: Skip Apply (dry-run)
|
|
if: ${{ env.DRY_RUN == 'true' }}
|
|
run: echo "Dry run enabled → skip apply step."
|
|
|
|
- name: Output
|
|
working-directory: ${{ env.BASE_DIR }}/${{ matrix.component }}
|
|
if: ${{ env.DRY_RUN == 'false' }}
|
|
run: terraform output -json
|