Skip to content
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
84 changes: 83 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,96 @@ resource "aws_s3_bucket" "data" {
# bucket does not have versioning
bucket = "${local.resource_prefix.value}-data"
region = "us-west-2"
acl = "public-read"
acl = "private"
force_destroy = true
tags = {
Name = "${local.resource_prefix.value}-data"
Environment = local.resource_prefix.value
}
}


resource "aws_s3_bucket_server_side_encryption_configuration" "data" {
bucket = aws_s3_bucket.data.bucket

rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}



resource "aws_s3_bucket_versioning" "data" {
bucket = aws_s3_bucket.data.id
versioning_configuration {
status = "Enabled"
}
}

resource "aws_s3_bucket" "data_destination" {
# checkov:skip=CKV_AWS_144:the resource is auto generated to be a destination for replication
bucket = aws_s3_bucket.data.id
versioning_configuration {
status = "Enabled"
}
}

resource "aws_iam_role" "data_replication" {
name = "aws-iam-role"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "s3.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}

resource "aws_s3_bucket_replication_configuration" "data" {
depends_on = [aws_s3_bucket_versioning.data]
role = aws_iam_role.data_replication.arn
bucket = aws_s3_bucket.data.id
rule {
id = "foobar"
status = "Enabled"
destination {
bucket = aws_s3_bucket.data_destination.arn
storage_class = "STANDARD"
}
}
}


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

versioning_configuration {
status = "Enabled"
}
}


resource "aws_s3_bucket" "data_log_bucket" {
bucket = "data-log-bucket"
}

resource "aws_s3_bucket_logging" "data" {
bucket = aws_s3_bucket.data.id

target_bucket = aws_s3_bucket.data_log_bucket.id
target_prefix = "log/"
}

resource "aws_s3_bucket_object" "data_object" {
bucket = aws_s3_bucket.data.id
region = "us-west-2"
Expand Down