Skip to content

Commit

Permalink
refactor for aws provider v4
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed May 7, 2022
1 parent 9480446 commit f6aac36
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
4 changes: 4 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ No modules.
| [aws_iam_role.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_s3_bucket.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
| [aws_s3_bucket_acl.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |
| [aws_s3_bucket_ownership_controls.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
| [aws_s3_bucket_public_access_block.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
| [aws_s3_bucket_server_side_encryption_configuration.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
| [aws_s3_bucket_versioning.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |
| [aws_sns_topic.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
| [aws_sns_topic_policy.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_policy) | resource |
| [aws_sns_topic_subscription.config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription) | resource |
Expand Down
50 changes: 36 additions & 14 deletions config/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@
#---
resource "aws_s3_bucket" "config" {
bucket = local.bucket_name
acl = "private"

# uses aws/kms key so log delivery works properly
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}

versioning {
enabled = false
}
# acl = "private"

lifecycle {
prevent_destroy = true
Expand Down Expand Up @@ -46,3 +33,38 @@ resource "aws_s3_bucket_public_access_block" "config" {
restrict_public_buckets = true
}


resource "aws_s3_bucket_ownership_controls" "config" {
bucket = aws_s3_bucket.config.id
rule {
object_ownership = "BucketOwnerEnforced"
}
}

resource "aws_s3_bucket_acl" "config" {
count = 0
bucket = aws_s3_bucket.config.id
acl = "private"
}

## resource "aws_s3_bucket_logging" "config" {
## bucket = aws_s3_bucket.config.id
## target_bucket = var.access_log_bucket
## target_prefix = format("%s/%s/", var.access_log_bucket_prefix, local.bucket_name)
## }

resource "aws_s3_bucket_server_side_encryption_configuration" "config" {
bucket = aws_s3_bucket.config.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}

resource "aws_s3_bucket_versioning" "config" {
bucket = aws_s3_bucket.config.id
versioning_configuration {
status = "Disabled"
}
}

0 comments on commit f6aac36

Please sign in to comment.