Skip to content

Commit

Permalink
Infracross
Browse files Browse the repository at this point in the history
  • Loading branch information
ntse committed Nov 29, 2024
1 parent 7ebd88c commit bb008e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/terraform-infra-cost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/terraform-plan-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb008e7

Please sign in to comment.