From 6755a7e6a229c20b2982dbe44de26338f10ab036 Mon Sep 17 00:00:00 2001 From: Evandro Myller Date: Mon, 19 Apr 2021 17:05:06 -0300 Subject: [PATCH 1/3] Allow creating a policy for an existing S3 bucket (#152) --- main.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 9e8d69eb..234a8184 100644 --- a/main.tf +++ b/main.tf @@ -78,7 +78,10 @@ data "aws_iam_policy_document" "origin_website" { resource "aws_s3_bucket_policy" "default" { count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0 - bucket = join("", aws_s3_bucket.origin.*.bucket) + bucket = join("", local.using_existing_origin + ? data.aws_s3_bucket.selected.*.bucket # Existing origin S3 bucket + : aws_s3_bucket.origin.*.bucket # Origin S3 bucket this module manages + ) policy = local.iam_policy_document } From 2f24a73bb300f8356d6aea7e0714939f6d379fd6 Mon Sep 17 00:00:00 2001 From: Evandro Myller Date: Mon, 19 Apr 2021 17:13:13 -0300 Subject: [PATCH 2/3] Fix formatting --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 234a8184..a1714feb 100644 --- a/main.tf +++ b/main.tf @@ -79,8 +79,8 @@ data "aws_iam_policy_document" "origin_website" { resource "aws_s3_bucket_policy" "default" { count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0 bucket = join("", local.using_existing_origin - ? data.aws_s3_bucket.selected.*.bucket # Existing origin S3 bucket - : aws_s3_bucket.origin.*.bucket # Origin S3 bucket this module manages + ? data.aws_s3_bucket.selected.*.bucket # Existing origin S3 bucket + : aws_s3_bucket.origin.*.bucket # Origin S3 bucket this module manages ) policy = local.iam_policy_document } From 97868a2bce94a6d5939e4681eae63b72daf4a80e Mon Sep 17 00:00:00 2001 From: Evandro Myller Date: Mon, 26 Apr 2021 20:12:56 -0300 Subject: [PATCH 3/3] Apply changes from auto-formatter --- README.md | 3 +-- main.tf | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 80c879c3..ec952074 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # terraform-aws-cloudfront-s3-cdn [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-cloudfront-s3-cdn?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d169121757962ff25679794) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg)](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) @@ -29,7 +30,6 @@ Terraform module to provision an AWS CloudFront CDN with an S3 origin. - --- This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. @@ -60,7 +60,6 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are - ## Security & Compliance [](https://bridgecrew.io/) Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance. diff --git a/main.tf b/main.tf index a1714feb..b9ccb686 100644 --- a/main.tf +++ b/main.tf @@ -77,7 +77,7 @@ data "aws_iam_policy_document" "origin_website" { } resource "aws_s3_bucket_policy" "default" { - count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0 + count = (module.this.enabled && (! local.using_existing_origin || var.override_origin_bucket_policy)) ? 1 : 0 bucket = join("", local.using_existing_origin ? data.aws_s3_bucket.selected.*.bucket # Existing origin S3 bucket : aws_s3_bucket.origin.*.bucket # Origin S3 bucket this module manages