Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Fix versioning for S3 bucket #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions modules/vault-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ resource "aws_s3_bucket" "vault_storage" {
var.s3_bucket_tags,
)

versioning {
enabled = var.enable_s3_bucket_versioning
}

# aws_launch_configuration.launch_configuration in this module sets create_before_destroy to true, which means
# everything it depends on, including this resource, must set it as well, or you'll get cyclic dependency errors
# when you try to do a terraform destroy.
Expand All @@ -292,6 +288,14 @@ resource "aws_s3_bucket" "vault_storage" {
}
}

resource "aws_s3_bucket_versioning" "vault_storage" {
count = var.enable_s3_backend ? 1 : 0
bucket = aws_s3_bucket.vault_storage[count.index].id
versioning_configuration {
status = var.enable_s3_bucket_versioning
}
}

resource "aws_iam_role_policy" "vault_s3" {
count = var.enable_s3_backend ? 1 : 0
name = "vault_s3"
Expand Down