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

Unintended forces replacement in google_vpc_access_connector #12411

Labels
bug forward/review In review; remove label to forward service/vpcaccess

Comments

@sho-abe
Copy link

sho-abe commented Aug 29, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.2.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v4.33.0
+ provider registry.terraform.io/hashicorp/google-beta v4.33.0

Affected Resource(s)

  • google_vpc_access_connector

Terraform Configuration Files

resource "google _compute_network" "main" {
  project                 = "your-project-id"
  name                    = "vpc-access-test"
  auto_create_subnetworks = false
  routing_mode            = "REGIONAL"
}

resource "google_compute_subnetwork" "main" {
  project       = "your-project-id"
  ip_cidr_range = "10.10.0.0/28"
  name          = "vpc-access-connector-sub"
  network       = google_compute_network.main.self_link
  region        = "asia-northeast1"
}

resource "google_vpc_access_connector" "connector" {
  provider = google-beta
  project  = "your-project-id"
  name     = "vpc-access-connector"
  region   = google_compute_subnetwork.main.region

  subnet {
    name = google_compute_subnetwork.main.name
  }

  machine_type  = "e2-micro"
  min_instances = 5
  max_instances = 10
}

Expected Behavior

No difference occurs in google_vpc_access_connector when executing terraform plan/apply.

Actual Behavior

Forces replacements occur in google_vpc_access_connector when executing terraform plan/apply.

Steps to Reproduce

  1. Create a tf file as per the "Terraform Configuration Files" section.
  2. Create VPC Access connector by terraform apply.
  3. Re-execute terraform plan or terraform apply.

Important Factoids

The default values are set in the google-beta provider for max_throughput and min_throughput.
It seems that these default values unintentionally conflict with the max_instances and min_instances.

References

@sho-abe sho-abe added the bug label Aug 29, 2022
@edwardmedia edwardmedia self-assigned this Aug 29, 2022
@edwardmedia
Copy link
Contributor

edwardmedia commented Aug 29, 2022

Looks like the defaults are updated on API

    "minThroughput": 500,
    "maxThroughput": 1000,

b/244156777

https://cloud.google.com/vpc/docs/reference/vpcaccess/rest/v1/projects.locations.connectors

@sho-abe
Copy link
Author

sho-abe commented Aug 30, 2022

@edwardmedia Thank you for your response.
I think there is not a good way to change Terraform provider's default values.
Because the difference is not detected when max_instances = 2 and min_instances = 3 as below.

resource "google_vpc_access_connector" "connector" {
  provider = google-beta
  name     = "vpc-access-connector"
  region   = google_compute_subnetwork.main.region

  subnet {
    name = google_compute_subnetwork.main.name
  }

  machine_type  = "e2-micro"
  min_instances = 2
  max_instances = 3
}

I guess the API is also changing the max_throughput and min_throughput values, probably according to the max_instances and min_instances values.
So I think it's better not to set default values of max_throughput and min_throughput in the Terraform provider.

Regards

@melinath
Copy link
Collaborator

previous PR caused test failures that represent real user issues - see GoogleCloudPlatform/magic-modules#6541 for revert PR.

@melinath melinath reopened this Sep 13, 2022
@edwardmedia edwardmedia assigned c2thorn and unassigned edwardmedia Sep 28, 2022
@github-actions github-actions bot added forward/review In review; remove label to forward service/vpcaccess labels Oct 25, 2023
@sho-abe
Copy link
Author

sho-abe commented Aug 28, 2024

It looks to me like this issue has been fixed in version 6.0.0.

https://github.com/hashicorp/terraform-provider-google/releases/tag/v6.0.0

vpcaccess: removed default values for min_throughput and min_instances fields on google_vpc_access_connector and made them default to values returned from the API when not provided by users (#18697)

Thanks,

@melinath
Copy link
Collaborator

great to hear, thanks for catching that!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.