diff --git a/5d1a38e8-e15a-450e-903c-562255e51faf/backend.tf b/5d1a38e8-e15a-450e-903c-562255e51faf/backend.tf new file mode 100644 index 0000000..c06155e --- /dev/null +++ b/5d1a38e8-e15a-450e-903c-562255e51faf/backend.tf @@ -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 + } +} \ No newline at end of file diff --git a/5d1a38e8-e15a-450e-903c-562255e51faf/main.tf b/5d1a38e8-e15a-450e-903c-562255e51faf/main.tf new file mode 100644 index 0000000..54551e9 --- /dev/null +++ b/5d1a38e8-e15a-450e-903c-562255e51faf/main.tf @@ -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 +} \ No newline at end of file diff --git a/5d1a38e8-e15a-450e-903c-562255e51faf/variables.tf b/5d1a38e8-e15a-450e-903c-562255e51faf/variables.tf new file mode 100644 index 0000000..60129d6 --- /dev/null +++ b/5d1a38e8-e15a-450e-903c-562255e51faf/variables.tf @@ -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 +} \ No newline at end of file