broad-zoo-34077
02/28/2024, 2:30 PMwhite-airport-8778
INFRACOST_SKIP_UPDATE_CHECK=true
white-airport-8778
damp-baker-46244
02/28/2024, 2:51 PM.state.json
filedamp-baker-46244
02/28/2024, 2:51 PMwhite-airport-8778
HOME
env to see if that helps?white-airport-8778
damp-baker-46244
02/29/2024, 12:03 PMdamp-baker-46244
02/29/2024, 12:04 PMexport HOME=/tmp
worked! I managed to execute infracost --version
. However, when I am running infracost breakdown --path plan.json
I get the same behaviour as beforewhite-airport-8778
damp-baker-46244
02/29/2024, 12:05 PMdamp-baker-46244
02/29/2024, 12:10 PMwhite-airport-8778
HOME=/tmp infracost breakdown...
or HOME=/tmp infracost diff...
2. make the home dir and the PWD where infracost runs writable.white-airport-8778
damp-baker-46244
02/29/2024, 1:06 PM$ls -lisah /tmp
total 24K
2 4.0K drwx------ 3 sbx_user 990 4.0K Feb 29 12:54 .
2 4.0K drwxr-xr-x 1 root root 4.0K Feb 29 12:53 ..
29601 4.0K drwx------ 3 sbx_user 990 4.0K Feb 29 12:54 .config
12 4.0K -rw-rw-r-- 1 sbx_user 990 3.5K Feb 29 12:55 config.json
11 8.0K -rw-rw-r-- 1 sbx_user 990 5.7K Feb 29 12:55 plan.json
$ls -lisah /tmp/.config
total 12K
29601 4.0K drwx------ 3 sbx_user 990 4.0K Feb 29 12:54 .
2 4.0K drwx------ 3 sbx_user 990 4.0K Feb 29 12:54 ..
13 4.0K drwx------ 2 sbx_user 990 4.0K Feb 29 12:54 infracost
$ls -lisah /tmp/.config/infracost
total 12K
13 4.0K drwx------ 2 sbx_user 990 4.0K Feb 29 12:54 .
29601 4.0K drwx------ 3 sbx_user 990 4.0K Feb 29 12:54 ..
14 4.0K -rw------- 1 sbx_user 990 106 Feb 29 12:54 .state.json
when I try to execute infracost configure set currency EUR
, lambda just exits. Keep in mind that there is already an env var HOME=/tmp
damp-baker-46244
02/29/2024, 1:07 PMinfracost configure set api_key {api_key_value}
but still fails. My guess is that it cannot create the necessary filesdamp-baker-46244
02/29/2024, 1:08 PMwhite-airport-8778
INFRACOST_API_KEY
and INFRACOST_CURRENCY
there’s also this. This is what our CI/CD integrations do to avoid needing to write those values in files.damp-baker-46244
02/29/2024, 1:10 PMwhite-airport-8778
damp-baker-46244
02/29/2024, 1:11 PMinfracost breakdown
white-airport-8778
damp-baker-46244
02/29/2024, 1:34 PMenvironment {
variables = {
LOG_FORMAT = "json"
INFRACOST_SKIP_UPDATE_CHECK = true
INFRACOST_LOG_LEVEL = "info"
INFRACOST_CURRENCY = "EUR"
INFRACOST_API_KEY = <api_key>
HOME = "/tmp"
}
}
and run the following Go code
cmd := exec.Command("infracost", "breakdown", "--path", "/tmp/plan.json")
out, err := cmd.CombinedOutput()
if err != nil {
log.WithError(err).Error("could not run infracost breakdown")
return resp, err
}
log.Info(strings.TrimSpace(string(out)))
I get a lambda timeout, which is set to 30 seconds...damp-baker-46244
02/29/2024, 1:34 PMwhite-airport-8778
debug
and see if that gives clues on what’s taking long?damp-baker-46244
03/01/2024, 10:33 AMHOME=/tmp
INFRACOST_API_KEY=ico-.....
INFRACOST_LOG_LEVEL=debug
INFRACOST_SKIP_UPDATE_CHECK=true
INFRACOST_ENABLE_CLOUD=false
INFRACOST_ENABLE_CLOUD_UPLOAD=false
INFRACOST_ENABLE_DASHBOARD=false
INFRACOST_TLS_INSECURE_SKIP_VERIFY=true
I created the following folders programmatically:
• /tmp/.config/infracost -> stores state.json
, credentials,yml
, and configuration.yml
files
• /tmp/.infracost -> stores the cache file pricing.gob
However, Lambda still freezes, produces no logs and eventually timeouts when it executes infracost breakdown --path /tmp/plan.json
sadpanda
When I locally run the same Docker image with the same envs, everything runs as expected...damp-baker-46244
03/01/2024, 10:45 AMinfracost configure set currency GBP
work! Still, breakdown is not working
"message": "2024-03-01T10:42:44Z DBG IsCloudEnabled explicitly set through Config.EnabledCloud is_cloud_enabled=false",
"message": "Configured currency",
I will look at the code again and see if anything does not play along with running in a Lambdawhite-airport-8778
damp-baker-46244
03/01/2024, 11:20 AMwhite-airport-8778
curl -i -v <https://dashboard.infracost.io/>
damp-baker-46244
03/01/2024, 11:29 AMINFRACOST_ENABLE_CLOUD=false
INFRACOST_ENABLE_CLOUD_UPLOAD=false
INFRACOST_ENABLE_DASHBOARD=false
white-airport-8778
curl -i -v <https://pricing.api.infracost.io/health>
damp-baker-46244
03/04/2024, 9:04 AMdamp-baker-46244
03/04/2024, 9:05 AMinfracost breakdown --no-color --path plan.json
commanddamp-baker-46244
03/04/2024, 9:22 AMwhite-airport-8778
infracost diff --path plan.json
as that shows the diff, not a breakdown, which is usually more useful as the engineer can review only the changes.
2. Does that view in TFC have a way to render markdown? If so, maybe try adding before and after the CLI output so it renders using code block with a better font for text output.
3. If they render markdown, you can also do this so you get the markdown for the same thing we put in GitHub comments:
```infracost diff --path plan.json --format json --out-file infracost.json
infracost output --path infracost.json --format github-comment
damp-baker-46244
03/06/2024, 2:28 PMwhite-airport-8778