Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is there a big price difference between infracost and gcp calculator? #2473

Closed
aliscott opened this issue May 24, 2023 Discussed in #2472 · 12 comments
Closed

Why is there a big price difference between infracost and gcp calculator? #2473

aliscott opened this issue May 24, 2023 Discussed in #2472 · 12 comments
Assignees
Labels
google Issue related to Google Cloud

Comments

@aliscott
Copy link
Member

Discussed in #2472

Originally posted by Alexlofern May 23, 2023
image
image

I'm using 0.10.22 version.

Regards

Alexandre

@aliscott aliscott added the google Issue related to Google Cloud label May 24, 2023
@aliscott
Copy link
Member Author

@Alexlofern are you able to share the Terraform code that was used to generate the estimate?

@Alexlofern
Copy link

@Alexlofern are you able to share the Terraform code that was used to generate the estimate?

Yes, sure
main.tf.txt
output.tf.txt
provider.tf.txt
variables.tf.txt

@aliscott aliscott self-assigned this May 25, 2023
@aliscott
Copy link
Member Author

Thanks @Alexlofern looks like there's two issues here causing the mismatch.

  1. The Google pricing calculator estimate is for a zonal SQL instance, but the code is using a regional instance. You can change this in the Google pricing calculator by selecting 'Enable High Availability Configuration'.
  2. Infracost is detecting the incorrect region, and currently showing the prices for us-central1. I've put in a fix for this here fix(google): if region is specified at the resource level, use that #2475, which will be released in the next release. Until then, you should be able to get the correct estimate by specifying the region inline in the provider block, e.g:
provider "google" {
  # Configuration options
  region = "europe-west3"
}

@Alexlofern
Copy link

Thanks @Alexlofern looks like there's two issues here causing the mismatch.

  1. The Google pricing calculator estimate is for a zonal SQL instance, but the code is using a regional instance. You can change this in the Google pricing calculator by selecting 'Enable High Availability Configuration'.
  2. Infracost is detecting the incorrect region, and currently showing the prices for us-central1. I've put in a fix for this here fix(google): if region is specified at the resource level, use that #2475, which will be released in the next release. Until then, you should be able to get the correct estimate by specifying the region inline in the provider block, e.g:
provider "google" {
  # Configuration options
  region = "europe-west3"
}

Hi, I did everything you asked, but there is still a small difference, I tried logged in and out of the calculator, the values are the same for my contract

image image

@aliscott
Copy link
Member Author

Thanks @Alexlofern. I've been trying to reproduce running against the following code and have been unable to reproduce. I'm seeing the expected $22.48 cost:

provider "google" {
  credentials = "{\"type\":\"service_account\"}"
  region      = "europe-west3"
}

resource "google_sql_database_instance" "sql_instance" {
  project             = "my-project"
  name                = "my-instance"
  region              = "europe-west3"
  database_version    = "POSTGRES_14"

  settings {
    tier = "db-f1-micro"
    availability_type = "REGIONAL"
    disk_size = 10

    ip_configuration {
      ipv4_enabled = false
    }
  }
}

It seems like somehow the resource is getting the wrong region, since those prices you are seeing are from europe-west8 or europe-west9 instead of europe-west3.

  1. What command are you using the run infracost?
  2. Does it show the correct price if you run with INFRACOST_GOOGLE_OVERRIDE_REGION=europe-west3 env variable set?

@Alexlofern
Copy link

Alexlofern commented May 25, 2023

Thanks @Alexlofern. I've been trying to reproduce running against the following code and have been unable to reproduce. I'm seeing the expected $22.48 cost:

provider "google" {
  credentials = "{\"type\":\"service_account\"}"
  region      = "europe-west3"
}

resource "google_sql_database_instance" "sql_instance" {
  project             = "my-project"
  name                = "my-instance"
  region              = "europe-west3"
  database_version    = "POSTGRES_14"

  settings {
    tier = "db-f1-micro"
    availability_type = "REGIONAL"
    disk_size = 10

    ip_configuration {
      ipv4_enabled = false
    }
  }
}

It seems like somehow the resource is getting the wrong region, since those prices you are seeing are from europe-west8 or europe-west9 instead of europe-west3.

  1. What command are you using the run infracost?
  2. Does it show the correct price if you run with INFRACOST_GOOGLE_OVERRIDE_REGION=europe-west3 env variable set?

Hi,

My main location is europe-west9, I use europe-west3 for replication of the database!

I just run:

    infracost breakdown --path $(SCRIPTRUNPATH) --format json --out-file $(SCRIPTRUNPATH)/infracost.json
    infracost output --path $(SCRIPTRUNPATH)/infracost.json --format table --show-skipped

I'll try use this var INFRACOST_GOOGLE_OVERRIDE_REGION, but I fill that isn't good idea, because of the read replica in another region, if have more suggestions, I appreciate.

My infracost output:

image

Tks

@Alexlofern
Copy link

testing without replica, backup in the same region, same results:

image image

@aliscott
Copy link
Member Author

My main location is europe-west9, I use europe-west3 for replication of the database!

Thanks for the details. Just to clarify, is the following correct?

  1. var.LOCATION is set to europe-west9
  2. var.LOCATION_DR is set to europe-west3

If so then the expected prices should be:

  • google_sql_database_instance.sql_instance to be $21.75 (price in europe-west9)
  • google_sql_database_instance.read_replica[0] to be $22.48 (price in europe-west3)

Currently what you're seeing is:

  • google_sql_database_instance.sql_instance is $21.75 (price in europe-west9)
  • google_sql_database_instance.read_replica[0] is $21.75 (price in europe-west9)

@Alexlofern
Copy link

My main location is europe-west9, I use europe-west3 for replication of the database!

Thanks for the details. Just to clarify, is the following correct?

  1. var.LOCATION is set to europe-west9
  2. var.LOCATION_DR is set to europe-west3

If so then the expected prices should be:

  • google_sql_database_instance.sql_instance to be $21.75 (price in europe-west9)
  • google_sql_database_instance.read_replica[0] to be $22.48 (price in europe-west3)

Currently what you're seeing is:

  • google_sql_database_instance.sql_instance is $21.75 (price in europe-west9)
  • google_sql_database_instance.read_replica[0] is $21.75 (price in europe-west9)

Yes, correct, tks

I found a glitch in my code and I fix

image image

@Alexlofern
Copy link

Alexlofern commented May 25, 2023

Oh, but when I deploy the second, I get the value from default of provider, I'll wait for the new release:

image

@aliscott
Copy link
Member Author

👍 thanks for confirming @Alexlofern, I'll update this issue when the release is out.

@aliscott
Copy link
Member Author

@Alexlofern thanks for your help with this 🙏. This has now been released in v0.10.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
google Issue related to Google Cloud
Projects
None yet
Development

No branches or pull requests

2 participants