broad-zoo-34077
05/24/2022, 2:17 PMmysterious-teacher-68276
05/24/2022, 2:34 PMdelightful-branch-79038
05/24/2022, 2:35 PMmysterious-teacher-68276
05/24/2022, 2:36 PMmysterious-teacher-68276
05/24/2022, 2:38 PMINFRACOST_TERRAFORM_BINARY
to specify the terraform version you want to usedelightful-branch-79038
05/24/2022, 2:38 PMdelightful-branch-79038
05/24/2022, 2:38 PMmysterious-teacher-68276
05/24/2022, 2:38 PMINFRACOST_TERRAFORM_BINARY=terraform_0.13.7
delightful-branch-79038
05/24/2022, 2:39 PMmysterious-teacher-68276
05/24/2022, 2:39 PMwhite-airport-8778
delightful-branch-79038
05/24/2022, 2:48 PMdelightful-branch-79038
05/24/2022, 2:48 PMmysterious-teacher-68276
05/24/2022, 2:48 PMdelightful-branch-79038
05/24/2022, 2:49 PMError: To show a diff:
1. Generate a cost estimate baseline: `infracost breakdown --path ./ --format json --out-file infracost-base.json`
2. Make a Terraform code change
3. Generate a cost estimate diff: `infracost diff --path ./ --compare-to infracost-base.json`
delightful-branch-79038
05/24/2022, 2:49 PMdelightful-branch-79038
05/24/2022, 2:50 PMinfracost:
stage: infracost
image:
name: infracost/infracost:0.10
entrypoint: [""]
variables:
INFRACOST_API_KEY: $INFRACOST_API_KEY
GITLAB_TOKEN: $GITLAB_TOKEN
script:
- infracost diff --config-file ./infracost.yaml --format json --out-file infracost.json
- infracost comment gitlab --path infracost.json --repo $CI_PROJECT_PATH --merge-request $CI_MERGE_REQUEST_IID --gitlab-server-url $CI_SERVER_URL --gitlab-token $GITLAB_TOKEN --behavior update
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
delightful-branch-79038
05/24/2022, 2:50 PMdelightful-branch-79038
05/24/2022, 2:51 PMmysterious-teacher-68276
05/24/2022, 2:51 PMmysterious-teacher-68276
05/24/2022, 2:51 PMmysterious-teacher-68276
05/24/2022, 2:56 PMinfracost:
stage: infracost
image:
name: infracost/infracost:ci-0.10
entrypoint: [""]
variables:
INFRACOST_API_KEY: $INFRACOST_API_KEY
GITLAB_TOKEN: $GITLAB_TOKEN
script:
- git clone $CI_REPOSITORY_URL --branch=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --single-branch /tmp/base
- |
infracost breakdown --config-file=/tmp/base/infracost.yaml \
--format=json \
--out-file=infracost-base.json
- |
infracost diff --config-file=./infracost.yaml \
--compare-to=infracost-base.json \
--format=json \
--out-file=infracost.json
- infracost comment gitlab --path infracost.json --repo $CI_PROJECT_PATH --merge-request $CI_MERGE_REQUEST_IID --gitlab-server-url $CI_SERVER_URL --gitlab-token $GITLAB_TOKEN --behavior update
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
mysterious-teacher-68276
05/24/2022, 2:56 PMdelightful-branch-79038
05/24/2022, 2:59 PMdelightful-branch-79038
05/24/2022, 3:01 PMError: config file does not exist at /tmp/base/infracost.yaml
delightful-branch-79038
05/24/2022, 3:02 PMdelightful-branch-79038
05/24/2022, 3:02 PMmysterious-teacher-68276
05/24/2022, 3:02 PMdelightful-branch-79038
05/24/2022, 3:02 PMmysterious-teacher-68276
05/24/2022, 3:03 PMmysterious-teacher-68276
05/24/2022, 3:03 PMdelightful-branch-79038
05/24/2022, 3:03 PMversion: 0.1
projects:
- path: ./
terraform_workspace: ops
terraform_plan_flags: -var-file=./ops.tfvars
terraform_var_files:
- ./ops.tfvars
delightful-branch-79038
05/24/2022, 3:04 PMdelightful-branch-79038
05/24/2022, 3:04 PMmysterious-teacher-68276
05/24/2022, 3:05 PMmysterious-teacher-68276
05/24/2022, 3:05 PMdelightful-branch-79038
05/24/2022, 3:05 PMmysterious-teacher-68276
05/24/2022, 3:05 PMdelightful-branch-79038
05/24/2022, 3:06 PM$ cp ./infracost.yaml /tmp/base/infracost.yaml
$ infracost breakdown --config-file=/tmp/base/infracost.yaml \ # collapsed multi-line command
Error: Flag terraform-plan-flags is deprecated and only compatible with --terraform-force-cli. If you want to pass Terraform variables use the --terraform-vars or --terraform-var-file flag.
delightful-branch-79038
05/24/2022, 3:07 PMdelightful-branch-79038
05/24/2022, 3:07 PMmysterious-teacher-68276
05/24/2022, 3:07 PMdelightful-branch-79038
05/24/2022, 3:07 PMmysterious-teacher-68276
05/24/2022, 3:08 PMterraform_plan_flags
argumentmysterious-teacher-68276
05/24/2022, 3:08 PMdelightful-branch-79038
05/24/2022, 3:08 PMdelightful-branch-79038
05/24/2022, 3:09 PMdelightful-branch-79038
05/24/2022, 3:11 PMversion: 0.1
projects:
- path: ./
terraform_workspace: <workspace name>
terraform_var_files:
- <workspace var file>
2. need to use this gitlab job:
- git clone $CI_REPOSITORY_URL --branch=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --single-branch /tmp/base
- cp ./infracost.yaml /tmp/base/infracost.yaml
- |
infracost breakdown --config-file=/tmp/base/infracost.yaml \
--format=json \
--out-file=infracost-base.json
- |
infracost diff --config-file=./infracost.yaml \
--compare-to=infracost-base.json \
--format=json \
--out-file=infracost.json
- infracost comment gitlab --path infracost.json --repo $CI_PROJECT_PATH --merge-request $CI_MERGE_REQUEST_IID --gitlab-server-url $CI_SERVER_URL --gitlab-token $GITLAB_TOKEN --behavior update
delightful-branch-79038
05/24/2022, 3:11 PMdelightful-branch-79038
05/24/2022, 3:11 PMmysterious-teacher-68276
05/24/2022, 3:11 PMcp
step can be removedmysterious-teacher-68276
05/24/2022, 3:12 PMdelightful-branch-79038
05/24/2022, 3:12 PMmysterious-teacher-68276
05/24/2022, 3:13 PMmysterious-teacher-68276
05/24/2022, 3:13 PMdelightful-branch-79038
05/24/2022, 3:13 PMdelightful-branch-79038
05/24/2022, 3:13 PMmysterious-teacher-68276
05/24/2022, 3:14 PMdelightful-branch-79038
05/24/2022, 3:14 PMdelightful-branch-79038
05/24/2022, 3:14 PMdelightful-branch-79038
05/24/2022, 3:14 PMmysterious-teacher-68276
05/24/2022, 3:15 PMi mean if i change aws instance node manually in aws (ex) and then want to change terraform to be the same as the current state, it will not showing me any cost changeyes this is correct. This would be infrastructure drift. If you want to cover this case you can generate a Terraform plan JSON output and have Infracost read it.
mysterious-teacher-68276
05/24/2022, 3:16 PMi see , so generally no need to any aws cred anymoreYes
delightful-branch-79038
05/24/2022, 3:17 PMmysterious-teacher-68276
05/24/2022, 3:17 PMmysterious-teacher-68276
05/24/2022, 3:17 PMdelightful-branch-79038
05/24/2022, 3:30 PMmysterious-teacher-68276
05/24/2022, 3:31 PMmysterious-teacher-68276
05/24/2022, 3:31 PMdelightful-branch-79038
05/24/2022, 3:31 PMdelightful-branch-79038
05/24/2022, 3:32 PMops
using terraform modulemysterious-teacher-68276
05/24/2022, 3:33 PMdelightful-branch-79038
05/24/2022, 3:33 PMdelightful-branch-79038
05/24/2022, 3:33 PMresource "aws_autoscaling_group" "eks-autoscalling-group" {
~ desired_capacity = 3 -> 6
id = "eks-ops-worker"
~ max_size = 3 -> 6
~ min_size = 3 -> 6
name = "eks-ops-worker"
# (19 unchanged attributes hidden)
# (5 unchanged blocks hidden)
}
fast-motorcycle-7174
05/24/2022, 3:36 PMmysterious-teacher-68276
05/24/2022, 3:37 PMmysterious-teacher-68276
05/24/2022, 3:38 PMdelightful-branch-79038
05/24/2022, 3:38 PMThe following projects have no cost estimate changes: ops/terraform/eks/eks-development/. (dev), ops/terraform/eks/eks-development/. (ops), ops/terraform/eks/eks-development/. (qa)
Run the following command to see their breakdown: infracost breakdown --path=/path/to/code
delightful-branch-79038
05/24/2022, 3:38 PMmysterious-teacher-68276
05/24/2022, 3:39 PMmysterious-teacher-68276
05/24/2022, 3:39 PMinfracost
locally?delightful-branch-79038
05/24/2022, 3:39 PMdelightful-branch-79038
05/24/2022, 3:39 PMmysterious-teacher-68276
05/24/2022, 3:40 PMdelightful-branch-79038
05/24/2022, 3:40 PMmysterious-teacher-68276
05/24/2022, 3:51 PMdelightful-branch-79038
05/24/2022, 8:08 PMinfracost:
stage: infracost
image:
name: infracost/infracost:0.10
entrypoint: [""]
variables:
INFRACOST_API_KEY: $INFRACOST_API_KEY
GITLAB_TOKEN: $GITLAB_TOKEN
script:
- echo "git clone $CI_REPOSITORY_URL --branch=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --single-branch /tmp/base"
- git clone $CI_REPOSITORY_URL --branch=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --single-branch /tmp/base
- cp ./infracost.yaml /tmp/base/infracost.yaml; cd /tmp/base
- |
infracost breakdown --config-file=./infracost.yaml \
--format=json \
--out-file=$CI_PROJECT_DIR/infracost-base.json
- cd -
- |
infracost diff --config-file=./infracost.yaml \
--compare-to=$CI_PROJECT_DIR/infracost-base.json \
--format=json \
--out-file=infracost.json
- infracost comment gitlab --path infracost.json --repo $CI_PROJECT_PATH --merge-request $CI_MERGE_REQUEST_IID --gitlab-server-url $CI_SERVER_URL --gitlab-token $GITLAB_TOKEN --behavior update
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'