Hello, I use inracost in my ci/cd in gitlab and wh...
# help
o
Hello, I use inracost in my ci/cd in gitlab and when I watch my dashboard, I can see two warnings like:
No such file or directory output.json Try adding a config-file to configure how Infracost should run. See <https://infracost.io/config-file> for details and examples.
and
Diff baseline error: No such file or directory output.json Try adding a config-file to configure how Infracost should run. See <https://infracost.io/config-file> for details and examples.
and I can see
Monthly cost will not change
. I tried to make a config-file but it seems to not work. Do you have a basic config-file to add to my repo?
m
Hi @orange-midnight-75948 can you paste the CI/CD pipeline configuration you are using to run Infracost?
o
Yes!
Copy code
infracost:
  stage: infracost
  image:
    name: infracost/infracost:ci-0.10
    entrypoint: [""]
  before_script:
    - cd directory
  script:
    - |
      infracost breakdown --path output.json \
                          --format=json \
                          --out-file=infracost-base.json
    - |
      infracost diff --path output.json \
                    --compare-to=infracost-base.json \
                    --format=json \
                    --out-file=infracost.json
    - |
      infracost comment gitlab --path=infracost.json \
                              --repo=$CI_PROJECT_PATH \
                              --merge-request=$CI_MERGE_REQUEST_IID \
                              --gitlab-server-url=$CI_SERVER_URL \
                              --gitlab-token=$GITLAB_TOKEN \
                              --behavior=new
m
and what are you expecting
output.json
to be?
is this the output from your terraform plan?
o
My output.json is an artefact from terraform
Yes
m
so the error suggests that the artefact hasn’t been found by Infracost - this could be because it’s not available at that path or your not making it available to this stage in the pipeline.
hence why we show the error:
no such file or directory output.json
o
Yes
Do you know the path of an artefact on Gitlab?
Maybe repo-name/artefact.txt?
m
I believe it’s just mounted at the root of the stage - however it looks like you’re doing a
cd
at the beginning of this stage into a different directory so it’s most likely one directory backwards
I’d suggest running a
ls
step first in the stage to make sure the artefact is there
also FYI if you are using a terraform plan JSON you do not need the
infracost diff
step as this is implicit from the terraform plan
o
I will try, I keep you in touch! Ok!
m
so your stage would look like:
Copy code
infracost:
  stage: infracost
  image:
    name: infracost/infracost:ci-0.10
    entrypoint: [""]
  before_script:
    - cd directory
  script:
    - |
      infracost breakdown --path output.json \
                          --format=json \
                          --out-file=infracost.json
    - |
      infracost comment gitlab --path=infracost.json \
                              --repo=$CI_PROJECT_PATH \
                              --merge-request=$CI_MERGE_REQUEST_IID \
                              --gitlab-server-url=$CI_SERVER_URL \
                              --gitlab-token=$GITLAB_TOKEN \
                              --behavior=new
o
Yes, thanks!
@mysterious-teacher-68276 Ok it's good
Merci!
m
pas soucis