Skip to content

Commit

Permalink
Merge pull request #169 from dandi/embargoed-object-tags
Browse files Browse the repository at this point in the history
Add embargoed tags bucket policy
  • Loading branch information
jjnesbitt authored Apr 3, 2024
2 parents 5257f5c + ce5cbf8 commit 64eaf18
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions terraform/modules/dandiset_bucket/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,42 @@ data "aws_iam_policy_document" "dandiset_bucket_owner" {
}
}

resource "aws_s3_bucket_policy" "dandiset_embargoed_objects" {
count = var.public ? 1 : 0
provider = aws
bucket = aws_s3_bucket.dandiset_bucket.id
policy = data.aws_iam_policy_document.dandiset_embargoed_objects[0].json
}

data "aws_iam_policy_document" "dandiset_embargoed_objects" {
count = var.public ? 1 : 0
version = "2008-10-17"

statement {
effect = "Deny"
principals {
identifiers = ["*"]
type = "*"
}
actions = [
"s3:*",
]
resources = [
"${aws_s3_bucket.dandiset_bucket.arn}/*",
]
condition {
test = "StringEquals"
variable = "s3:ExistingObjectTag/embargoed"
values = ["true"]
}
condition {
test = "ArnNotEquals"
variable = "aws:PrincipalArn"
values = [var.heroku_user.arn]
}
}
}

resource "aws_s3_bucket_policy" "dandiset_bucket_policy" {
provider = aws

Expand Down

0 comments on commit 64eaf18

Please sign in to comment.