broad-zoo-34077
04/13/2022, 12:23 PMdelightful-market-27721
04/19/2022, 9:00 AMterraform plan
.
i am following below steps in my project
1. infracost breakdown --path . --terraform-parse-hcl --format json --out-file /tmp/infracost.json
2. ./infracost comment github --path /tmp/infracost.json --repo $GITHUB_REPOSITORY --github-token ${{ secrets.GITHUB_TOKEN }} --pull-request ${{github.event.pull_request.number}} --github-api-url https://<internal_git_repo> --behavior update --policy-path cost-policy.rego
but i am seeing the original cost is showing zero value . Looks like i am missing somethings. Could you please validate the above steps are correct to bypass execution terraform steps.
FYI: when running with terraform, everything coming properlydelightful-market-27721
04/19/2022, 9:01 AMmysterious-teacher-68276
04/19/2022, 9:02 AMdelightful-market-27721
04/19/2022, 9:03 AMmysterious-teacher-68276
04/19/2022, 9:48 AMdelightful-market-27721
05/03/2022, 5:12 AMmysterious-teacher-68276
05/03/2022, 6:56 AMname: Terraform directory
on: [pull_request]
jobs:
terraform-directory:
name: Terraform directory
runs-on: ubuntu-latest
steps:
# Checkout the branch you want Infracost to compare costs against. This example is using the
# target PR branch.
- name: Checkout base branch
uses: actions/checkout@v2
with:
ref: '${{ github.event.pull_request.base.ref }}'
- name: Setup Infracost
uses: infracost/actions/setup@v1
with:
api-key: ${{ secrets.INFRACOST_API_KEY }}
# Generate an Infracost output JSON from the comparison branch, so that Infracost can compare the cost difference.
- name: Generate Infracost cost snapshot
run: |
infracost breakdown --terraform-parse-hcl --path examples/terraform-directory/code \
--format json \
--out-file /tmp/prior.json
# Checkout the PR branch with your infrastructure changes.
- uses: actions/checkout@v2
- name: Run Infracost
run: |
infracost breakdown --terraform-parse-hcl --path examples/terraform-directory/code \
--format json \
--compare-to /tmp/prior.json \
--out-file /tmp/infracost.json
- name: Post Infracost comment
run: |
# Posts a comment to the PR using the 'update' behavior.
# This creates a single comment and updates it. The "quietest" option.
# The other valid behaviors are:
# delete-and-new - Delete previous comments and create a new one.
# hide-and-new - Minimize previous comments and create a new one.
# new - Create a new cost estimate comment on every push.
# See <https://www.infracost.io/docs/features/cli_commands/#comment-on-pull-requests> for other options.
infracost comment github --path /tmp/infracost.json \
--repo $GITHUB_REPOSITORY \
--github-token ${{github.token}} \
--pull-request ${{github.event.pull_request.number}} \
--behavior update
You can read more about the functionality here: https://www.infracost.io/docs/features/cli_commands/#option-1-terraform-directorydelightful-market-27721
05/03/2022, 6:56 AMdelightful-market-27721
05/06/2022, 2:25 AMi am getting error `unknown flag: --compare-to
below is the command
docker run --rm -e INFRACOST_API_KEY=<key> -v $PWD/:/code/ infracost/infracost breakdown --terraform-parse-hcl --path /code/infrastructure --format json --compare-to /tmp/prior.json --out-file /tmp/infracost.json
Error: unknown flag: --compare-to
delightful-market-27721
05/06/2022, 2:25 AMinfracost version is v0.9.24
docker run --rm -e INFRACOST_API_KEY=<key> -e -v $PWD/:/code/ infracost/infracost --version
Infracost v0.9.24
crooked-daybreak-55253
05/06/2022, 2:31 AMinfracost breakdown …
command to infracost diff …
. We modified the interface so that --compare-to
work with infracost diff
because people were finding it confusing to run breakdown twice.delightful-market-27721
05/06/2022, 2:31 AMdelightful-market-27721
05/06/2022, 2:35 AMdelightful-market-27721
05/06/2022, 5:06 AM--compare-to
option with breakdown
otherwise output will be not json format and infracost comment
will fail . I am not sure why first time it failed saying unknown flag: --compare-to
when used with breakdown
. But all good now and things are working .delightful-market-27721
05/06/2022, 5:12 AMinit
and show
as part of breakdown
and --compare-to
combination . I was in impression we wont required running terraform init
and show
and still required AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY .
So it is not helping my use-case . i al looking to skip running terraform init
and plan
all together, so that i don't need to pass AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
if i ran infracost diff
, which is not generating json output so can not use infracost comment
.delightful-market-27721
05/06/2022, 5:13 AMinfracost breakdown --terraform-parse-hcl --path examples/terraform-directory/code \
--format json \
--compare-to /tmp/prior.json \
--out-file /tmp/infracost.json
mysterious-teacher-68276
05/06/2022, 5:40 AMdelightful-market-27721
05/06/2022, 5:42 AMdelightful-market-27721
05/06/2022, 5:50 AMUSAGE
infracost diff [flags]
Error: unknown flag: --format
delightful-market-27721
05/06/2022, 5:52 AMinfracost breakdown with --terraform-parse-hcl
, still running terraform init, see https://infracost-community.slack.com/archives/C01G63Q4HS7/p1651814027730029?thread_ts=1649852581.140919&cid=C01G63Q4HS7
2. infracost diff command with --format json throwing error unknown flag: --format , but document say we can use it , see https://infracost-community.slack.com/archives/C01G63Q4HS7/p1651816224568659?thread_ts=1649852581.140919&cid=C01G63Q4HS7delightful-market-27721
05/06/2022, 5:55 AMlittle-author-61621
infracost diff --path=. --compare-to=prior.json --terraform-parse-hcl --format=json
little-author-61621
infracost breakdown with --terraform-parse-hcl
still running terraform init. I wonder if somehow it’s pulling an old version of Infracost.delightful-market-27721
05/06/2022, 6:59 AMlittle-author-61621
docker run --rm -e INFRACOST_API_KEY=<key> -e -v $PWD/:/code/ infracost/infracost --version
again just to double check?delightful-market-27721
05/06/2022, 7:04 AMdelightful-market-27721
05/06/2022, 7:05 AMlittle-author-61621
delightful-market-27721
05/06/2022, 7:05 AMlittle-author-61621