-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Supporting Disk Labels on Instance bootDisk and InstanceTemplate disks #3766
Supporting Disk Labels on Instance bootDisk and InstanceTemplate disks #3766
Conversation
I realize that I haven't updated the documentation for the google_compute_instance and google_compute_instance_template resources. I can add those to the PR if the general approach is ok. |
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.
Seems like a reasonable approach. Yes please add docs!
@@ -587,6 +596,8 @@ func buildDisks(d *schema.ResourceData, config *Config) ([]*computeBeta.Attached | |||
} | |||
disk.InitializeParams.SourceImage = imageUrl | |||
} | |||
|
|||
disk.InitializeParams.Labels = expandStringMap(d, prefix+".labels") |
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.
You are allowing labels
on all disk types in the Schema but they won't work if somebody is using them on a disk that's using source
. Ideally we'd use ConflictsWith
to throw a plan level error but due to limitations in core Terraform we can't use it with lists of nested objects.
Unfortunately this is apparently already a bug with all the other initializeParams fields, but can you add a caveat to the docs for labels.
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.
I understand. I think with the behaviour clearly explained it should be ok. When using the source
, an existing disk is being specified, and regardless of how that disk came into existence (Terraform, Google API, Google Cloud console), the labels could have been set at the time of creation.
My PR is to cover the case where the disks do not exist until the instance template is used to create an instance.
6ec481c
to
34c820a
Compare
0980171
to
5d2d229
Compare
upstream and closed by GoogleCloudPlatform/magic-modules#2106 |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This PR introduces a change that allows specifying labels in the disk block of a google_compute_instance_template resource and in the boot_disk block of a google_compute_instance resource.
The Google API allows setting labels in both of these contexts, so the change simply consists of modifying the resource schemas to allow a label map and then adding the code to retrieve the values from within the resource and set the correct parameters for the API request.