Hello team, thank you for such an amazing tool. I ...
# help
Hello team, thank you for such an amazing tool. I am setting up the gitlab ci/cd using the provided template but passing the INFRACOST_API_KEY that I have generated in my account says that the key is invalid when used. Is there an additional step that is required before adding an API key to the gitlab-ci.yml file? Do I need to auth with it first on my local machine to use it?
Step for reference (based on the template in your docs with the private modules portion removed as it wasn't relevant for me:
Copy code
  stage: infracost
    - checkov
    - tfsec
    name: infracost/infracost:ci-0.10
    entrypoint: [""]
    # Clone the base branch of the pull request (e.g. main/master) into a temp directory.
    - git clone $CI_REPOSITORY_URL --branch=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --single-branch /tmp/base

    # Generate an Infracost cost snapshot from the comparison branch, so that Infracost can compare the cost difference.
    - |
      infracost breakdown --path=/tmp/base/${TF_ROOT} \
                          --format=json \

    # Generate an Infracost diff and save it to a JSON file.
    - |
      infracost diff --path=${TF_ROOT} \
                     --compare-to=infracost-base.json \
                     --format=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 \
    GITLAB_TOKEN: $GITLAB_TOKEN # With `api` scope to post merge request comments

    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
Hello! Thank you for the nice words! 🙂 May I ask you what the exact error you see?
Of course,
Defined api key here in CI/CD section of gitlab
Interesting. Everything looks correct to me 🤔 May I ask if your GitLab runner is linux or windows based?
Can you also DM me your Org ID? It can be found in /org/settings in Infracost Cloud
Yes I can one moment, thank you for the help
I am assuming linux based, but isn't the infracost image determining whether it is linux or windows based?
The image will run the commands, yes. But there is a difference how to pass
to the container. For example, in Windows I'd need to use
From your screenshot I see that you made the env var protected. Our quick start guide suggests to untick the "Protect variable" option to ensure it can be used for all MRs. Can you try to do that?
That was it, thank you so much @busy-agent-35515
Awesome, glad I could help! 🙂