Commit 19e79027 authored by Bryant Biggs's avatar Bryant Biggs Committed by GitHub

fix: add default values to allow for completely disabling module with bare minimum input (#342)

parent 3cfc2c9e
......@@ -21,6 +21,6 @@ repos:
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.0.1
hooks:
- id: check-merge-conflict
This diff is collapsed.
......@@ -33,6 +33,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version |
|------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
......@@ -159,3 +159,14 @@ module "db" {
tags = local.tags
}
module "db_disabled" {
source = "../../"
identifier = "${local.name}-disabled"
create_db_instance = false
create_db_subnet_group = false
create_db_parameter_group = false
create_db_option_group = false
}
......@@ -32,6 +32,7 @@ No providers.
|------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
......@@ -155,3 +155,14 @@ module "db_default" {
tags = local.tags
}
module "db_disabled" {
source = "../../"
identifier = "${local.name}-disabled"
create_db_instance = false
create_db_subnet_group = false
create_db_parameter_group = false
create_db_option_group = false
}
......@@ -31,6 +31,7 @@ No providers.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
......@@ -102,3 +102,14 @@ module "db" {
tags = local.tags
}
module "db_disabled" {
source = "../../"
identifier = "${local.name}-disabled"
create_db_instance = false
create_db_subnet_group = false
create_db_parameter_group = false
create_db_option_group = false
}
......@@ -32,6 +32,7 @@ No providers.
|------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | |
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | |
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
......@@ -159,3 +159,14 @@ module "db_default" {
tags = local.tags
}
module "db_disabled" {
source = "../../"
identifier = "${local.name}-disabled"
create_db_instance = false
create_db_subnet_group = false
create_db_parameter_group = false
create_db_option_group = false
}
locals {
master_password = var.create_db_instance && var.create_random_password ? random_password.master_password[0].result : var.password
db_subnet_group_name = var.replicate_source_db != null ? null : coalesce(var.db_subnet_group_name, module.db_subnet_group.db_subnet_group_id)
db_subnet_group_name = var.replicate_source_db != null ? null : coalesce(var.db_subnet_group_name, module.db_subnet_group.db_subnet_group_id, var.identifier)
parameter_group_name_id = var.create_db_parameter_group ? module.db_parameter_group.db_parameter_group_id : var.parameter_group_name
......
This diff is collapsed.
......@@ -12,6 +12,7 @@ variable "identifier" {
variable "allocated_storage" {
description = "The allocated storage in gigabytes"
type = string
default = null
}
variable "storage_type" {
......@@ -65,16 +66,19 @@ variable "domain_iam_role_name" {
variable "engine" {
description = "The database engine to use"
type = string
default = ""
}
variable "engine_version" {
description = "The engine version to use"
type = string
default = null
}
variable "instance_class" {
description = "The instance type of the RDS instance"
type = string
default = null
}
variable "name" {
......@@ -86,16 +90,19 @@ variable "name" {
variable "username" {
description = "Username for the master DB user"
type = string
default = null
}
variable "password" {
description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file"
type = string
default = null
}
variable "port" {
description = "The port on which the DB accepts connections"
type = string
default = null
}
variable "skip_final_snapshot" {
......@@ -215,6 +222,7 @@ variable "apply_immediately" {
variable "maintenance_window" {
description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'"
type = string
default = null
}
variable "backup_retention_period" {
......@@ -226,6 +234,7 @@ variable "backup_retention_period" {
variable "backup_window" {
description = "The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance_window"
type = string
default = null
}
variable "tags" {
......
......@@ -29,8 +29,8 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_create"></a> [create](#input\_create) | Whether to create this resource or not? | `bool` | `true` | no |
| <a name="input_engine_name"></a> [engine\_name](#input\_engine\_name) | Specifies the name of the engine that this option group should be associated with | `string` | n/a | yes |
| <a name="input_major_engine_version"></a> [major\_engine\_version](#input\_major\_engine\_version) | Specifies the major version of the engine that this option group should be associated with | `string` | n/a | yes |
| <a name="input_engine_name"></a> [engine\_name](#input\_engine\_name) | Specifies the name of the engine that this option group should be associated with | `string` | `null` | no |
| <a name="input_major_engine_version"></a> [major\_engine\_version](#input\_major\_engine\_version) | Specifies the major version of the engine that this option group should be associated with | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the option group | `string` | `""` | no |
| <a name="input_option_group_description"></a> [option\_group\_description](#input\_option\_group\_description) | The description of the option group | `string` | `""` | no |
| <a name="input_options"></a> [options](#input\_options) | A list of Options to apply | `any` | `[]` | no |
......
......@@ -25,11 +25,13 @@ variable "option_group_description" {
variable "engine_name" {
description = "Specifies the name of the engine that this option group should be associated with"
type = string
default = null
}
variable "major_engine_version" {
description = "Specifies the major version of the engine that this option group should be associated with"
type = string
default = null
}
variable "options" {
......
......@@ -30,7 +30,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_create"></a> [create](#input\_create) | Whether to create this resource or not? | `bool` | `true` | no |
| <a name="input_description"></a> [description](#input\_description) | The description of the DB parameter group | `string` | `""` | no |
| <a name="input_family"></a> [family](#input\_family) | The family of the DB parameter group | `string` | n/a | yes |
| <a name="input_family"></a> [family](#input\_family) | The family of the DB parameter group | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the DB parameter group | `string` | `""` | no |
| <a name="input_parameters"></a> [parameters](#input\_parameters) | A list of DB parameter maps to apply | `list(map(string))` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no |
......
......@@ -25,6 +25,7 @@ variable "description" {
variable "family" {
description = "The family of the DB parameter group"
type = string
default = null
}
variable "parameters" {
......
......@@ -6,6 +6,7 @@ variable "identifier" {
variable "allocated_storage" {
description = "The allocated storage in gigabytes"
type = string
default = null
}
variable "storage_type" {
......@@ -59,11 +60,13 @@ variable "domain_iam_role_name" {
variable "engine" {
description = "The database engine to use"
type = string
default = ""
}
variable "engine_version" {
description = "The engine version to use"
type = string
default = null
}
variable "skip_final_snapshot" {
......@@ -99,6 +102,7 @@ variable "final_snapshot_identifier_prefix" {
variable "instance_class" {
description = "The instance type of the RDS instance"
type = string
default = null
}
variable "name" {
......@@ -110,6 +114,7 @@ variable "name" {
variable "username" {
description = "Username for the master DB user"
type = string
default = null
}
variable "password" {
......@@ -121,6 +126,7 @@ variable "password" {
variable "port" {
description = "The port on which the DB accepts connections"
type = string
default = null
}
variable "vpc_security_group_ids" {
......@@ -198,6 +204,7 @@ variable "apply_immediately" {
variable "maintenance_window" {
description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'"
type = string
default = null
}
variable "backup_retention_period" {
......@@ -209,6 +216,7 @@ variable "backup_retention_period" {
variable "backup_window" {
description = "The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance_window"
type = string
default = null
}
variable "s3_import" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment