-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/google: Changed network argument in google_compute_instance_group as optional #13493
provider/google: Changed network argument in google_compute_instance_group as optional #13493
Conversation
…group as optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @tmshn! I have a few small pieces of feedback, but this is nice and simple and should be able to be merged pretty quickly :)
@@ -128,6 +130,10 @@ func resourceComputeInstanceGroupCreate(d *schema.ResourceData, meta interface{} | |||
instanceGroup.NamedPorts = getNamedPorts(v.([]interface{})) | |||
} | |||
|
|||
if v, ok := d.GetOk("network"); ok { | |||
instanceGroup.Network = v.(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other terraform resources, we have the network parameter be the name of the network and then do a lookup. For consistency, I think we should do that here too. See https://github.com/hashicorp/terraform/blob/master/builtin/providers/google/resource_compute_instance.go#L479 for an example.
@@ -201,7 +211,34 @@ func testAccComputeInstanceGroup_named_ports(n string, np map[string]int64, inst | |||
} | |||
} | |||
|
|||
func testAccComputeInstanceGroup_basic(instance string) string { | |||
func testAccComputeInstanceGroup_network(n string, network string, instanceGroup *compute.InstanceGroup) resource.TestCheckFunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can you rename this to something like testAccComputeInstanceGroup_networkExists
? Check functions (in my opinion) should be more boolean-like in name to make it clear that it's a check and not a config.
name = "%s-empty-with-network" | ||
network = "%s" | ||
zone = "us-central1-c" | ||
named_port { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation
…testAccComputeInstanceGroup_hasCorrectNetwork
@danawillow Hey, sorry for the late reaction, but I fixed the points you reviewed! 👍 So could you check again? Actually the first point, the one about the |
Oh, good point about backwards incompatibility- I think you're right, sorry to lead you down the wrong path. |
18ba343
to
036535d
Compare
…uteInstanceGroup_basic
036535d
to
086059f
Compare
@danawillow No problem! I dropped the last commit (and bit modified the next last one). |
"GCLOUD_PROJECT", | ||
"CLOUDSDK_CORE_PROJECT", | ||
} | ||
var networkUrl = fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s", multiEnvSearch(projs), networkName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't feel very basic anymore. Mind creating a new test for this? I also think creating the network from within the test would be nicer than relying on the default network and having to read the project from the environment.
@danawillow Divided the test for the network 👍 |
@@ -201,6 +227,44 @@ func testAccComputeInstanceGroup_named_ports(n string, np map[string]int64, inst | |||
} | |||
} | |||
|
|||
func testAccComputeInstanceGroup_hasCorrectNetwork(n_ig string, n_nw string, instanceGroup *compute.InstanceGroup) resource.TestCheckFunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: I'm not a huge fan of mixing types of cases- let's leave everything camelCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but what does "everything" mean? "Every function names" including the ones I didn't modify? Or just "every letter" of this function name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I just meant the variables (n_ig, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, yeah, I got it 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 💪 28f0d5e
|
||
resource "google_compute_instance_group" "with_instance" { | ||
description = "Terraform test instance group" | ||
name = "%[1]s-with-insntance" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry! Fixed -> 4aa065c
|
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. |
If you want to add an instance group to a backend service, the
network
filed of the instance group must be set.Formerly this field is set based on the network where instances are in (this is computed by Google API). It means; if you create the empty instance group, the
network
field will be empty, and you cannot add it to a backend service.In this PR, I changed
network
field ingoogle_compute_instance_group
from the computed attribute to the configurable optional argument.Now user can specify network the group is in and add it to a backend service.