From 3099b008bf99d362af89063755e4f3d435309fec Mon Sep 17 00:00:00 2001 From: Dmitrii Unterov <du228@cam.ac.uk> Date: Mon, 16 Sep 2024 15:41:27 +0100 Subject: [PATCH] chore: add known-issues.md file --- docs/known-issues.md | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/known-issues.md diff --git a/docs/known-issues.md b/docs/known-issues.md new file mode 100644 index 0000000..e523a20 --- /dev/null +++ b/docs/known-issues.md @@ -0,0 +1,52 @@ +# Known issues + +## Manual Deletion Required for Static IP Address + +This module has `prevent_deletion` attribute enabled for `google_compute_address.static_ip` +resource. This attribute is used to prevent accidental deletion of important resources. +It was done on purpose, as it is not expected that static IPs to be regularly removed +and recreated, as it's likely that they will be used within firewall, DNS records and so on. +Terraform will display error trying to destroy the resource: + +```sh +│ Error: Instance cannot be destroyed +│ +│ on .terraform/modules/webapp/static_egress_ip.tf line 40: +│ 40: resource "google_compute_address" "static_ip" { +│ +│ Resource module.webapp.google_compute_address.static_ip[0] has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid +│ this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag. +``` + +However, sometimes it needs to be deleted. If a resource is created with `prevent_deletion`, +Terraform will block any attempt to delete this resource through Terraform commands. +As a result, if you need to remove such a resource from your Terraform configuration, +you must manually delete the resource outside of Terraform before running `terraform apply` again. + +The steps below shows how it can be achieved. + +## Steps to Resolve + +First, delete the resources that use the IP address. In common case it is Cloud Router with the +default name `webapp-ip-router`. If not sure, check the list of routers using `gcloud` command: + +```sh +gcloud compute routers list --project $PROJECT_ID + +NAME REGION NETWORK +webapp-ip-router europe-west2 default +``` + +Delete the Cloud Router: + +```sh +gcloud compute routers delete webapp-ip-router --project $PROJECT_ID --region $REGION +``` + +Now the IP address can be deleted: + +```sh +gcloud compute addresses delete webapp-static-ip --region $REGION --project $PROJECT_ID +``` + +That's it. Now Terraform commands will work without errors. -- GitLab