selkies-project / selkies-operator

K8s operator for per-user stateful workloads
https://selkies.io
Apache License 2.0
72 stars 13 forks source link

Error creating Topic: googleapi: Error 409: Resource already exists in the project (resource=gcr) #54

Closed videlanicolas closed 2 years ago

videlanicolas commented 2 years ago

While setting up a new GCP project I got the following error:

Step #4 - "deploy-infra-base": Step #1 - "terraform-apply": Error: Error creating Topic: googleapi: Error 409: Resource already exists in the project (resource=gcr).
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":   on gcr.tf line 17, in resource "google_pubsub_topic" "gcr":
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":   17: resource "google_pubsub_topic" "gcr" {
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":
Step #4 - "deploy-infra-base": Step #1 - "terraform-apply":

Not sure why Terraform complains about the resource already existing? Shouldn't Terraform make sure the configured state is reflected in the GCP project?

videlanicolas commented 2 years ago

This is interesting: https://registry.terraform.io/modules/sysdiglabs/secure-for-cloud/google/latest#q-getting-error-creating-topic-googleapi-error-409-resource-already-exists-in-the-project-resourcegcr

This error happens due to a GCP limitation where only a single topic named gcr can exist. This name is [gcp hardcoded](https://cloud.google.com/container-registry/docs/configuring-notifications#create_a_topic) and is the one we used to detect images pushed to the registry.

I'll apply the workaround and try again.

videlanicolas commented 2 years ago

Seems like I had to manually import the config in place as specified by the link above.