diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml new file mode 100644 index 0000000..8fc20f8 --- /dev/null +++ b/.github/workflows/terraform-apply.yml @@ -0,0 +1,57 @@ +name: "Network Terraform Apply" + +on: + push: + branches: + - main + paths: + - 'terraform/**' + workflow_dispatch: + +env: + TF_WORKSPACE: "default" + CONFIG_DIRECTORY: "./terraform" + +jobs: + terraform: + name: "Network Terraform Plan & Apply" + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ${{ env.CONFIG_DIRECTORY }} + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Assume AWS Credentials + id: assume + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-region: ${{ secrets.AWS_REGION }} + role-session-name: ${{ github.actor }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + + - uses: hashicorp/setup-terraform@v3 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + continue-on-error: true + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Plan + id: plan + run: terraform plan -no-color -out=tf.plan + + - name: Terraform Apply + run: terraform apply -auto-approve tf.plan diff --git a/.github/workflows/terraform-plan.yml b/.github/workflows/terraform-plan.yml index ce4ff4d..d449977 100644 --- a/.github/workflows/terraform-plan.yml +++ b/.github/workflows/terraform-plan.yml @@ -2,8 +2,8 @@ name: "Terraform Plan" on: pull_request: - # paths: - # - './terraform/**' + paths: + - 'terraform/**' env: TF_WORKSPACE: "default"