hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.29k stars 1.72k forks source link

Support Resource Manager Tags for GKE #16614

Open maxi-cit opened 9 months ago

maxi-cit commented 9 months ago

Community Note

Description

Currently, only VMs and Instance have Resource Manager Tags support. This will allow to set custom firewall rules within the nodes that belong to a GKE Cluster.

New or Affected Resource(s)

Potential Terraform Configuration

node_config = {
...
    resource_manager_tags = {
      "tagKeys/${google_tags_tag_key.key.name}" = "tagValues/${google_tags_tag_value.value.name}"
    }
...
}

References

b/315953619

bcorbitt-ps commented 6 months ago

Question on what was implemented in https://github.com/GoogleCloudPlatform/magic-modules/pull/9531. It appears to me that resource_manager_tags was implemented for the node_config block within the google_container_cluster resource and has not been implemented (yet?) in google_container_node_pool, making this applicable only for the default pool. Is that accurate?

maxi-cit commented 6 months ago

Hello @bcorbitt-ps node_pool resource references the same object (node_config) as the cluster resource so it may seem that it is only implemented for clusters. I added a usage example for 'node_pools' in the tests.

Let me know if you find something to fix.

bcorbitt-ps commented 6 months ago

Thanks for the reply @maxi-cit. Everything planned and applied, but I was unable to "see" the tags anywhere. (Nothing in the console, nothing returned for gcloud resource-manager tags bindings list), but appears I may not have found just the right command. gcloud beta container node-pools describe <node-pool> --format="value(config.resourceManagerTags)" appears to be that command. Now I just need to verify that the tag alone (without a binding?) is sufficient to inherit a rule. Thanks a bunch for the contribution here!

sanmaym commented 6 months ago

I also followed up on this and found this public documentation page I think we need to incorporate "autoprovisioning-resource-manager-tags" support in container-cluster resource to apply all secure tags at a cluster level?

Cluster-level setting

GKE applies the tags to all new auto-provisioned node pools in the cluster. If you use this flag on an existing cluster, existing node pools retain any tags that were applied before the update

maxi-cit commented 5 months ago

Hello @sanmaym, I added support for auto provisioned clusters in this PR. In case there isnt anything more to add I think we can close this issue

sanmaym commented 5 months ago

@maxi-cit thank you so much