From e1d2c421d07db5a613d8e3e61ce83b4d33542d27 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Tue, 22 Sep 2020 17:39:18 -0700 Subject: [PATCH 1/8] changing version string to allow for aws 3 --- README.md | 4 ++-- versions.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3653b24..298abf7 100644 --- a/README.md +++ b/README.md @@ -97,13 +97,13 @@ module "aws_logs" { | Name | Version | |------|---------| | terraform | ~> 0.12.0 | -| aws | ~> 2.70 | +| aws | >= 2.68, < 4.0 | ## Providers | Name | Version | |------|---------| -| aws | ~> 2.70 | +| aws | >= 2.68, < 4.0 | ## Inputs diff --git a/versions.tf b/versions.tf index d7ce6c1..3fb09b2 100644 --- a/versions.tf +++ b/versions.tf @@ -2,6 +2,6 @@ terraform { required_version = "~> 0.12.0" required_providers { - aws = "~> 2.70" + aws = ">= 2.68, < 4.0" } } From 5ac27c7a47d6937ebb76e91e589a36d4712f73c9 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Tue, 22 Sep 2020 17:52:01 -0700 Subject: [PATCH 2/8] removing region --- README.md | 1 - examples/alb/main.tf | 1 - examples/alb_remote/main.tf | 1 - examples/cloudtrail/main.tf | 1 - examples/combined/main.tf | 3 +-- examples/elb/main.tf | 1 - examples/nlb/main.tf | 1 - examples/redshift/main.tf | 1 - examples/s3/main.tf | 1 - examples/simple/main.tf | 1 - main.tf | 7 ++++++- variables.tf | 5 ----- 12 files changed, 7 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 298abf7..937eeb8 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,6 @@ module "aws_logs" { | nlb\_account | Account for NLB logs. By default limits to the current account. | `string` | `""` | no | | nlb\_logs\_prefixes | S3 key prefixes for NLB logs. | `list(string)` |
[
"nlb"
]
| no | | redshift\_logs\_prefix | S3 prefix for RedShift logs. | `string` | `"redshift"` | no | -| region | Region where the AWS S3 bucket will be created. | `string` | n/a | yes | | s3\_bucket\_acl | Set bucket ACL per [AWS S3 Canned ACL]() list. | `string` | `"log-delivery-write"` | no | | s3\_bucket\_name | S3 bucket to store AWS logs in. | `string` | n/a | yes | | s3\_log\_bucket\_retention | Number of days to keep AWS logs around. | `string` | `90` | no | diff --git a/examples/alb/main.tf b/examples/alb/main.tf index 97236f9..6d568d1 100644 --- a/examples/alb/main.tf +++ b/examples/alb/main.tf @@ -3,7 +3,6 @@ module "aws_logs" { s3_bucket_name = var.test_name alb_logs_prefixes = var.alb_logs_prefixes - region = var.region allow_alb = true default_allow = false diff --git a/examples/alb_remote/main.tf b/examples/alb_remote/main.tf index e6e9588..8683aea 100644 --- a/examples/alb_remote/main.tf +++ b/examples/alb_remote/main.tf @@ -6,7 +6,6 @@ module "aws_logs" { s3_bucket_name = var.test_name alb_logs_prefixes = var.alb_logs_prefixes - region = var.region allow_alb = true default_allow = false diff --git a/examples/cloudtrail/main.tf b/examples/cloudtrail/main.tf index ff9aa31..6aa0d27 100644 --- a/examples/cloudtrail/main.tf +++ b/examples/cloudtrail/main.tf @@ -2,7 +2,6 @@ module "aws_logs" { source = "../../" s3_bucket_name = var.test_name - region = var.region force_destroy = var.force_destroy cloudtrail_logs_prefix = var.cloudtrail_logs_prefix diff --git a/examples/combined/main.tf b/examples/combined/main.tf index 371b1dc..7091c4f 100644 --- a/examples/combined/main.tf +++ b/examples/combined/main.tf @@ -2,7 +2,6 @@ module "aws_logs" { source = "../../" s3_bucket_name = var.test_name - region = var.region default_allow = true force_destroy = var.force_destroy @@ -32,7 +31,7 @@ module "aws_cloudtrail" { module "config" { source = "trussworks/config/aws" - version = "~> 2" + version = "~> 3" config_name = var.test_name config_logs_bucket = module.aws_logs.aws_logs_bucket diff --git a/examples/elb/main.tf b/examples/elb/main.tf index b84ce26..5a6452a 100644 --- a/examples/elb/main.tf +++ b/examples/elb/main.tf @@ -3,7 +3,6 @@ module "aws_logs" { s3_bucket_name = var.test_name elb_logs_prefix = var.elb_logs_prefix - region = var.region allow_elb = true default_allow = false diff --git a/examples/nlb/main.tf b/examples/nlb/main.tf index af50441..1da1b3e 100644 --- a/examples/nlb/main.tf +++ b/examples/nlb/main.tf @@ -3,7 +3,6 @@ module "aws_logs" { s3_bucket_name = var.test_name nlb_logs_prefixes = var.nlb_logs_prefixes - region = var.region allow_nlb = true default_allow = false diff --git a/examples/redshift/main.tf b/examples/redshift/main.tf index 97656c8..2df2c89 100644 --- a/examples/redshift/main.tf +++ b/examples/redshift/main.tf @@ -3,7 +3,6 @@ module "aws_logs" { s3_bucket_name = var.test_name redshift_logs_prefix = var.redshift_logs_prefix - region = var.region allow_redshift = true default_allow = false diff --git a/examples/s3/main.tf b/examples/s3/main.tf index 8945168..295f13d 100644 --- a/examples/s3/main.tf +++ b/examples/s3/main.tf @@ -2,7 +2,6 @@ module "aws_logs" { source = "../../" s3_bucket_name = var.test_name - region = var.region default_allow = false diff --git a/examples/simple/main.tf b/examples/simple/main.tf index faafaa2..8f2a2f4 100644 --- a/examples/simple/main.tf +++ b/examples/simple/main.tf @@ -2,7 +2,6 @@ module "aws_logs" { source = "../../" s3_bucket_name = var.test_name - region = var.region force_destroy = var.force_destroy tags = var.tags diff --git a/main.tf b/main.tf index a922107..2bb14a3 100644 --- a/main.tf +++ b/main.tf @@ -16,6 +16,11 @@ data "aws_caller_identity" "current" { data "aws_partition" "current" { } +# The region is pulled from the current AWS session you are in +data "aws_region" "current" { + +} + locals { # S3 bucket ARN bucket_arn = "arn:${data.aws_partition.current.partition}:s3:::${var.s3_bucket_name}" @@ -48,7 +53,7 @@ locals { cloudwatch_effect = var.default_allow || var.allow_cloudwatch ? "Allow" : "Deny" # region specific logs service principal - cloudwatch_service = "logs.${var.region}.amazonaws.com" + cloudwatch_service = "logs.${data.aws_region.current.name}.amazonaws.com" cloudwatch_resource = "${local.bucket_arn}/${var.cloudwatch_logs_prefix}/*" diff --git a/variables.tf b/variables.tf index 9c125c8..3a5042a 100644 --- a/variables.tf +++ b/variables.tf @@ -3,11 +3,6 @@ variable "s3_bucket_name" { type = string } -variable "region" { - description = "Region where the AWS S3 bucket will be created." - type = string -} - variable "s3_log_bucket_retention" { description = "Number of days to keep AWS logs around." default = 90 From 44a1e7a5af2b85641e8e346408cac8541d5e05df Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Tue, 22 Sep 2020 18:07:13 -0700 Subject: [PATCH 3/8] missed one --- examples/nlb_remote/main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/nlb_remote/main.tf b/examples/nlb_remote/main.tf index 10b8165..1528e19 100644 --- a/examples/nlb_remote/main.tf +++ b/examples/nlb_remote/main.tf @@ -6,7 +6,6 @@ module "aws_logs" { s3_bucket_name = var.test_name nlb_logs_prefixes = var.nlb_logs_prefixes - region = var.region allow_nlb = true default_allow = false From d59f307297d3aa2ea26c0043d1013f3cd3c72f81 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Tue, 22 Sep 2020 18:10:53 -0700 Subject: [PATCH 4/8] missed another reference --- main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/main.tf b/main.tf index 2bb14a3..a8bb71d 100644 --- a/main.tf +++ b/main.tf @@ -353,7 +353,6 @@ data "aws_iam_policy_document" "main" { resource "aws_s3_bucket" "aws_logs" { bucket = var.s3_bucket_name acl = var.s3_bucket_acl - region = var.region policy = data.aws_iam_policy_document.main.json force_destroy = var.force_destroy From d7c8d0cbb425df9d587d6dd017e4da7b17127b30 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Tue, 22 Sep 2020 18:24:48 -0700 Subject: [PATCH 5/8] cleaning up more --- examples/cloudtrail/main.tf | 2 +- examples/config/main.tf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/cloudtrail/main.tf b/examples/cloudtrail/main.tf index 6aa0d27..fbec5d2 100644 --- a/examples/cloudtrail/main.tf +++ b/examples/cloudtrail/main.tf @@ -11,7 +11,7 @@ module "aws_logs" { module "aws_cloudtrail" { source = "trussworks/cloudtrail/aws" - version = "~> 2" + version = "~> 3" s3_bucket_name = module.aws_logs.aws_logs_bucket cloudwatch_log_group_name = var.test_name diff --git a/examples/config/main.tf b/examples/config/main.tf index 0a0219c..17ffa72 100644 --- a/examples/config/main.tf +++ b/examples/config/main.tf @@ -2,7 +2,6 @@ module "aws_logs" { source = "../../" s3_bucket_name = var.test_name - region = var.region allow_config = true default_allow = false config_logs_prefix = var.config_logs_prefix From dc5f66ab82e2833f83ccc2eb43ca757a0ee4eea3 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Wed, 23 Sep 2020 13:24:43 -0700 Subject: [PATCH 6/8] maybe its the version of cloudtrail in this test --- examples/combined/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/combined/main.tf b/examples/combined/main.tf index 7091c4f..c067c1a 100644 --- a/examples/combined/main.tf +++ b/examples/combined/main.tf @@ -22,7 +22,7 @@ resource "aws_lb" "test_alb" { module "aws_cloudtrail" { source = "trussworks/cloudtrail/aws" - version = "~> 2" + version = "~> 3" s3_bucket_name = module.aws_logs.aws_logs_bucket s3_key_prefix = "cloudtrail" From 7a08423be53f6d80c8732745186ddf015db912b7 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Wed, 23 Sep 2020 15:01:11 -0700 Subject: [PATCH 7/8] likely lingering test issue with cnfig --- examples/cloudtrail/main.tf | 2 +- examples/combined/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cloudtrail/main.tf b/examples/cloudtrail/main.tf index fbec5d2..8c2f64d 100644 --- a/examples/cloudtrail/main.tf +++ b/examples/cloudtrail/main.tf @@ -11,7 +11,7 @@ module "aws_logs" { module "aws_cloudtrail" { source = "trussworks/cloudtrail/aws" - version = "~> 3" + version = "~> 3.0" s3_bucket_name = module.aws_logs.aws_logs_bucket cloudwatch_log_group_name = var.test_name diff --git a/examples/combined/main.tf b/examples/combined/main.tf index c067c1a..0f14d4b 100644 --- a/examples/combined/main.tf +++ b/examples/combined/main.tf @@ -22,7 +22,7 @@ resource "aws_lb" "test_alb" { module "aws_cloudtrail" { source = "trussworks/cloudtrail/aws" - version = "~> 3" + version = "~> 3.0" s3_bucket_name = module.aws_logs.aws_logs_bucket s3_key_prefix = "cloudtrail" From 3a5b2a1fcc92e18eba76e001997f697d1cfcd1d5 Mon Sep 17 00:00:00 2001 From: Elizabeth Eady Date: Thu, 24 Sep 2020 13:50:16 -0700 Subject: [PATCH 8/8] just the config etest failing i think --- examples/combined/providers.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/combined/providers.tf b/examples/combined/providers.tf index f09b9eb..6dc7807 100644 --- a/examples/combined/providers.tf +++ b/examples/combined/providers.tf @@ -1,3 +1,4 @@ provider "aws" { version = "~> 2.70" + region = var.region }