Skip to content

Commit

Permalink
update bucket policy for a deployment_user
Browse files Browse the repository at this point in the history
  • Loading branch information
fillup committed Jan 2, 2020
1 parent dc90619 commit 8df1788
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
14 changes: 13 additions & 1 deletion bucket-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::${bucket_name}/public/*"
},
{
"Sid": "PutWebsite",
"Effect": "Allow",
"Principal": {
"AWS": ["${deployment_user_arn}"]
},
"Action": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::${bucket_name}/public/*"
}
]
}
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ data "template_file" "bucket_policy" {
template = "${file("${path.module}/bucket-policy.json")}"

vars {
bucket_name = "${var.bucket_name}"
bucket_name = "${var.bucket_name}"
deployment_user_arn = "${var.deployment_user_arn}"
}
}

Expand Down
5 changes: 5 additions & 0 deletions vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ variable "viewer_protocol_policy" {
type = "string"
default = "redirect-to-https"
}

variable "deployment_user_arn" {
description = "ARN for user who is able to put objects into S3 bucket"
type = "string"
}

0 comments on commit 8df1788

Please sign in to comment.