Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a storage bucket in GCP using Terraform #10135

Closed
ckin1 opened this issue Sep 22, 2021 · 2 comments
Closed

Deleting a storage bucket in GCP using Terraform #10135

ckin1 opened this issue Sep 22, 2021 · 2 comments
Labels

Comments

@ckin1
Copy link

ckin1 commented Sep 22, 2021

There is a storage bucket that was created manually through the GCS console in our GCP project. We need to delete this bucket and do not have permission to do this manually (manual permissions are not given within our company). We need to know how we can go about deleting this bucket. We thought we could use Terraform to do this, however our documentation says that you need to use the Gitlab pipeline that was used to create the bucket to delete it by executing the "destroy" part of the pipeline. Unfortunately, a pipeline is not what was used to create that bucket, so there's no option to "destroy" it. We tried using the following terraform code, but it is not working:

resource "google_storage_bucket" "gcs-bucket-cah" {
name = "gcp_ea_test"
location = "US-EAST4"
storage_class = "REGIONAL"

force_destroy = false
}

When I run this, I get the following error:

module.pipeline.google_storage_bucket.gcs-bucket-cah: Creating...
Error: googleapi: Error 409: Sorry, that name is not available. Please try a different one., conflict
on ../modules/setup/main.tf line 14, in resource "google_storage_bucket" "gcs-bucket-cah":
14: resource "google_storage_bucket" "gcs-bucket-cah" {
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

Does anyone know if it is possible to delete a GCP storage bucket if a pipeline was not used to create it?

@ckin1 ckin1 added the bug label Sep 22, 2021
@rileykarson
Copy link
Collaborator

You need to be able to run the Terraform binary against your state file manually, which may be possible or not dependent on your company processes, but this is what terraform import does: https://www.terraform.io/docs/cli/import/index.html

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants