Skip to content

Commit

Permalink
Prevent destruction of state infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Sep 26, 2024
1 parent 6c99c12 commit 73f5155
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions web/deploy/terraform/state/modules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ provider "aws" {
resource "aws_s3_bucket" "tf_state" {
bucket = "${var.bucket_name}-${var.environment}"

lifecycle {
create_before_destroy = true
}

tags = {
Name = "${var.bucket_name}-${var.environment}"
}
Expand All @@ -36,6 +40,10 @@ resource "aws_s3_bucket_lifecycle_configuration" "tf_state" {
days = 365
}
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_s3_bucket_versioning" "enabled" {
Expand All @@ -44,6 +52,10 @@ resource "aws_s3_bucket_versioning" "enabled" {
versioning_configuration {
status = "Enabled"
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
Expand All @@ -54,6 +66,10 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
sse_algorithm = "AES256"
}
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_dynamodb_table" "tf_locks" {
Expand All @@ -66,6 +82,10 @@ resource "aws_dynamodb_table" "tf_locks" {
type = "S"
}

lifecycle {
create_before_destroy = true
}

tags = {
Name = "${var.bucket_name}-${var.environment}"
}
Expand Down

0 comments on commit 73f5155

Please sign in to comment.