mammoth-painting-38799
10/18/2022, 7:25 AMbusy-agent-35515
10/18/2022, 7:47 AM<https://pricing.api.infracost.io>
, it is defined here: https://github.com/infracost/cloud-pricing-api/blob/c19f79972788a88dffa60d47abf13ac96048524a/src/config.ts#L82
Where it is used for data download: https://github.com/infracost/cloud-pricing-api/blob/636115f365e6fc442fc1194a1da18cd42ba5a94c/src/cmd/dataDownload.ts#L28npm run data:scrape
mammoth-painting-38799
10/18/2022, 8:45 AMbusy-agent-35515
10/18/2022, 8:50 AMmammoth-painting-38799
10/18/2022, 9:53 AMbusy-agent-35515
10/18/2022, 9:55 AMmammoth-painting-38799
10/18/2022, 10:15 AMbusy-agent-35515
10/18/2022, 10:21 AMnpm run job:init
or you run the scraper. With the scrape approach you can also choose the cloud vendor, these are the available options for the flag --only=[aws:bulk,aws:spot,azure:retail,gcp:catalog,gcp:machineTypes]
mammoth-painting-38799
10/18/2022, 10:35 AMbusy-agent-35515
10/18/2022, 11:00 AMinit_job
mammoth-painting-38799
10/18/2022, 11:03 AMbusy-agent-35515
10/18/2022, 11:03 AMmammoth-painting-38799
10/18/2022, 11:07 AMdocker network create cloud_pricing_api
which created bridge network
2nd run postgres:13.4 as container, started successfully
starting PostgreSQL 13.4 (Debian 13.4-4.pgdg110+1) on x86 _64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
listening on IPv4 address"0.0.0.0".port 5432
listening on IPv6 address"::", port 5432
listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
database system was shut down at 2022-10-19 07:09:16 UTC
database system is ready to accept connections
3rd when i run init job, getting below error after 10 retry
{"level":50,"time":1666164483057,'pid :29, " hostname": "545af87929a2"msg': "Waiting for Postgres@L
to become available: connect ECONNREFUSED 127.0.0.1:5432 }
("level":50, "time":1666164493066, "pid":29, "hostnalme" •"545af8792922"erp"Error."message":""Failed to connect to PostereSOL". "stack": "Error: Failed to connect to PostereSOLIn
at /usr/src/app/dist/cmd/db
Setup.js:80:31\n
at step (/usr/src/app/dist/cmd/dbSetup.is:33:23)\n
Object.next (/usr/src/app/dist/cmd/dbSetup.is:14:53n
at fulfilled (/usr/src/app/dist/cmd/dbSetup.JS:5:58)h,msg:Falledtoconnect
to PostgreSOL"}
nom ERRI Code ELIFECYCLE
nom ERR. errno 1
pm ERR! Cloud-pricing-api@0.3.7 db: setup:
*node dist/cmd/dbSetup.js
nom ERR.
pm ERR! Failed at the cloud-pricing-apige.3.7 db:setup script.
nom ERRI This is probablv not a problem with nom.
mare
likely
additional lossing
outnut above.
pm ERR! A complete log of this run can be found in:
/root/.npm/_logs/2022-10-19T07_28_13_0872-debug.log
nom ERR! Code ELIFECYCLE
errno
pm ERR! cloud-pricing-api@@.3.7 job:init: 'npm run db:setup && npm run job:update
npm ERR! Exit status
pm ERR! Failed at the cloud-pricing-api@o.3.7 job: init script.
npm ERR. In1s 15 probably not a problem witn nom.
There is likely additional logging output above.
pm ERR! A complete l0g of this run can be found in:
nomER
/root/.npm/_logs/2022-10-19T07_28_13_118-debug.10g
pls help how to fix this. Highly appriciatedbusy-agent-35515
10/19/2022, 8:23 AMconnect ECONNREFUSED 127.0.0.1:5432
looks suspicious, it tries to connect to localhost, not your network. Does the init_job container use the network?POSTGRES_HOST=postgres
and networks: - cloud_pricing_api
in the docker-compose.ymlmammoth-painting-38799
10/19/2022, 8:32 AMdocker network create cloud _pricing_api
#db
docker run -d\
--network cloud pricing api \
-v postgres-data:/var/lib/postgresql/data/ \
-u posteres \
- POSTGRES_PASSWORD=postgres \
--health-cmd="CMD-SHELL" \
--health-cmd="pg_isready" \
--health-interval=60s \
--health-timeout=10s \
--health-retries=3 \
--health-start-period=10s \
-restart on-failure \
postgres:13.4
#init job
docker run
--network cloud pricing_api \
-e INFRACOST_API KEY \
-e POSTGRES_HOST \
-e POSTGRES_DB \
-e POSTGRES_USER \
-e POSTGRES_PASSWORD \
cloud-pricing-api:latest npm run job:init
busy-agent-35515
10/19/2022, 8:45 AM-h postgres
to the postgres container? This way you'll set its hostname, so you can use POSTGRES_HOST=postgres
with the init job (and other containers that depend on the db)mammoth-painting-38799
10/19/2022, 8:51 AMWaiting for PostgreSQL to become available: getaddrinfo ENOTFOUND postgres
@busy-agent-35515 i suspect something todo with network? i see default bridge nework is created with docker network create cloud _pricing_api
busy-agent-35515
10/19/2022, 8:57 AMmammoth-painting-38799
10/19/2022, 8:58 AMbusy-agent-35515
10/19/2022, 8:58 AM--name postgres
instead of -h
onepodman pod inspect <container>
should tell you what the hostname ismammoth-painting-38799
10/19/2022, 10:50 AM--network host
, init_job
it, data_scare
working with download errors,
now i am getting new error while dataDownload & dataScpae both
There was an error downloading data: connect EINVAL 0.0.1.187:80 - Local (0.0.0.0:0)
I can confirm that no issue with infracost.io, amazonaws.com,*googleapis.com,*azure.com domain accessbusy-agent-35515
10/19/2022, 11:13 AM<https://pricing.api.infracost.io>
. Quick googling showed that the reason for this error might be missing protocol (https://), but I find it strange as the default endpoint certainly has it. Here's an SO where I found it https://stackoverflow.com/questions/48939454/error-connect-einval-0-0-xx-xx80-local-0-0-0-00mammoth-painting-38799
10/19/2022, 11:21 AMThere was an error downloading data: connect EINVAL 0.0.1.187:80 - Local (0.0.0.0:0)
any workaround or fix please? Appreciated your helpbusy-agent-35515
10/20/2022, 8:39 AMINFRACOST_PRICING_API_ENDPOINT
env var set, right?mammoth-painting-38799
10/20/2022, 8:44 AMbusy-agent-35515
10/20/2022, 9:05 AMnpm data:load --path=path/to/file
to populate the database. I'm sorry, it's not the solution for the issue, but it should help unblock you with the CPAPIcsv.gz
filemammoth-painting-38799
10/20/2022, 10:21 AMbusy-agent-35515
10/20/2022, 10:22 AMmammoth-painting-38799
10/20/2022, 10:27 AMbusy-agent-35515
10/21/2022, 10:16 AM/root
to save/delete these filesmammoth-painting-38799
10/25/2022, 3:08 AMcurl -i $INFRACOST_PRICING_API_ENDPOINT/health
is 200 okey,
curl -i $INFRACOST_PRICING_API_ENDPOINT/graphql -H "X-Api-Key: $SELF_HOSTED_INFRACOST_API_KEY
is 400 Get query missing
when i run infracost breakdown --path .
Error while Retrieving cloud prices to calculate costs
Error: Invalid API key
Please check your /home/user1/.config/infracost/credentials.yml or INFRACOST_API_KEY env variable.
i am 200% sure that /home/user1/.config/infracost/credentials.yml key is correct. What wrong here
? thanks in Advancebusy-agent-35515
10/25/2022, 8:14 AMSELF_HOSTED_INFRACOST_API_KEY
generated and exported - this is the key that CLI will use to authenticate with it (for example, it will be cpapi-key
). For CPAPI you can also set up INFRACOST_API_KEY
with the one you got from Infracost - this is needed to update the database. For example, it will be infra-key
.
3. On CLI side you need to configure two env vars: INFRACOST_PRICING_API_ENDPOINT
to point to your CPAPI (you mentioned <http://localhost:4000>
). And CLI should also have INFRACOST_API_KEY
generated by CPAPI, from example it should be cpapi-key
cpapi-key
, not the one Infracost generated for you.api_key: cpapi-key
pricing_api_endpoint: <http://localhost:4000>
export INFRACOST_API_KEY=$SELF_HOSTED_INFRACOST_API_KEY
export INFRACOST_API_KEY="<<MY API KEY>>"
mammoth-painting-38799
10/25/2022, 8:28 AMbusy-agent-35515
10/25/2022, 8:31 AMconfigure set
command - it stores values in the credentials yamlmammoth-painting-38799
10/25/2022, 8:33 AMbusy-agent-35515
10/25/2022, 8:34 AMexport SELF_HOSTED_INFRACOST_API_KEY=$SELF_HOSTED_INFRACOST_API_KEY
export INFRACOST_API_KEY=infra-key
And this should be done for CLI:
export INFRACOST_PRICING_API_ENDPOINT=<http://localhost:4000>
export INFRACOST_API_KEY=cpapi-key
INFRACOST_API_KEY=cpapi-key infracost breakdown --path .
replacing the cpapi-key with your actual key?mammoth-painting-38799
10/25/2022, 8:37 AMinfracost breakdown --path .
Is this could be issue?busy-agent-35515
10/25/2022, 8:38 AMecho $INFRACOST_API_KEY
echo $SELF_HOSTED_INFRACOST_API_KEY
?mammoth-painting-38799
10/25/2022, 9:16 AMbusy-agent-35515
10/25/2022, 9:17 AMINFRACOST_API_KEY=cpapi-key infracost breakdown --path .
it should not clash. Can you try that?mammoth-painting-38799
10/25/2022, 9:53 AMbusy-agent-35515
10/25/2022, 9:55 AMmammoth-painting-38799
10/25/2022, 2:40 PMbusy-agent-35515
10/25/2022, 2:42 PM.env
file where the env vars are defined. And we recommend to use the docker compose approach as it's fast and clean. Unfortunately, we can't account for all the corner cases. Sorry, that your case was one of those 🙂