Skip to content

Commit 34d948c

Browse files
author
Steven Nemetz
committed
Setup standand naming of log bucket
1 parent 43e867a commit 34d948c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

main.tf

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ module "label" {
4141
tags = "${var.tags}"
4242
}
4343

44+
module "log_bucket" {
45+
source = "devops-workflow/label/local"
46+
version = "0.1.0"
47+
organization = "${var.organization}"
48+
name = "${var.log_bucket_name}"
49+
namespace-env = true
50+
namespace-org = true
51+
environment = "${var.environment}"
52+
delimiter = "${var.delimiter}"
53+
attributes = "${var.attributes}"
54+
tags = "${var.tags}"
55+
}
56+
4457
/*
4558
# Retrieve SSL certificate if creating SSL LB
4659
Support list for multiple certs ?? First pass, only 1 LB, 1 DNS, 1 cert
@@ -73,7 +86,7 @@ resource "aws_lb" "application" {
7386
subnets = ["${var.subnets}"]
7487
tags = "${module.label.tags}"
7588
access_logs {
76-
bucket = "${var.log_bucket_name}"
89+
bucket = "${module.log_bucket.id}" # ? Cannot be empty ?
7790
prefix = "${var.log_location_prefix}"
7891
enabled = "${module.enable_logging.value}"
7992
}
@@ -130,7 +143,7 @@ data "aws_iam_policy_document" "bucket_policy" {
130143
"s3:PutObject",
131144
]
132145
resources = [
133-
"arn:aws:s3:::${var.log_bucket_name}/${var.log_location_prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
146+
"arn:aws:s3:::${module.log_bucket.id}/${var.log_location_prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
134147
]
135148
principals {
136149
type = "AWS"
@@ -145,7 +158,7 @@ resource "aws_s3_bucket" "log_bucket" {
145158
module.enable_logging.value &&
146159
var.type == "application" &&
147160
var.create_log_bucket ? 1 : 0}"
148-
bucket = "${var.log_bucket_name}"
161+
bucket = "${module.log_bucket.id}"
149162
#acl
150163
policy = "${var.bucket_policy == "" ? data.aws_iam_policy_document.bucket_policy.json : var.bucket_policy}"
151164
force_destroy = "${var.force_destroy_log_bucket}"

0 commit comments

Comments
 (0)