diff --git a/README.md b/README.md
index 680d95ae..5f9b7b7a 100644
--- a/README.md
+++ b/README.md
@@ -372,6 +372,7 @@ Available targets:
| [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
| [admin\_password](#input\_admin\_password) | Password for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `""` | no |
| [admin\_user](#input\_admin\_user) | Username for the master DB user. Ignored if snapshot\_identifier or replication\_source\_identifier is provided | `string` | `"admin"` | no |
+| [admin\_user\_secret\_kms\_key\_id](#input\_admin\_user\_secret\_kms\_key\_id) | Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key.
To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN.
If not specified, the default KMS key for your Amazon Web Services account is used. | `string` | `null` | no |
| [allocated\_storage](#input\_allocated\_storage) | The allocated storage in GBs | `number` | `null` | no |
| [allow\_major\_version\_upgrade](#input\_allow\_major\_version\_upgrade) | Enable to allow major engine version upgrades when changing engine versions. Defaults to false. | `bool` | `false` | no |
| [allowed\_cidr\_blocks](#input\_allowed\_cidr\_blocks) | List of CIDR blocks allowed to access the cluster | `list(string)` | `[]` | no |
@@ -429,6 +430,7 @@ Available targets:
| [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no |
| [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` |
[| no | | [maintenance\_window](#input\_maintenance\_window) | Weekly time range during which system maintenance can occur, in UTC | `string` | `"wed:03:00-wed:04:00"` | no | +| [manage\_admin\_user\_password](#input\_manage\_admin\_user\_password) | Set to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if master\_password is provided | `bool` | `false` | no | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
"default"
]
[| no | | [maintenance\_window](#input\_maintenance\_window) | Weekly time range during which system maintenance can occur, in UTC | `string` | `"wed:03:00-wed:04:00"` | no | +| [manage\_admin\_user\_password](#input\_manage\_admin\_user\_password) | Set to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if master\_password is provided | `bool` | `false` | no | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
"default"
]
list(object({| `[]` | no | +| [restore\_to\_point\_in\_time](#input\_restore\_to\_point\_in\_time) | List of point-in-time recovery options. Valid parameters are:
source_cluster_identifier = string
restore_type = string
use_latest_restorable_time = bool
restore_to_time = string
}))
list(object({| `[]` | no | | [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no | | [s3\_import](#input\_s3\_import) | Restore from a Percona Xtrabackup in S3. The `bucket_name` is required to be in the same region as the resource. |
source_cluster_identifier = string
restore_type = optional(string, "copy-on-write")
use_latest_restorable_time = optional(bool, true)
restore_to_time = optional(string, null)
}))
object({| `null` | no | | [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` |
bucket_name = string
bucket_prefix = string
ingestion_role = string
source_engine = string
source_engine_version = string
})
list(object({| `[]` | no | diff --git a/main.tf b/main.tf index d9845747..024d7ba7 100644 --- a/main.tf +++ b/main.tf @@ -69,11 +69,14 @@ resource "aws_security_group_rule" "egress" { # The name "primary" is poorly chosen. We actually mean standalone or regional. # The primary cluster of a global database is actually created with the "secondary" cluster resource below. resource "aws_rds_cluster" "primary" { - count = local.enabled && local.is_regional_cluster ? 1 : 0 - cluster_identifier = var.cluster_identifier == "" ? module.this.id : var.cluster_identifier - database_name = var.db_name + count = local.enabled && local.is_regional_cluster ? 1 : 0 + cluster_identifier = var.cluster_identifier == "" ? module.this.id : var.cluster_identifier + database_name = var.db_name + # manage_master_user_password must be `null` or `true`. If it is `false`, and `master_password` is not `null`, a conflict occurs. + manage_master_user_password = var.manage_admin_user_password ? var.manage_admin_user_password : null + master_user_secret_kms_key_id = var.admin_user_secret_kms_key_id master_username = local.ignore_admin_credentials ? null : var.admin_user - master_password = local.ignore_admin_credentials ? null : var.admin_password + master_password = local.ignore_admin_credentials || var.manage_admin_user_password ? null : var.admin_password backup_retention_period = var.retention_period preferred_backup_window = var.backup_window copy_tags_to_snapshot = var.copy_tags_to_snapshot @@ -169,11 +172,14 @@ resource "aws_rds_cluster" "primary" { # https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster#replication_source_identifier resource "aws_rds_cluster" "secondary" { - count = local.enabled && !local.is_regional_cluster ? 1 : 0 - cluster_identifier = var.cluster_identifier == "" ? module.this.id : var.cluster_identifier - database_name = var.db_name + count = local.enabled && !local.is_regional_cluster ? 1 : 0 + cluster_identifier = var.cluster_identifier == "" ? module.this.id : var.cluster_identifier + database_name = var.db_name + # manage_master_user_password must be `null` or `true`. If it is `false`, and `master_password` is not `null`, a conflict occurs. + manage_master_user_password = var.manage_admin_user_password ? var.manage_admin_user_password : null + master_user_secret_kms_key_id = var.admin_user_secret_kms_key_id master_username = local.ignore_admin_credentials ? null : var.admin_user - master_password = local.ignore_admin_credentials ? null : var.admin_password + master_password = local.ignore_admin_credentials || var.manage_admin_user_password ? null : var.admin_password backup_retention_period = var.retention_period preferred_backup_window = var.backup_window copy_tags_to_snapshot = var.copy_tags_to_snapshot diff --git a/variables.tf b/variables.tf index f32950ed..1cf1b9be 100644 --- a/variables.tf +++ b/variables.tf @@ -60,6 +60,23 @@ variable "db_port" { description = "Database port" } +variable "manage_admin_user_password" { + type = bool + default = false + nullable = false + description = "Set to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if master_password is provided" +} + +variable "admin_user_secret_kms_key_id" { + type = string + default = null + description = <<-EOT + Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key. + To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN. + If not specified, the default KMS key for your Amazon Web Services account is used. + EOT +} + variable "admin_user" { type = string default = "admin"
auto_pause = bool
max_capacity = number
min_capacity = number
seconds_until_auto_pause = number
timeout_action = string
}))