broad-zoo-34077
12/04/2023, 7:37 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:22 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:24 PMechoing-piano-29088
12/05/2023, 1:24 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:26 PMechoing-piano-29088
12/05/2023, 1:29 PMechoing-piano-29088
12/05/2023, 1:30 PMechoing-piano-29088
12/05/2023, 1:33 PMtime="2023-12-04T22:05:41Z" level=debug sync_usage=false func=main.main file="/app/cmd/infracost/main.go:44" error="open aws/pre-prod-loc/global/plan.cache/.infracost/pricing.gob: not a directory" enable_cloud_org=false currency=USD msg="could not flush pricing API cache to filesystem"
little-author-61621
echoing-piano-29088
12/05/2023, 1:33 PMechoing-piano-29088
12/05/2023, 1:34 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:35 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:35 PMechoing-piano-29088
12/05/2023, 1:36 PMlittle-author-61621
little-author-61621
curl -H "X-Api-Key: $INFRACOST_API_KEY" <https://pricing.api.infracost.io/graphql>
If that shows a Invalid API key
error then something is not set up right in the GitLab pipeline to set that varechoing-piano-29088
12/05/2023, 1:46 PMechoing-piano-29088
12/05/2023, 1:48 PM"vcsSubPath":"aws/pre-prod-loc/global","errors":[{"code":0,"message":"Invalid API key\nPlease check your /root/.config/infracost/credentials.yml file or INFRACOST_API_KEY environment variable.
echoing-piano-29088
12/05/2023, 1:52 PM[{"code":0,"message":"Terraform binary 'terraform' could not be found. You have two options:\n1. Set a custom Terraform binary using the environment variable INFRACOST_TERRAFORM_BINARY
little-author-61621
echoing-piano-29088
12/05/2023, 1:55 PMechoing-piano-29088
12/05/2023, 1:56 PM[{"code":0,"message":"Terraform binary 'terraform' could not be found. You have two options:\n1. Set a custom Terraform binary using the environment variable INFRACOST_TERRAFORM_BINARY.\n\n2. Set --path to a Terraform plan JSON file. See <https://infracost.io/troubleshoot> for how to generate this."
little-author-61621
echoing-piano-29088
12/05/2023, 1:56 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 1:58 PM'gitlab-terraform plan',
'gitlab-terraform plan-json',
echoing-piano-29088
12/05/2023, 1:59 PMlittle-author-61621
little-author-61621
echoing-piano-29088
12/05/2023, 2:07 PM$ curl -H "X-Api-Key: $INFRACOST_API_KEY" <https://pricing.api.infracost.io/graphql>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 58 100 58 0 0 372 0 --:--:-- --:--:-- --:--:-- 374
{"error":"Invalid API key","error_code":"invalid_api_key"}$ ls -la /tmp/base/
echoing-piano-29088
12/05/2023, 2:07 PMechoing-piano-29088
12/05/2023, 2:08 PMinfracost auth login
We're redirecting you to our log in page, please complete that,
and return here to continue using Infracost.
If the redirect doesn't work, either:
- Use this URL:
<https://dashboard.infracost.io/login?cli_port=57483&cli_state=ce52de4e-0ba8-4278-98bf-0e8172adcc67&cli_version=v0.10.30&os=darwin&utm_source=cli>
- Or log in/sign up at <https://dashboard.infracost.io>, copy your API key
from Org Settings and run `infracost configure set api_key MY_KEY`
Waiting...
The API key was saved to /Users/phazeight/.config/infracost/credentials.yml
Your account has been authenticated. Run Infracost on your Terraform project by running:
infracost breakdown --path=.
little-author-61621
curl -H "X-Api-Key: $INFRACOST_API_KEY" -H "User-Agent: infracost-debug-19348509-6b3c-4d3e-9a4c-ef55bec70bfe" <https://pricing.api.infracost.io/graphql>
echoing-piano-29088
12/05/2023, 2:16 PMphazeight
echoing-piano-29088
12/05/2023, 2:31 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 2:51 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 3:05 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 3:07 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 3:17 PMechoing-piano-29088
12/05/2023, 3:18 PMcurl -H "X-Api-Key: $INFRACOST_API_KEY" -H "phazeight: infracost-debug-19348509-6b3c-4d3e-9a4c-ef55bec70bfe" <https://pricing.api.infracost.io/graphql>
GET query missing.%
little-author-61621
GET query missing
for this curl)echoing-piano-29088
12/05/2023, 3:22 PMlittle-author-61621
-H "phazeight: infracost-debug-19348509-6b3c-4d3e-9a4c-ef55bec70bfe"
needs to be -H "User-Agent: phazeight"
or -H "User-Agent: infracost-debug-19348509-6b3c-4d3e-9a4c-ef55bec70bfe"
echoing-piano-29088
12/05/2023, 3:23 PMechoing-piano-29088
12/05/2023, 3:24 PMechoing-piano-29088
12/05/2023, 3:29 PM$ curl -H "X-Api-Key: $INFRACOST_API_KEY" -H "User-Agent: phazeight" <https://pricing.api.infracost.io/graphql>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 58 100 58 0 0 401 0 --:--:-- --:--:-- --:--:-- 402
{"error":"Invalid API key","error_code":"invalid_api_key"}
that looks right?little-author-61621
"x-api-key": "$IN***************"
So I’m guessing it’s coming through as the string $INFRACOST_API_KEY
somewhere.little-author-61621
echoing-piano-29088
12/05/2023, 3:34 PMechoing-piano-29088
12/05/2023, 3:34 PMechoing-piano-29088
12/05/2023, 3:38 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 3:39 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 3:40 PMechoing-piano-29088
12/05/2023, 4:42 PMechoing-piano-29088
12/05/2023, 4:42 PMlittle-author-61621
echoing-piano-29088
12/05/2023, 4:44 PMechoing-piano-29088
12/05/2023, 6:45 PMechoing-piano-29088
12/05/2023, 6:46 PMshow-all-projects
flag, but it didn't get me what I wanted it did thislittle-author-61621
echoing-piano-29088
12/07/2023, 1:25 PMechoing-piano-29088
12/07/2023, 2:15 PMlittle-author-61621
infracost_comment
stages running per pipeline.echoing-piano-29088
12/07/2023, 4:42 PMgitlab-ci.yaml
. i have a a job that builds a dynamic yaml from a template, and a trigger job after that that uses the template to create downstream child pipelines for each file. I got it working to get the infracost into each downstream pipeline as a stage within that job.little-author-61621
infracost comment
doesn’t support appending to a comment, just replacing it. So the two options I can see are:
1. trigger a single job at the end of all pipelines that gathers all the infracost JSON files and leaves a single comment for them
2. have each pipeline leave a separate comment (using the --tag
flag)echoing-piano-29088
12/07/2023, 6:58 PM