Is there a way I can script an existing VPC and related subnets in GCP? I would like to script this out so that I can use gcloud CLI to recreate it.
I notice for some of the resources in GCP, there is a button at the bottom that outputs the equivalent REST API call. How do I use this to from the Gcloud CLI to recreate an existing VPC?
This would be very useful across the board but, to my knowledge, it's not possible to invert gcloud
commands to recreate the command that created existing resources.
You can determine the state of any GCP resource using the APIs and GET
ting resources but you'd need then to reframe these as gcloud
commands.
The equivalent REST and Cloud SDK commands presented in Console are very useful but these show you the gcloud
and API equivalents of Console behaviors; usually create commands.
I recall reading something recently with Terraform where it is able to recreate configs from deployed resources but I've not seen this done for gcloud