diff --git a/.github/workflows/terraform-infra-cost.yml b/.github/workflows/terraform-infra-cost.yml index 90600fc..cb40fa0 100644 --- a/.github/workflows/terraform-infra-cost.yml +++ b/.github/workflows/terraform-infra-cost.yml @@ -4,9 +4,9 @@ name: "[Analysis] Terraform Cost Estimation with Infracost" on: workflow_call: inputs: - stack_root_directory: + stack_config: + description: "A detailed matrix containing the Terraform stack configuration and dependencies" required: true - description: "The root of the stack to run the Infracost check in" type: string repo: required: false @@ -33,7 +33,9 @@ jobs: infracost: name: Compare cost to main runs-on: ubuntu-latest - + strategy: + matrix: + stack: "${{ fromJSON(inputs.stack_config) }}" steps: - name: Checkout code uses: actions/checkout@v4 @@ -66,7 +68,7 @@ jobs: - name: Generate current Infracost continue-on-error: true env: - stack_root_directory: ${{ inputs.stack_root_directory }} + stack_root_directory: ${{ matrix.stack.directory }} run: | infracost breakdown --path=${stack_root_directory} \ --format=json \ @@ -80,6 +82,8 @@ jobs: - name: Generate new Infracost continue-on-error: true + env: + stack_root_directory: ${{ matrix.stack.directory }} run: | infracost diff --path=${stack_root_directory} \ --format=json \ diff --git a/.github/workflows/terraform-plan-apply.yml b/.github/workflows/terraform-plan-apply.yml index 8c5887a..f78bbb2 100644 --- a/.github/workflows/terraform-plan-apply.yml +++ b/.github/workflows/terraform-plan-apply.yml @@ -140,6 +140,15 @@ jobs: download_existing_plan: false secrets: inherit + cost: + uses: ./.github/workflows/terraform-infra-cost.yml + needs: + - check + - filter_matrix_1 + with: + stack_config: "${{ needs.filter_matrix_1.outputs.filtered_matrix }}" + secrets: inherit + approve: name: Approve deployment runs-on: ubuntu-latest @@ -221,19 +230,6 @@ jobs: upload_plan: false download_existing_plan: true secrets: inherit - - cost: - uses: ./.github/workflows/terraform-infra-cost.yml - strategy: - matrix: - directory: ${{ fromJSON(needs.define_matrix.outputs.directories) }} - needs: - - check - - define_matrix - with: - stack_root_directory: "${{ matrix.directory }}" - secrets: - INFRACOST_API_KEY: "foo" # update-deployment: # name: Update Github deployment