Skip to content

Commit

Permalink
fixes for website bucket deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaiplesa committed Apr 21, 2021
1 parent f70f215 commit 390cb9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 11 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ resource "aws_iam_policy" "s3" {
policy = join("", data.aws_iam_policy_document.s3.*.json)
}

data "aws_s3_bucket" "website" {
count = local.enabled ? 1 : 0
bucket = var.website_bucket_name
}

data "aws_iam_policy_document" "s3" {
count = local.enabled ? 1 : 0

Expand All @@ -136,12 +141,15 @@ data "aws_iam_policy_document" "s3" {
"s3:GetObjectVersion",
"s3:GetBucketVersioning",
"s3:PutObject",
"s3:PutObjectAcl",
]

resources = [
join("", aws_s3_bucket.default.*.arn),
"arn:aws:s3:::elasticbeanstalk*",
"${join("", aws_s3_bucket.default.*.arn)}/*",
"arn:aws:s3:::elasticbeanstalk*"
join("", aws_s3_bucket.default.*.arn),
"${join("", data.aws_s3_bucket.website.*.arn)}/*",
join("", data.aws_s3_bucket.website.*.arn)
]

effect = "Allow"
Expand Down Expand Up @@ -306,7 +314,7 @@ resource "aws_codepipeline" "default" {
configuration = {
BucketName = var.website_bucket_name
Extract = "true"
CannedACL = "public-read"
CannedACL = var.website_bucket_acl
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ variable "website_bucket_name" {
default = ""
description = "Name of the S3 bucket where the website will be deployed"
}

variable "website_bucket_acl" {
type = string
default = "public-read"
description = "Canned ACL of the S3 bucket objects that get served as a website, can be private if using CloudFront with OAI"
}

0 comments on commit 390cb9e

Please sign in to comment.