Skip to content

Commit e79aef0

Browse files
author
Scott Miller
authored
Merge pull request #7 from rhythmictech/database_create
ENG-1279
2 parents 72ae00c + b359c2e commit e79aef0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Create and manage an RDS PostgreSQL instance. Includes the ability to manage the
3939
| cloudwatch\_log\_exports | Log types to export to CloudWatch | `list(string)` | <pre>[<br> "postgresql",<br> "upgrade"<br>]</pre> | no |
4040
| create\_secretmanager\_secret | True to create a secretmanager secret containing DB password (not used if `password` is set) | `bool` | `true` | no |
4141
| create\_ssm\_secret | True to create a SSM Parameter SecretString containing DB password (not used if `password` is set) | `bool` | `false` | no |
42+
| database\_name | Name of the initial database to create. (null for none) | `string` | `null` | no |
4243
| enable\_deletion\_protection | If `true`, deletion protection will be turned on for the RDS instance(s) | `bool` | `true` | no |
4344
| engine\_version | Version of database engine to use | `string` | `"11.5"` | no |
4445
| final\_snapshot\_identifier | name of final snapshot (will be computed automatically if not specified) | `string` | `null` | no |

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ resource "aws_db_parameter_group" "this" {
4444
}
4545

4646
resource "aws_db_instance" "this" {
47-
identifier = var.identifier
48-
identifier_prefix = var.identifier_prefix
47+
identifier = try(substr(var.identifier, 0, 63), null)
48+
identifier_prefix = try(substr(var.identifier_prefix, 0, 36), null)
4949

5050
allocated_storage = var.storage
5151
backup_retention_period = var.backup_retention_period
@@ -61,7 +61,7 @@ resource "aws_db_instance" "this" {
6161
monitoring_interval = var.monitoring_interval
6262
monitoring_role_arn = var.monitoring_role_arn
6363
multi_az = var.multi_az
64-
name = replace(var.name, "/[^A-Za-z0-9]/", "")
64+
name = var.database_name
6565
parameter_group_name = local.parameter_group_name
6666
password = local.password
6767
performance_insights_enabled = var.performance_insights_enabled

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ variable "cloudwatch_log_exports" {
9696
]
9797
}
9898

99+
variable "database_name" {
100+
default = null
101+
description = "Name of the initial database to create. (null for none)"
102+
type = string
103+
}
104+
99105
variable "enable_deletion_protection" {
100106
default = true
101107
description = "If `true`, deletion protection will be turned on for the RDS instance(s)"

0 commit comments

Comments
 (0)