From 8bd12035d1e94e9c9a4c1bd6bd85a7aa1107b490 Mon Sep 17 00:00:00 2001 From: drewmullen Date: Fri, 21 Jan 2022 12:08:10 -0500 Subject: [PATCH] PR feedback --- .header.md | 2 +- NOTICE.txt | 2 +- data.tf | 1 - examples/basic/main.tf | 2 +- examples/basic/variables.tf | 2 ++ examples/basic/versions.tf | 1 + main.tf | 2 -- provider.tf | 4 ++++ variables.tf | 18 ++++++++++++++---- 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.header.md b/.header.md index 20425e7..ae38f12 100644 --- a/.header.md +++ b/.header.md @@ -55,4 +55,4 @@ Currently, this module supports active/passive for applications across Regions. You can contribute to this module by adding a new service. To do so, complete the following steps. 1. Add the service to the `var.resource_type_name` variable type definition. -1. Add the service key (from step 1) to the validation check for `var.cells_definition` in `variables.tf`. +1. Add the service key (from step 1) to the validation check for `var.cells_definition` in [variables.tf](./variables.tf). diff --git a/NOTICE.txt b/NOTICE.txt index 5c440d1..919c27c 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,4 +1,4 @@ -Copyright 2016-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at diff --git a/data.tf b/data.tf index 9a39f50..2304f11 100644 --- a/data.tf +++ b/data.tf @@ -100,7 +100,6 @@ data "aws_lb" "ap_southeast_2" { arn = var.cells_definition["ap-southeast-2"].elasticloadbalancing } - data "aws_lb" "eu_central_1" { count = local.configure_lbs && contains(local.regions, "eu-central-1") ? 1 : 0 provider = aws.eu-central-1 diff --git a/examples/basic/main.tf b/examples/basic/main.tf index c8b10a7..0d99de5 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,4 +1,4 @@ -module "arc" { +module "basic-recovery-controller-example" { source = "../.." name = var.name diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index 28f477b..62076da 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -11,6 +11,7 @@ variable "cells_definition" { variable "hosted_zone" { description = "Info about the hosted zone. If the `name` or `zone_id` is not passed, a search will be performed using the values provided. Leave null to not create Route53 Alias records (required for LB functionality) ." + type = object({ name = optional(string) private_zone = optional(bool) @@ -18,6 +19,7 @@ variable "hosted_zone" { tags = optional(map(string)) zone_id = optional(string) }) + default = { name = null zone_id = null diff --git a/examples/basic/versions.tf b/examples/basic/versions.tf index cf698d0..f7eca31 100644 --- a/examples/basic/versions.tf +++ b/examples/basic/versions.tf @@ -1,5 +1,6 @@ terraform { experiments = [module_variable_optional_attrs] + required_providers { aws = { source = "hashicorp/aws" diff --git a/main.tf b/main.tf index 2ace466..ebd2048 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,6 @@ locals { } # Readiness control - module "recovery_group" { source = "./modules/readiness_recovery_group" @@ -18,7 +17,6 @@ module "recovery_group" { } ## Routing Control - module "recovery_cluster" { count = var.create_recovery_cluster ? 1 : 0 source = "./modules/recovery_cluster" diff --git a/provider.tf b/provider.tf index d71dc45..3c8b633 100644 --- a/provider.tf +++ b/provider.tf @@ -1,3 +1,7 @@ +# Multiple providers are needed to search for information if loadbalancers are apart of the ARC configuration +# data sources are conditioned to check if LBs are being managed & per region. LBs will only be searched if +# theyre specified in a particular region. + # NORTHERN VIRGINIA : us-east-1 provider "aws" { region = "us-east-1" diff --git a/variables.tf b/variables.tf index 6f0753c..55f97c0 100644 --- a/variables.tf +++ b/variables.tf @@ -4,7 +4,7 @@ variable "name" { } variable "cells_definition" { - description = "Nested map where the key is a region you want to enable and keys referring to resource arns to enable. Services enabled are defined in `var.resource_type_name`. Example below:" + description = "Nested map where the key is a region you want to enable and keys referring to resource arns to enable. Services enabled are defined in `var.resource_type_name`. For examples, see the variables.tf file" /* cells_definition = { us-west-2 = { @@ -13,11 +13,14 @@ variable "cells_definition" { } } */ + type = map(map(string)) validation { condition = alltrue([for _, k in keys(var.cells_definition) : can(regex("[a-z][a-z]-[a-z]+-[1-9]", k))]) && alltrue(flatten([ for arns in var.cells_definition : [ - for service, arn in arns : contains(["apigateway", "autoscaling", "cloudwatch", "dynamodb", "ec2-volume", "ec2-vpc", "ec2-vpn-gw", "ec2-vpn-cgw", "ec2-vpn-conn", "elasticloadbalancing", "kafka", "lambda", "rds", "route53", "sns", "sqs"], service) + for service, arn in arns : contains(["apigateway", "autoscaling", "cloudwatch", "dynamodb", "ec2-volume", + "ec2-vpc", "ec2-vpn-gw", "ec2-vpn-cgw", "ec2-vpn-conn", "elasticloadbalancing", + "kafka", "lambda", "rds", "route53", "sns", "sqs"], service) ] ])) error_message = "Supported service names are the keys defined in var.resource_type_name ." @@ -27,6 +30,7 @@ variable "cells_definition" { variable "resource_type_name" { type = map(string) description = "list of all service types you can pass and their associated Resource Set Type." + default = { apigateway = "AWS::ApiGatewayV2::Api" autoscaling = "AWS::AutoScaling::AutoScalingGroup" @@ -51,6 +55,7 @@ variable "safety_rule_type" { description = "Type of safety rules to create. Can only be \"assertion\" or \"gating\"." type = string default = "assertion" + validation { condition = var.safety_rule_type == lower("assertion") || var.safety_rule_type == lower("gating") error_message = "Safety rule type can only be \"assertion\" or \"gating\"." @@ -59,6 +64,7 @@ variable "safety_rule_type" { variable "safety_rules" { description = "Configuration of the Safety Rules. Key is the name applied to the rule." + type = map(object({ wait_period_ms = number inverted = bool @@ -66,6 +72,7 @@ variable "safety_rules" { type = string name_suffix = string })) + default = { MinCellsActive = { inverted = false @@ -78,7 +85,8 @@ variable "safety_rules" { } variable "hosted_zone" { - description = "Info about the hosted zone. If the `name` or `zone_id` is not passed, a search will be performed using the values provided. Leave null to not create Route53 Alias records (required for LB functionality) ." + description = "Info about the hosted zone. If the `name` or `zone_id` is not passed, a search will be performed using the values provided. Leave null to not create Route53 Alias records (required for LB functionality)." + type = object({ name = optional(string) private_zone = optional(bool) @@ -86,6 +94,7 @@ variable "hosted_zone" { tags = optional(map(string)) zone_id = optional(string) }) + default = { name = null zone_id = null @@ -93,9 +102,10 @@ variable "hosted_zone" { } variable "primary_cell_region" { - description = "(Optional) Region name of which Cell to make Route53 Primary. Defaults to default provider region if not set. " + description = "(Optional) Region name of which Cell to make Route53 Primary. Defaults to default provider region if not set." type = string default = null + validation { condition = can(regex("[a-z][a-z]-[a-z]+-[1-9]", var.primary_cell_region)) || var.primary_cell_region == null error_message = "Must be a valid AWS region format."