Skip to content

fix(deploy): Replace the managed certificate before deleting it - #7

Merged
dcramer merged 1 commit into
mainfrom
fix/managed-cert-replace
Oct 10, 2026
Merged

dcramer merged 1 commit into
mainfrom
fix/managed-cert-replace

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

When domain changes, Terraform has to replace the Google-managed certificate. With the fixed name roach, it tried to delete the old certificate first, and GCP refused because the SSL proxy still used it (resourceInUseByAnotherResource).

Now the certificate name has a random suffix that changes only when the domain changes, and create_before_destroy is set. Terraform creates the new certificate, moves the SSL proxy to it, and then deletes the old one.

The new certificate stays PROVISIONING until DNS for the new domain points at the load balancer IP.

via David Cramer.

--

View Junior Session [Sentry]

A domain change replaced the certificate in place, and GCP refused to
delete it while the SSL proxy still used it. Give each certificate a
unique name and create the new one first.

Co-Authored-By: David Cramer <david@sentry.io>
@dcramer
dcramer merged commit ce8c340 into main Oct 10, 2026
15 checks passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c2e5056. Configure here.

Comment thread deploy/gcp/main.tf

resource "google_compute_managed_ssl_certificate" "roach" {
name = "roach"
name = "roach-${random_id.certificate.hex}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate replaced without domain change

High Severity

A new random_id is interpolated into the certificate name, so the next apply replaces the live roach certificate even when var.domain is unchanged. Terraform then points the SSL proxy at the still-PROVISIONING cert and deletes the active one, taking HTTPS down until Google finishes issuing it.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c2e5056. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant