Skip to content
Open
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
8 changes: 8 additions & 0 deletions 5d1a38e8-e15a-450e-903c-562255e51faf/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
backend "s3" {
bucket = "opszero-b63fbc68-f984-455e-8e8f-b9ac4fb3e1e5"
key = "b63fbc68-f984-455e-8e8f-b9ac4fb3e1e5/5d1a38e8-e15a-450e-903c-562255e51faf/terraform.tfstate"
region = "us-east-1"
encrypt = true
}
}
37 changes: 37 additions & 0 deletions 5d1a38e8-e15a-450e-903c-562255e51faf/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
provider "aws" {
region = var.region
}

resource "aws_s3_bucket" "this" {
bucket = var.bucket_name
force_destroy = var.force_destroy

tags = var.tags
}

resource "aws_s3_bucket_versioning" "this" {
bucket = aws_s3_bucket.this.id

versioning_configuration {
status = var.enable_versioning ? "Enabled" : "Disabled"
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
bucket = aws_s3_bucket.this.id

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.this.id

block_public_acls = var.block_public_access
block_public_policy = var.block_public_access
ignore_public_acls = var.block_public_access
restrict_public_buckets = var.block_public_access
}
34 changes: 34 additions & 0 deletions 5d1a38e8-e15a-450e-903c-562255e51faf/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
variable "region" {
description = "AWS region where the S3 bucket will be created"
type = string
default = "us-east-1"
}

variable "bucket_name" {
description = "Name of the S3 bucket"
type = string
}

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

variable "enable_versioning" {
description = "Enable versioning for the S3 bucket"
type = bool
default = false
}

variable "block_public_access" {
description = "Block public access to the S3 bucket"
type = bool
default = true
}

variable "force_destroy" {
description = "Allow the bucket to be destroyed even if it contains objects"
type = bool
default = false
}