Skip to content

Commit

Permalink
Merge pull request #22 from Snowflake-Labs/fix-s3-bucket-with-acl-usage
Browse files Browse the repository at this point in the history
Fix s3 bucket acl usage.
  • Loading branch information
sfc-gh-pkommini authored May 25, 2023
2 parents 2e3ae49 + f4531ce commit 75d998e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "storage_integration" {

# Snowflake
snowflake_integration_user_roles = var.snowflake_integration_user_roles
bucket_object_ownership_settings = var.bucket_object_ownership_settings

providers = {
snowflake.storage_integration_role = snowflake.storage_integration_role
Expand Down
6 changes: 6 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ variable "arn_format" {
default = "aws"
}

variable "bucket_object_ownership_settings" {
type = string
description = "The settings that will impact ACLs and ownership of objects within the bucket."
default = "BucketOwnerEnforced"
}

data "aws_caller_identity" "current" {}

locals {
Expand Down
10 changes: 10 additions & 0 deletions s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ resource "aws_s3_bucket" "geff_bucket" {
bucket = local.s3_bucket_name
}

resource "aws_s3_bucket_ownership_controls" "geff_bucket_ownership_controls" {
bucket = aws_s3_bucket.geff_bucket.id

rule {
object_ownership = var.bucket_object_ownership_settings
}
}

resource "aws_s3_bucket_acl" "geff_bucket_acl" {
bucket = aws_s3_bucket.geff_bucket.id
acl = "private"

depends_on = [aws_s3_bucket_ownership_controls.geff_bucket_ownership_controls]
}

resource "aws_s3_object" "geff_meta_folder" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ variable "arn_format" {
default = "aws"
}

variable "bucket_object_ownership_settings" {
type = string
description = "The settings that will impact ACLs and ownership of objects within the bucket."
default = "BucketOwnerEnforced"
}

data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
data "aws_partition" "current" {}
Expand Down

0 comments on commit 75d998e

Please sign in to comment.