From 29630df9896af5d25073a23b597a9bfe24a32fa3 Mon Sep 17 00:00:00 2001 From: Dmitrii Unterov <du228@cam.ac.uk> Date: Tue, 17 Sep 2024 15:07:02 +0100 Subject: [PATCH] chore: add known-issues.md file --- docs/known-issues.md | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/docs/known-issues.md b/docs/known-issues.md index e523a20..61457b7 100644 --- a/docs/known-issues.md +++ b/docs/known-issues.md @@ -2,11 +2,14 @@ ## 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: +`prevent_deletion` attribute is enabled for the `google_compute_address.static_ip` resource. +This attribute is used to prevent accidental deletion of important resources. +It is generally not expected for static IP addresses to be deleted or recreated frequently, +as these are often referenced in other external configurations such as firewall rules and DNS +records. + +with `prevent_deletion` applied, Terraform will display error trying to destroy the resource: + ```sh │ Error: Instance cannot be destroyed @@ -20,15 +23,16 @@ Terraform will display error trying to destroy the resource: 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. +In some situations, it is necessary to delete static IP Address entries. In order to do this with +`prevent_deletion` enabled, you must first manually delete the resource via the console or `gcloud` +cli tool before running `terraform apply`. -The steps below shows how it can be achieved. +A full example of this is shown below. -## 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: +## Manually deleting a static IP address with `prevent_deletion` attribute + +1. Confirm the name of the Cloud Router using the `gcloud` command: ```sh gcloud compute routers list --project $PROJECT_ID @@ -37,16 +41,24 @@ NAME REGION NETWORK webapp-ip-router europe-west2 default ``` -Delete the Cloud Router: +Default name for the resource created within this module is `webapp-ip-router`. + +2. Delete the Cloud Router: ```sh gcloud compute routers delete webapp-ip-router --project $PROJECT_ID --region $REGION ``` -Now the IP address can be deleted: +3. Delete the IP address: ```sh gcloud compute addresses delete webapp-static-ip --region $REGION --project $PROJECT_ID ``` +4. Verify that the IP address is deleted: + +```sh +gcloud compute addresses list --project $PROJECT_ID +``` + That's it. Now Terraform commands will work without errors. -- GitLab