Add Terraform formatting step, Created WAF policy in Frontdoor module… #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Terraform infrastructure provision | |
| on: | |
| push: | |
| paths: | |
| - 'terraform/**' | |
| workflow_dispatch: | |
| inputs: | |
| action: | |
| description: 'Choose the Terraform action to perform: "plan" or "apply"' | |
| required: false | |
| default: 'plan' # Default to 'plan' for safety | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| terraform: | |
| runs-on: ubuntu-latest | |
| env: | |
| ARM_USE_OIDC: true | |
| ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
| ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
| ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| defaults: | |
| run: | |
| working-directory: ./terraform | |
| steps: | |
| - name: Checkout repositorys | |
| uses: actions/checkout@v4 | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.5.7 | |
| - name: Login to Azure | |
| uses: azure/login@v1 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Terraform Init | |
| run: terraform init | |
| - name: Terraform Format | |
| run: terraform fmt && terraform fmt -resursive | |
| - name: Terraform Plan | |
| if: ${{ github.event_name == 'push' || github.event.inputs.action == 'plan' || github.event.inputs.action == 'apply' }} | |
| run: terraform plan | |
| - name: Terraform Apply | |
| if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.action == 'apply') }} | |
| run: terraform apply --auto-approve | |