4

Is there a way to rename a subnet in gcp? either in console or with terraform.

I rather not drop and recreate the subnet as there are other resources using the subnet.

According to Google docs, you can't change the subnet name once it is created.

Example:

Change subnet name = sn-env-north-01

to this = sn-dev-north-01

thanks.

Stryker
  • 5,732
  • 1
  • 57
  • 70
  • Perhaps a way around this is to: get all dependencies of the current subnet, drop the subnet and recreate a new subnet and link all the resources back to the new subnet. Is there a script that can do this? – Stryker Sep 18 '20 at 13:53

1 Answers1

2

Actually, you've already answered your question - it's not possible.

Accordingly to the documentation Using VPC networks section Working with subnets:

You cannot change the name or region of a subnet after you have created it. However, you can delete a subnet and replace it, as long as no resources are using it.

You can try to change this behaviour by filling a feature request at Google Public Issue Tracker.

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29