I cant get my head around the following problem: With Terraform I am creating different ressources in Google Cloud one of them is a GKE Cluster. Other ressources are deployments of infrastructure elements into this cluster like mongodb or gloo gateway. The cluster is a private cluster and I need to add certain networks which need access to this cluster so our applications work correctly. The problem is the IP I want to add only becomes available after the Cluster is deployed and the gloo gateway is running.
I talked to different AIs and GPTs for ages about this problem but the only solution they come up with is a) to update the authorized_networks with gcloud, which is not an option for me, or b) run a second google_container_cluster after the cluster is created or exists already. Which doesn't work as expected. I get the error message "object already exists" or something like this:
│ Error: googleapi: Error 400: At least one of ['node_version', 'image_type', 'updated_node_pool', 'locations', 'workload_metadata_config', 'upgrade_settings', 'kubelet_config', 'linux_node_config', 'tags', 'taints', 'labels', 'node_network_config', 'gcfs_config', 'gvnic', 'confidential_nodes', 'logging_config', 'fast_socket', 'resource_labels', 'accelerators', 'windows_node_config', 'machine_type', 'disk_type', 'disk_size_gb', 'storage_pools', 'containerd_config', 'resource_manager_tags', 'performance_monitoring_unit', 'queued_provisioning', 'max_run_duration', 'flex_start'] must be specified.
I cant get my head around what the correct approach would me. I want to modify the cluster with the authorized ips, when its already created and if it is a run from scratch I want to create it and than, maybe in a second run of the terraform module, I want to add the corresponding authorized_networks.
Any ideas how to achieve this?
Thanks in advance.