Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally create aws_s3_bucket_public_access_block #94

Merged
merged 6 commits into from
Aug 25, 2021
Merged
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ locals {
# Deprecate `replication_rules` in favor of `s3_replication_rules` to keep all the replication related
# inputs grouped under s3_replica[tion]
s3_replication_rules = var.replication_rules == null ? var.s3_replication_rules : var.replication_rules

public_access_block_enabled = var.block_public_acls || var.block_public_policy || var.ignore_public_acls || var.restrict_public_buckets
}

resource "aws_s3_bucket" "default" {
Expand Down Expand Up @@ -374,7 +376,7 @@ resource "aws_s3_bucket_policy" "default" {
# https://www.terraform.io/docs/providers/aws/r/s3_bucket_public_access_block.html
# for the nuances of the blocking options
resource "aws_s3_bucket_public_access_block" "default" {
count = local.enabled ? 1 : 0
count = module.this.enabled && local.public_access_block_enabled ? 1 : 0
bucket = join("", aws_s3_bucket.default.*.id)

block_public_acls = var.block_public_acls
Expand Down