diff --git a/plugins/modules/gcp_compute_subnetwork.py b/plugins/modules/gcp_compute_subnetwork.py index 3fc743802..67beafbb6 100644 --- a/plugins/modules/gcp_compute_subnetwork.py +++ b/plugins/modules/gcp_compute_subnetwork.py @@ -318,6 +318,7 @@ import json import time + ################################################################################ # Main ################################################################################ @@ -353,7 +354,10 @@ def main(): if fetch: if state == 'present': - if is_different(module, fetch): + if module.params['network']['selfLink'] != fetch['network']: # found difference on same subnet within the same VPC network + module.fail_json(msg="Subnet already exists in a different VPC network: %s" % fetch['network']) + changed = False + elif is_different(module, fetch): update(module, self_link(module), kind, fetch) fetch = fetch_resource(module, self_link(module), kind) changed = True