In this post, we’ll see how we can prevent a resource, conditionally created by Terraform from getting deleted. Step 1: Create 2 files named main.tf and variables.tf with following content: main.tf resource "aws_s3_bucket" "bucket1" {
bucket = "test-bucket-19892"
count = var.s3 ? 1 : 0
lifecycle {
prevent_destroy = true …