Skip to content

Commit

Permalink
adds s3-bucket stack
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Nov 11, 2024
1 parent b24df34 commit 0997a75
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module "clickhouse_backup_bucket" {
source = "./modules/s3-bucket"

bucket_name = "clickhouse-backup"
}
17 changes: 17 additions & 0 deletions modules/s3-bucket/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "aws_s3_bucket" "bucket" {
bucket = var.bucket_name

tags = merge(
var.tags,
{
Name = var.bucket_name
}
)
}

resource "aws_s3_bucket_versioning" "versioning" {
bucket = aws_s3_bucket.bucket.id
versioning_configuration {
status = var.enable_versioning ? "Enabled" : "Suspended"
}
}
9 changes: 9 additions & 0 deletions modules/s3-bucket/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "bucket_name" {
description = "Name of the created S3 bucket"
value = aws_s3_bucket.bucket.id
}

output "bucket_arn" {
description = "ARN of the created S3 bucket"
value = aws_s3_bucket.bucket.arn
}
16 changes: 16 additions & 0 deletions modules/s3-bucket/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
variable "bucket_name" {
description = "Name of the S3 bucket to create"
type = string
}

variable "tags" {
description = "Tags to apply to the S3 bucket"
type = map(string)
default = {}
}

variable "enable_versioning" {
description = "Enable versioning on the bucket"
type = bool
default = true
}

0 comments on commit 0997a75

Please sign in to comment.