Tofu Plan #21
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
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Tofu Plan | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| type: choice | |
| description: Environment | |
| required: true | |
| options: | |
| - staging | |
| - prod | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| plan: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.event.inputs.environment }} | |
| steps: | |
| - name: Deploy to environment | |
| run: echo "Deploying to ${{ needs.determine_environment.outputs.env_name }}" | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ vars.AWS_ROLE_ARN }} | |
| aws-region: ${{ vars.AWS_REGION }} | |
| audience: "sts.amazonaws.com" | |
| role-session-name: "GitHubActions-${{ github.run_id }}" | |
| mask-aws-account-id: false | |
| role-duration-seconds: 900 # 15 minutes | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Setup OpenTofu | |
| uses: opentofu/setup-opentofu@v1 | |
| - name: Initialize OpenTofu | |
| working-directory: ./terraform/config/${{ needs.determine_environment.outputs.env_name }} | |
| run: tofu init | |
| - name: Get OpenTofu version | |
| working-directory: ./terraform/config/${{ needs.determine_environment.outputs.env_name }} | |
| run: tofu --version | |
| - name: List out state | |
| working-directory: ./terraform/config/${{ needs.determine_environment.outputs.env_name }} | |
| run: tofu state list | |
| - name: Apply tofu plan | |
| working-directory: ./terraform/config/${{ needs.determine_environment.outputs.env_name }} | |
| run: tofu plan -input=false | |
| - name: Output stderr | |
| if: always() | |
| run: echo ${{ steps.plan.outputs.stderr }} | |
| - name: Output exitcode | |
| if: always() | |
| run: echo ${{ steps.plan.outputs.exitcode }} |