Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
drewmullen committed Jan 21, 2022
1 parent 6fae928 commit 8bd1203
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .header.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "arc" {
module "basic-recovery-controller-example" {
source = "../.."

name = var.name
Expand Down
2 changes: 2 additions & 0 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ 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)
vpc_id = optional(number)
tags = optional(map(string))
zone_id = optional(string)
})

default = {
name = null
zone_id = null
Expand Down
1 change: 1 addition & 0 deletions examples/basic/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
terraform {
experiments = [module_variable_optional_attrs]

required_providers {
aws = {
source = "hashicorp/aws"
Expand Down
2 changes: 0 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ locals {
}

# Readiness control

module "recovery_group" {
source = "./modules/readiness_recovery_group"

Expand All @@ -18,7 +17,6 @@ module "recovery_group" {
}

## Routing Control

module "recovery_cluster" {
count = var.create_recovery_cluster ? 1 : 0
source = "./modules/recovery_cluster"
Expand Down
4 changes: 4 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
18 changes: 14 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 ."
Expand All @@ -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"
Expand All @@ -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\"."
Expand All @@ -59,13 +64,15 @@ 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
threshold = number
type = string
name_suffix = string
}))

default = {
MinCellsActive = {
inverted = false
Expand All @@ -78,24 +85,27 @@ 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)
vpc_id = optional(number)
tags = optional(map(string))
zone_id = optional(string)
})

default = {
name = null
zone_id = null
}
}

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."
Expand Down

0 comments on commit 8bd1203

Please sign in to comment.