Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
34 changes: 30 additions & 4 deletions docs/data-sources/object_storage_bucket_policy_document.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,42 @@ description: |-
## Example Usage

```terraform
terraform {
required_providers {
coreweave = {
source = "coreweave/coreweave"
}
}
}

variable "bucket_name" {
type = string
description = "Name of the bucket to allow access to."
}

variable "org_id" {
type = string
description = "CoreWeave organization ID to match in the bucket policy condition."
}

data "coreweave_object_storage_bucket_policy_document" "default" {
version = "2012-10-17"
statement {
sid = "allow-all"
effect = "Allow"
action = ["s3:*"]
resource = ["arn:aws:s3:::*"]
sid = "AllowAllInOrg"
effect = "Allow"
action = ["s3:*"]
resource = [
"arn:aws:s3:::${var.bucket_name}",
"arn:aws:s3:::${var.bucket_name}/*",
]
principal = {
"CW" : ["*"]
}
condition = {
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}
}
```
Expand Down
50 changes: 41 additions & 9 deletions docs/resources/object_storage_bucket_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,39 @@ description: |-
```terraform
## Example using jsonencode to pass a raw JSON string to the policy attribute

terraform {
required_providers {
coreweave = {
source = "coreweave/coreweave"
}
}
}

variable "org_id" {
type = string
description = "CoreWeave organization ID to match in the bucket policy condition."
}

locals {
bucket_policy = {
Version = "2012-10-17"
Statement = [
{
Sid = "allow-all"
Sid = "AllowAllInOrg"
Effect = "Allow"
Principal = {
"CW" : "*"
"CW" : ["*"]
}
Action = ["s3:*"]
Resource = [
"arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}",
"arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}/*",
]
Condition = {
"StringEquals" = {
"cw:PrincipalOrgID" = [var.org_id]
}
}
Action = ["s3:*"]
Resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}"]
},
]
}
Expand All @@ -52,17 +73,25 @@ resource "coreweave_object_storage_bucket" "doc" {
data "coreweave_object_storage_bucket_policy_document" "doc" {
version = "2012-10-17"
statement {
sid = "allow-all"
effect = "Allow"
action = ["s3:*"]
resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}"]
sid = "AllowAllInOrg"
effect = "Allow"
action = ["s3:*"]
resource = [
"arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}",
"arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}/*",
]
principal = {
"CW" : ["*"]
}
condition = {
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}

statement {
sid = "DenyIfPrefixEquals"
sid = "DenyIfPrefixNotEquals"
effect = "Deny"
action = ["s3:ListBucket"]
resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}"]
Expand All @@ -73,6 +102,9 @@ data "coreweave_object_storage_bucket_policy_document" "doc" {
"StringNotEquals" : {
"s3:prefix" : "projects"
}
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
terraform {
required_providers {
coreweave = {
source = "coreweave/coreweave"
}
}
}

variable "bucket_name" {
type = string
description = "Name of the bucket to allow access to."
}

variable "org_id" {
type = string
description = "CoreWeave organization ID to match in the bucket policy condition."
}

data "coreweave_object_storage_bucket_policy_document" "default" {
version = "2012-10-17"
statement {
sid = "allow-all"
effect = "Allow"
action = ["s3:*"]
resource = ["arn:aws:s3:::*"]
sid = "AllowAllInOrg"
effect = "Allow"
action = ["s3:*"]
resource = [
"arn:aws:s3:::${var.bucket_name}",
"arn:aws:s3:::${var.bucket_name}/*",
]
principal = {
"CW" : ["*"]
}
condition = {
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
## Example using jsonencode to pass a raw JSON string to the policy attribute

terraform {
required_providers {
coreweave = {
source = "coreweave/coreweave"
}
}
}

variable "org_id" {
type = string
description = "CoreWeave organization ID to match in the bucket policy condition."
}

locals {
bucket_policy = {
Version = "2012-10-17"
Statement = [
{
Sid = "allow-all"
Sid = "AllowAllInOrg"
Effect = "Allow"
Principal = {
"CW" : "*"
"CW" : ["*"]
}
Action = ["s3:*"]
Resource = [
"arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}",
"arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}/*",
]
Condition = {
"StringEquals" = {
"cw:PrincipalOrgID" = [var.org_id]
}
}
Action = ["s3:*"]
Resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.raw.name}"]
},
]
}
Expand All @@ -37,17 +58,25 @@ resource "coreweave_object_storage_bucket" "doc" {
data "coreweave_object_storage_bucket_policy_document" "doc" {
version = "2012-10-17"
statement {
sid = "allow-all"
effect = "Allow"
action = ["s3:*"]
resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}"]
sid = "AllowAllInOrg"
effect = "Allow"
action = ["s3:*"]
resource = [
"arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}",
"arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}/*",
]
principal = {
"CW" : ["*"]
}
condition = {
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}

statement {
sid = "DenyIfPrefixEquals"
sid = "DenyIfPrefixNotEquals"
effect = "Deny"
action = ["s3:ListBucket"]
resource = ["arn:aws:s3:::${coreweave_object_storage_bucket.doc.name}"]
Expand All @@ -58,6 +87,9 @@ data "coreweave_object_storage_bucket_policy_document" "doc" {
"StringNotEquals" : {
"s3:prefix" : "projects"
}
"StringEquals" : {
"cw:PrincipalOrgID" : var.org_id
}
}
}
}
Expand Down
Loading