https://infracost.io logo
#help
Title
# help
o

orange-midnight-75948

07/31/2023, 9:16 AM
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

mysterious-teacher-68276

07/31/2023, 9:17 AM
Hi @orange-midnight-75948 can you paste the CI/CD pipeline configuration you are using to run Infracost?
o

orange-midnight-75948

07/31/2023, 9:19 AM
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

mysterious-teacher-68276

07/31/2023, 9:20 AM
and what are you expecting
output.json
to be?
is this the output from your terraform plan?
o

orange-midnight-75948

07/31/2023, 9:20 AM
My output.json is an artefact from terraform
Yes
m

mysterious-teacher-68276

07/31/2023, 9:21 AM
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

orange-midnight-75948

07/31/2023, 9:22 AM
Yes
Do you know the path of an artefact on Gitlab?
Maybe repo-name/artefact.txt?
m

mysterious-teacher-68276

07/31/2023, 9:26 AM
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

orange-midnight-75948

07/31/2023, 9:27 AM
I will try, I keep you in touch! Ok!
m

mysterious-teacher-68276

07/31/2023, 9:27 AM
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

orange-midnight-75948

07/31/2023, 9:28 AM
Yes, thanks!
@mysterious-teacher-68276 Ok it's good
Merci!
m

mysterious-teacher-68276

07/31/2023, 9:49 AM
pas soucis
21 Views