broad-zoo-34077
09/10/2022, 12:34 AMcrooked-daybreak-55253
09/10/2022, 1:22 AMinfracost diff
looks at the resource changes so I’m not sure why it would be showing something different than showing the terraform plan. You’re using the commands the same as in the docs, without any other flags or anything?
terraform init
terraform plan -out tfplan.binary
terraform show -json tfplan.binary > plan.json
infracost diff --path plan.json
flat-article-86750
09/12/2022, 4:38 PMflat-article-86750
09/12/2022, 4:45 PMcrooked-daybreak-55253
09/12/2022, 4:48 PMresource_changes
key of the plan.json? If you have jq
available you do something like: plan.json | jq .resource_changes
flat-article-86750
09/12/2022, 4:50 PMflat-article-86750
09/12/2022, 6:41 PMflat-article-86750
09/12/2022, 6:43 PMcrooked-daybreak-55253
09/12/2022, 7:04 PMplanned_values.root_module
and prior_state.values.root_module
keys.flat-article-86750
09/12/2022, 7:23 PMterraform init &&
terraform plan -out 'tfplan.binary' &&
terraform show -json 'tfplan.binary' > 'pr-dev-onboarding-cloud-infrastructure-tfplan.json' &&
echo 'tf show: pr-dev-onboarding-cloud-infrastructure-tfplan.json' &&
cat 'pr-dev-onboarding-cloud-infrastructure-tfplan.json' &&
INFRACOST_VCS_PROVIDER='github'
INFRACOST_VCS_REPOSITORY_URL='<https://github.com/xxxxxxxx/xxxxxxxxxxxxxxx>'
INFRACOST_VCS_PULL_REQUEST_URL='<https://github.com/xxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxx/pull/20676>'
INFRACOST_VCS_BASE_BRANCH='development'
INFRACOST_VCS_PULL_REQUEST_AUTHOR='Alexis Mosquera'
INFRACOST_VCS_COMMIT_AUTHOR_EMAIL='<mailto:XXXXXXXXXXXX@XXXXXXXXX.com|XXXXXXXXXXXX@XXXXXXXXX.com>'
INFRACOST_VCS_PULL_REQUEST_TITLE='feat(infracost): enable multiprojects pr'
INFRACOST_VCS_BRANCH='PR-20676'
INFRACOST_VCS_COMMIT_SHA='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
INFRACOST_VCS_COMMIT_MESSAGE='feat(infracost): test special chars'
INFRACOST_VCS_COMMIT_TIMESTAMP='1662731045'
infracost diff --path 'pr-dev-onboarding-cloud-infrastructure-tfplan.json' &&
infracost output --format diff --path 'pr-dev-onboarding-cloud-infrastructure-tfplan.json'
Let me check the keys you requested.flat-article-86750
09/12/2022, 7:26 PMError: could not load input file pr-dev-onboarding-cloud-infrastructure-tfplan.json err: invalid Infracost JSON file version. Supported versions are 0.2 ≤ x ≤ 0.2
flat-article-86750
09/12/2022, 7:27 PMcrooked-daybreak-55253
09/12/2022, 7:35 PMinfracost output
expects an infracost json, not the plan json so that is where the error is coming fromflat-article-86750
09/12/2022, 7:37 PMflat-article-86750
09/12/2022, 7:47 PMcrooked-daybreak-55253
09/12/2022, 8:39 PMflat-article-86750
09/12/2022, 9:14 PMflat-article-86750
09/12/2022, 9:20 PMflat-article-86750
09/12/2022, 9:21 PMflat-article-86750
09/12/2022, 9:23 PMflat-article-86750
09/12/2022, 9:28 PMflat-article-86750
09/12/2022, 9:29 PMcrooked-daybreak-55253
09/12/2022, 9:43 PMflat-article-86750
09/12/2022, 9:44 PMflat-article-86750
09/12/2022, 9:47 PMflat-article-86750
09/12/2022, 9:47 PMcrooked-daybreak-55253
09/12/2022, 9:51 PM{"format_version":"1.1","terraform_version":"1.2.9",
flat-article-86750
09/12/2022, 9:52 PMflat-article-86750
09/12/2022, 10:20 PMcrooked-daybreak-55253
09/13/2022, 1:11 AMprior_state
populated and the infracost diff working correctly:
...
"prior_state": {
"format_version": "0.1",
"terraform_version": "0.12.31",
"values": {
"outputs": {
"aws_instance_type": {
"sensitive": false,
"value": "t2.nano"
}
},
"root_module": {
"resources": [
{
"address": "aws_instance.web_app",
"mode": "managed",
"type": "aws_instance",
"name": "web_app",
"provider_name": "aws",
"schema_version": 1,
"values": {
"ami": "ami-079ca844e323047c2",
"arn": "arn:aws:ec2:us-east-1:186080867442:instance/i-0fd93ce246912900e",
flat-article-86750
09/13/2022, 1:33 AMflat-article-86750
09/13/2022, 1:34 AMflat-article-86750
09/13/2022, 1:46 AMTF_IN_AUTOMATION=true
Could you please try with it?flat-article-86750
09/13/2022, 1:46 AMcrooked-daybreak-55253
09/13/2022, 2:13 AMflat-article-86750
09/13/2022, 2:17 AMcrooked-daybreak-55253
09/13/2022, 2:04 PMlittle-author-61621