From 29e1a7346ff8e38c59ab77f5c8f96b13da4e20ae Mon Sep 17 00:00:00 2001 From: Krystan Honour Date: Sat, 31 Oct 2020 01:25:15 +0000 Subject: [PATCH 1/2] Add code to allow specification of bucket. --- main.tf | 3 ++- variables.tf | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 0a9ce2e..73b4101 100644 --- a/main.tf +++ b/main.tf @@ -15,6 +15,7 @@ resource "aws_cloudfront_origin_access_identity" "default" { module "logs" { source = "git::https://github.com/cloudposse/terraform-aws-log-storage.git?ref=tags/0.14.0" + enabled = module.this.enabled && length(var.log_bucket_fqdn) == 0 attributes = compact(concat(module.this.attributes, ["origin", "logs"])) lifecycle_prefix = var.log_prefix standard_transition_days = var.log_standard_transition_days @@ -35,7 +36,7 @@ resource "aws_cloudfront_distribution" "default" { logging_config { include_cookies = var.log_include_cookies - bucket = module.logs.bucket_domain_name + bucket = length(var.log_bucket_fqdn) > 0 ? var.log_bucket_fqdn : module.logs.bucket_domain_name prefix = var.log_prefix } diff --git a/variables.tf b/variables.tf index e45b29d..4929f57 100644 --- a/variables.tf +++ b/variables.tf @@ -127,6 +127,12 @@ variable "log_prefix" { description = "Path of logs in S3 bucket" } +variable "log_bucket_fqdn" { + type = string + default = "" + description = "Optional fqdn of logging bucket, if not supplied a bucket will be generated." +} + variable "log_standard_transition_days" { type = number description = "Number of days to persist in the standard storage tier before moving to the glacier tier" From e6d0f5bcf53fd84c8581d7c6854060f7d8af92a2 Mon Sep 17 00:00:00 2001 From: Krystan Honour Date: Sat, 31 Oct 2020 02:15:52 +0000 Subject: [PATCH 2/2] added documentation --- README.md | 1 + docs/terraform.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 039a068..376ce46 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ Available targets: | id\_length\_limit | Limit `id` to this many characters.
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | | is\_ipv6\_enabled | State of CloudFront IPv6 | `bool` | `true` | no | | label\_order | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | +| log\_bucket\_fqdn | Optional fqdn of logging bucket, if not supplied a bucket will be generated. | `string` | `""` | no | | log\_expiration\_days | Number of days after which to expunge the objects | `number` | `90` | no | | log\_glacier\_transition\_days | Number of days after which to move the data to the glacier storage tier | `number` | `60` | no | | log\_include\_cookies | Include cookies in access logs | `bool` | `false` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 17e0082..a89d590 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -43,6 +43,7 @@ | id\_length\_limit | Limit `id` to this many characters.
Set to `0` for unlimited length.
Set to `null` for default, which is `0`.
Does not affect `id_full`. | `number` | `null` | no | | is\_ipv6\_enabled | State of CloudFront IPv6 | `bool` | `true` | no | | label\_order | The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no | +| log\_bucket\_fqdn | Optional fqdn of logging bucket, if not supplied a bucket will be generated. | `string` | `""` | no | | log\_expiration\_days | Number of days after which to expunge the objects | `number` | `90` | no | | log\_glacier\_transition\_days | Number of days after which to move the data to the glacier storage tier | `number` | `60` | no | | log\_include\_cookies | Include cookies in access logs | `bool` | `false` | no |