Skip to content

Add ephemeral to GCP storage enabling resources deletion #65

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

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deployment/modules/gcp/conformance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module "storage" {
project_id = var.project_id
base_name = var.base_name
location = var.location
ephemeral = true
}

module "secretmanager" {
Expand Down
6 changes: 6 additions & 0 deletions deployment/modules/gcp/storage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ resource "google_spanner_instance" "log_spanner" {
config = "regional-${var.location}"
display_name = var.base_name
processing_units = 100

force_destroy = var.ephemeral
}

resource "google_spanner_database" "log_db" {
Expand All @@ -54,6 +56,8 @@ resource "google_spanner_database" "log_db" {
"CREATE TABLE Seq (id INT64 NOT NULL, seq INT64 NOT NULL, v BYTES(MAX),) PRIMARY KEY (id, seq)",
"CREATE TABLE IntCoord (id INT64 NOT NULL, seq INT64 NOT NULL,) PRIMARY KEY (id)",
]

deletion_protection = !var.ephemeral
}

resource "google_spanner_database" "dedup_db" {
Expand All @@ -62,4 +66,6 @@ resource "google_spanner_database" "dedup_db" {
ddl = [
"CREATE TABLE IDSeq (id INT64 NOT NULL, h BYTES(MAX) NOT NULL, idx INT64 NOT NULL, timestamp INT64 NOT NULL,) PRIMARY KEY (id, h)",
]

deletion_protection = !var.ephemeral
}
5 changes: 5 additions & 0 deletions deployment/modules/gcp/storage/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ variable "location" {
description = "Location in which to create resources"
type = string
}

variable "ephemeral" {
description = "Set to true if this is a throwaway/temporary log instance. Will set attributes on created resources to allow them to be disabled/deleted more easily."
type = bool
}
1 change: 1 addition & 0 deletions deployment/modules/gcp/test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module "storage" {
project_id = var.project_id
base_name = var.base_name
location = var.location
ephemeral = false
}

module "secretmanager" {
Expand Down
Loading