wonderful-lizard-93382
08/17/2023, 5:56 AMconfig
feature to get a single comment for different environments of the same terraform folder (feeding different .tfvar files) on CircleCI.
I followed docs https://www.infracost.io/docs/features/config_file/ and https://github.com/infracost/infracost-circleci and have somewhat working comment posted in PR.
But this comment consists of duplicate pairs of my “projects”. I suspect this is because my baseline “project” has different path where it was estimated? Would appreciate any advise on how to make this look properly, i.e merged and get a proper diff? Thanks in advance 🤝white-airport-8778
infracost generate config --repo-path=. \
--template-path=infracost.yml.tmpl
2. In CircleCI, does the main branch have the same config file? i.e. in CircleCI it would be doing this:
git clone $CIRCLE_REPOSITORY_URL --branch=$BASE_BRANCH --single-branch /tmp/base
# Breakdown using generated config file from main branch
infracost generate config --repo-path=/tmp/base \
--template-path=/tmp/base/infracost.yml.tmpl \
--out-file=/tmp/base/infracost.yml
infracost breakdown --config-file=/tmp/base/infracost.yml \
--format=json \
--out-file=/tmp/infracost-base.json
# Diff using generated config file from feature branch
infracost generate config --repo-path=${TF_ROOT} \
--template-path=${TF_ROOT}/infracost.yml.tmpl \
--out-file=${TF_ROOT}/infracost.yml
infracost diff --config-file=${TF_ROOT}/infracost.yml \
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json
infracost comment --path=/tmp/infracost.json
wonderful-lizard-93382
08/17/2023, 6:30 AMwhite-airport-8778
wonderful-lizard-93382
08/17/2023, 2:22 PMworking_directory:
key in CircleCI config to run commands from relevant directories (one for BASE and one for FEATURE branches) also making sure “path” parameter in config file in project is set properly (it was “.” like in the example) thats what I think was the root of the issue. Resulting comment looks awesome!