Skip to content

Commit

Permalink
Fix for s3 bucket acl & added custom prefix (databricks#95)
Browse files Browse the repository at this point in the history
* fix s3 bucket acl, add custom prefix

* added s3 acl fix for aws modules
  • Loading branch information
dleiva04 authored Oct 16, 2023
1 parent 5918099 commit d651fa5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions modules/aws-exfiltration-protection/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ resource "aws_s3_bucket_versioning" "versioning" {
}
}

resource "aws_s3_bucket_ownership_controls" "state" {
bucket = aws_s3_bucket.root_storage_bucket.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "acl" {
bucket = aws_s3_bucket.root_storage_bucket.id
acl = "private"
Expand Down
4 changes: 2 additions & 2 deletions modules/aws-workspace-basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ resource "random_string" "naming" {
}

locals {
prefix = "demo${random_string.naming.result}"
}
prefix = var.prefix != "" ? var.prefix : "demo${random_string.naming.result}"
}
7 changes: 7 additions & 0 deletions modules/aws-workspace-basic/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ resource "aws_s3_bucket_versioning" "versioning" {
}
}

resource "aws_s3_bucket_ownership_controls" "state" {
bucket = aws_s3_bucket.root_storage_bucket.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "acl" {
bucket = aws_s3_bucket.root_storage_bucket.id
acl = "private"
Expand Down
5 changes: 5 additions & 0 deletions modules/aws-workspace-basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ variable "cidr_block" {

variable "region" {
default = "eu-west-1"
}

variable "prefix" {
default = null
description = "Default value is demo"
}
7 changes: 7 additions & 0 deletions modules/aws-workspace-with-firewall/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ resource "aws_s3_bucket_policy" "root_bucket_policy" {
depends_on = [aws_s3_bucket_public_access_block.root_storage_bucket]
}

resource "aws_s3_bucket_ownership_controls" "state" {
bucket = aws_s3_bucket.root_storage_bucket.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_acl" "root_storage_bucket" {
bucket = aws_s3_bucket.root_storage_bucket.id
acl = "private"
Expand Down

0 comments on commit d651fa5

Please sign in to comment.