broad-zoo-34077
06/18/2021, 11:18 AMclean-dream-3226
06/18/2021, 11:23 AMlittle-author-61621
little-author-61621
clean-dream-3226
06/18/2021, 11:40 AM# Copied from <https://github.com/marketplace/actions/run-infracost>
on:
push:
paths:
- '**.tf'
- '**.tfvars'
- '**.tfvars.json'
jobs:
infracost:
runs-on: ubuntu-latest
name: Show infracost diff
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Infracost
uses: infracost/infracost-gh-action@v0.7.0
env:
INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
entrypoint: /scripts/ci/diff.sh # Do not change
config_file: 'infracost.yml'
clean-dream-3226
06/18/2021, 11:42 AMterraform plan
clean-dream-3226
06/18/2021, 11:43 AMRunning infracost breakdown using:
$ infracost breakdown --no-color --format json --config-file infracost.yml
time="2021-06-18T04:39:40Z" level=info msg="Detected Terraform directory at website/production/"
time="2021-06-18T04:39:41Z" level=warning msg="Can't sync usage file as it's not specified"
time="2021-06-18T04:39:41Z" level=info msg="starting: Running terraform plan"
time="2021-06-18T04:39:41Z" level=info msg="Running command: /usr/bin/terraform plan -input=false -lock=false -no-color -out=/tmp/tfplan768928249"
little-author-61621
terraform plan
. So currently, we check for certain errors from that. Terraform has recently added a new error https://github.com/hashicorp/terraform/commit/9b1bd19ca5ac15325fb663743503e83e0d8a0689#diff-2bb17b35251ba77935e5edc3[…]1d268c10d1ef0eaeca2ab832eR576.
So we need to add support for that here: https://github.com/infracost/infracost/blob/master/internal/providers/terraform/dir_provider.go#L223-L227. I'll add that just now so it makes the next release.
In the meantime, I think it can be worked round by forcing an init in the action before the Infracost step runs
- name: "Install terraform"
uses: hashicorp/setup-terraform@v1
- name: "Terraform init"
id: init
run: terraform init
working-directory: path/to/code
clean-dream-3226
06/18/2021, 11:55 AMconfig_file
option?little-author-61621
little-author-61621
little-author-61621
uses: infracost/infracost-gh-action@fix-init
until this is released properly.little-author-61621
clean-dream-3226
06/18/2021, 12:07 PM