Hey,
I have a situation where a particular set of resources provided by a module are not required in our dev environment - I was wondering if theres an easy way to conditionally create / not create a module - for instance, I want the existing resources to be unaffected but not create any when the stage is dev - this works fine for dev - but when I try and run prod plans, it wants to delete and re create the modules resources due to the count:
like so
# module.gcp-networks[0].google_compute_network.vpc_network will be created
### GCP Networks ###
####################
module "gcp-networks" {
count = var.stage == "prod" ? 1 : 0
source = "../../../modules/gcp-networks"
project_id = module.gcp-project.project_id
gcp_region = var.gcp_region
vpc_subnetwork_cidr_range = var.vpc_subnetwork_cidr_range
cluster_secondary_range_cidr = var.cluster_secondary_range_cidr
cluster_secondary_range_name = var.cluster_secondary_range_name
services_secondary_range_cidr = var.services_secondary_range_cidr
services_secondary_range_name = var.services_secondary_range_name
create_ingress_ip = false
vpc_flow_log_sampling = var.vpc_flow_log_sampling
}
Same approach works with individual resources so I was hoping there would be something similar for modules.
Is there an easier way to tackle this situation?
Any help would be greatly appreciated.
Thanks!