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: ...@@ -21,6 +21,6 @@ repos:
- '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote' - '--args=--only=terraform_workspace_remote'
- repo: git://github.com/pre-commit/pre-commit-hooks - repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 rev: v4.0.1
hooks: hooks:
- id: check-merge-conflict - 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 ...@@ -33,6 +33,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version | | Name | Source | Version |
|------|--------|---------| |------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | | | <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_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 | | <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
...@@ -159,3 +159,14 @@ module "db" { ...@@ -159,3 +159,14 @@ module "db" {
tags = local.tags 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. ...@@ -32,6 +32,7 @@ No providers.
|------|--------|---------| |------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | | | <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | | | <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_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 | | <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
...@@ -155,3 +155,14 @@ module "db_default" { ...@@ -155,3 +155,14 @@ module "db_default" {
tags = local.tags 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. ...@@ -31,6 +31,7 @@ No providers.
| Name | Source | Version | | Name | Source | Version |
|------|--------|---------| |------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | | | <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_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 | | <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
...@@ -102,3 +102,14 @@ module "db" { ...@@ -102,3 +102,14 @@ module "db" {
tags = local.tags 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. ...@@ -32,6 +32,7 @@ No providers.
|------|--------|---------| |------|--------|---------|
| <a name="module_db"></a> [db](#module\_db) | ../../ | | | <a name="module_db"></a> [db](#module\_db) | ../../ | |
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | | | <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_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 | | <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
......
...@@ -159,3 +159,14 @@ module "db_default" { ...@@ -159,3 +159,14 @@ module "db_default" {
tags = local.tags 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 { locals {
master_password = var.create_db_instance && var.create_random_password ? random_password.master_password[0].result : var.password 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 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" { ...@@ -12,6 +12,7 @@ variable "identifier" {
variable "allocated_storage" { variable "allocated_storage" {
description = "The allocated storage in gigabytes" description = "The allocated storage in gigabytes"
type = string type = string
default = null
} }
variable "storage_type" { variable "storage_type" {
...@@ -65,16 +66,19 @@ variable "domain_iam_role_name" { ...@@ -65,16 +66,19 @@ variable "domain_iam_role_name" {
variable "engine" { variable "engine" {
description = "The database engine to use" description = "The database engine to use"
type = string type = string
default = ""
} }
variable "engine_version" { variable "engine_version" {
description = "The engine version to use" description = "The engine version to use"
type = string type = string
default = null
} }
variable "instance_class" { variable "instance_class" {
description = "The instance type of the RDS instance" description = "The instance type of the RDS instance"
type = string type = string
default = null
} }
variable "name" { variable "name" {
...@@ -86,16 +90,19 @@ variable "name" { ...@@ -86,16 +90,19 @@ variable "name" {
variable "username" { variable "username" {
description = "Username for the master DB user" description = "Username for the master DB user"
type = string type = string
default = null
} }
variable "password" { 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" 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 type = string
default = null
} }
variable "port" { variable "port" {
description = "The port on which the DB accepts connections" description = "The port on which the DB accepts connections"
type = string type = string
default = null
} }
variable "skip_final_snapshot" { variable "skip_final_snapshot" {
...@@ -215,6 +222,7 @@ variable "apply_immediately" { ...@@ -215,6 +222,7 @@ variable "apply_immediately" {
variable "maintenance_window" { variable "maintenance_window" {
description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'" description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'"
type = string type = string
default = null
} }
variable "backup_retention_period" { variable "backup_retention_period" {
...@@ -226,6 +234,7 @@ variable "backup_retention_period" { ...@@ -226,6 +234,7 @@ variable "backup_retention_period" {
variable "backup_window" { 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" 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 type = string
default = null
} }
variable "tags" { variable "tags" {
......
...@@ -29,8 +29,8 @@ No modules. ...@@ -29,8 +29,8 @@ No modules.
| Name | Description | Type | Default | Required | | 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_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_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` | 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` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the option group | `string` | `""` | 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_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 | | <a name="input_options"></a> [options](#input\_options) | A list of Options to apply | `any` | `[]` | no |
......
...@@ -25,11 +25,13 @@ variable "option_group_description" { ...@@ -25,11 +25,13 @@ variable "option_group_description" {
variable "engine_name" { variable "engine_name" {
description = "Specifies the name of the engine that this option group should be associated with" description = "Specifies the name of the engine that this option group should be associated with"
type = string type = string
default = null
} }
variable "major_engine_version" { variable "major_engine_version" {
description = "Specifies the major version of the engine that this option group should be associated with" description = "Specifies the major version of the engine that this option group should be associated with"
type = string type = string
default = null
} }
variable "options" { variable "options" {
......
...@@ -30,7 +30,7 @@ No modules. ...@@ -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_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_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_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_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 | | <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" { ...@@ -25,6 +25,7 @@ variable "description" {
variable "family" { variable "family" {
description = "The family of the DB parameter group" description = "The family of the DB parameter group"
type = string type = string
default = null
} }
variable "parameters" { variable "parameters" {
......
...@@ -6,6 +6,7 @@ variable "identifier" { ...@@ -6,6 +6,7 @@ variable "identifier" {
variable "allocated_storage" { variable "allocated_storage" {
description = "The allocated storage in gigabytes" description = "The allocated storage in gigabytes"
type = string type = string
default = null
} }
variable "storage_type" { variable "storage_type" {
...@@ -59,11 +60,13 @@ variable "domain_iam_role_name" { ...@@ -59,11 +60,13 @@ variable "domain_iam_role_name" {
variable "engine" { variable "engine" {
description = "The database engine to use" description = "The database engine to use"
type = string type = string
default = ""
} }
variable "engine_version" { variable "engine_version" {
description = "The engine version to use" description = "The engine version to use"
type = string type = string
default = null
} }
variable "skip_final_snapshot" { variable "skip_final_snapshot" {
...@@ -99,6 +102,7 @@ variable "final_snapshot_identifier_prefix" { ...@@ -99,6 +102,7 @@ variable "final_snapshot_identifier_prefix" {
variable "instance_class" { variable "instance_class" {
description = "The instance type of the RDS instance" description = "The instance type of the RDS instance"
type = string type = string
default = null
} }
variable "name" { variable "name" {
...@@ -110,6 +114,7 @@ variable "name" { ...@@ -110,6 +114,7 @@ variable "name" {
variable "username" { variable "username" {
description = "Username for the master DB user" description = "Username for the master DB user"
type = string type = string
default = null
} }
variable "password" { variable "password" {
...@@ -121,6 +126,7 @@ variable "password" { ...@@ -121,6 +126,7 @@ variable "password" {
variable "port" { variable "port" {
description = "The port on which the DB accepts connections" description = "The port on which the DB accepts connections"
type = string type = string
default = null
} }
variable "vpc_security_group_ids" { variable "vpc_security_group_ids" {
...@@ -198,6 +204,7 @@ variable "apply_immediately" { ...@@ -198,6 +204,7 @@ variable "apply_immediately" {
variable "maintenance_window" { variable "maintenance_window" {
description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'" description = "The window to perform maintenance in. Syntax: 'ddd:hh24:mi-ddd:hh24:mi'. Eg: 'Mon:00:00-Mon:03:00'"
type = string type = string
default = null
} }
variable "backup_retention_period" { variable "backup_retention_period" {
...@@ -209,6 +216,7 @@ variable "backup_retention_period" { ...@@ -209,6 +216,7 @@ variable "backup_retention_period" {
variable "backup_window" { 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" 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 type = string
default = null
} }
variable "s3_import" { 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