flat-article-86750
09/10/2022, 12:34 AMinfracost diff
command following the instructions that we can find in the documentation (https://www.infracost.io/docs/features/cli_commands/#option-2-terraform-plan-json-1), but there's something that doesn't make sense for me. If the terraform plan says that it's going to change 1 resource, why the diff command is trying to estimate all the resources and the result is that the whole deployment is added and none is changed?.crooked-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 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 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.Error: 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
crooked-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 PMcrooked-daybreak-55253
09/12/2022, 8:39 PMflat-article-86750
09/12/2022, 9:14 PMcrooked-daybreak-55253
09/12/2022, 9:43 PMflat-article-86750
09/12/2022, 9:44 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 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 AMTF_IN_AUTOMATION=true
Could you please try with it?crooked-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