Skip to content

Commit 8dd901a

Browse files
fix: add create_before_destroy to trust bundle GCS object
Without a lifecycle block, a content change causes Terraform to destroy the old object before creating the new one. If the apply is interrupted between destroy and create, the bucket is left empty with no trust bundle — breaking CA trust for runner and environment VMs until the next successful apply. Adding create_before_destroy ensures the new object is written before the old one is removed, eliminating the gap. Co-authored-by: Ona <no-reply@ona.com>
1 parent 59066c3 commit 8dd901a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

storage.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ locals {
264264
has_certificates = var.ca_certificate != null || (var.certificate_secret_id != "" && var.certificate_secret_read)
265265
}
266266

267-
# Upload combined trust bundle certificate to GCS bucket
267+
# Upload combined trust bundle certificate to GCS bucket.
268+
# create_before_destroy ensures the new object is written before the old
269+
# one is removed, preventing a gap if terraform apply is interrupted.
268270
resource "google_storage_bucket_object" "trust_bundle" {
269271
count = local.has_certificates ? 1 : 0
270272

@@ -284,6 +286,10 @@ resource "google_storage_bucket_object" "trust_bundle" {
284286
has_ca_cert = var.ca_certificate != null ? "true" : "false"
285287
has_secret_cert = var.certificate_secret_id != "" && var.certificate_secret_read ? "true" : "false"
286288
}
289+
290+
lifecycle {
291+
create_before_destroy = true
292+
}
287293
}
288294

289295
# Upload Docker config.json to GCS bucket if provided

0 commit comments

Comments
 (0)