diff --git a/plugins/modules/gcp_compute_instance.py b/plugins/modules/gcp_compute_instance.py index 3c30338..f57b454 100644 --- a/plugins/modules/gcp_compute_instance.py +++ b/plugins/modules/gcp_compute_instance.py @@ -1237,8 +1237,22 @@ def update_fields(module, request, response): machine_type_update(module, request, response) if response.get('shieldedInstanceConfig') != request.get('shieldedInstanceConfig'): shielded_instance_config_update(module, request, response) + if response.get("tags") != request.get("tags"): + tag_fingerprint_update(module,request,response) + + +def tag_fingerprint_update(module, request, response): + auth = GcpSession(module, 'compute') + if not module.params.get('tags'): + module.params['tags'] = {} + module.params['tags']['fingerprint'] = response.get('tags', {}).get('fingerprint') + auth.post( + ''.join(["https://compute.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/instances/{name}/setTags"]).format(**module.params), + InstanceTags(module.params.get('tags', {}), module).to_request(), + ) + def label_fingerprint_update(module, request, response): auth = GcpSession(module, 'compute') auth.post(