From c694cb3b35791cea32efb823658fa2abef921002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauricio=20S=C3=A1nchez?= Date: Mon, 30 Jul 2018 17:21:02 -0500 Subject: [PATCH] refactor(access_identity): Fix varaibles to enable access identity --- README.md | 2 +- data.tf | 4 ++-- main.tf | 2 +- variables.tf | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9269374..27bf2da 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ Terraform AWS S3 module ======================== -Create a AWS S3 bickets optimized for static web hosting +Create a AWS S3 buckets optimized for static web hosting diff --git a/data.tf b/data.tf index e00dfb2..abb7b82 100644 --- a/data.tf +++ b/data.tf @@ -1,5 +1,5 @@ data "aws_iam_policy_document" "access_identity" { - count = "${var.access_identity_arn != "" ? 1 : 0}" + count = "${var.access_identity ? 1 : 0}" statement { actions = ["s3:GetObject"] resources = ["arn:aws:s3:::$${bucket_name}$${origin_path}*"] @@ -22,7 +22,7 @@ data "aws_iam_policy_document" "access_identity" { } data "template_file" "access_identity" { - count = "${var.access_identity_arn != "" ? 1 : 0}" + count = "${var.access_identity ? 1 : 0}" template = "${data.aws_iam_policy_document.access_identity.json}" vars { diff --git a/main.tf b/main.tf index 2d9e12e..ebb7d3f 100644 --- a/main.tf +++ b/main.tf @@ -19,7 +19,7 @@ resource "aws_s3_bucket" "this" { } resource "aws_s3_bucket_policy" "access_identity" { - count = "${var.access_identity_arn != "" ? 1 : 0}" + count = "${var.access_identity ? 1 : 0}" bucket = "${aws_s3_bucket.this.id}" policy = "${data.template_file.access_identity.rendered}" } diff --git a/variables.tf b/variables.tf index c8ff281..f435b94 100644 --- a/variables.tf +++ b/variables.tf @@ -41,6 +41,10 @@ variable "access_identity_arn" { default = "" } +variable "access_identity" { + default = false +} + variable "read_permissions" { default = [ "s3:GetObject"