Skip to content

Commit 03c9279

Browse files
Merge pull request segmentio#96 from segmentio/rds/username
RDS: add database + username config
2 parents ed347a8 + c506d17 commit 03c9279

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

rds/main.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
variable "name" {
2-
description = "RDS name and Postgres username"
2+
description = "RDS instance name"
33
}
44

55
variable "engine" {
@@ -17,6 +17,16 @@ variable "port" {
1717
default = 5432
1818
}
1919

20+
variable "database" {
21+
description = "The database name for the RDS instance (if not specified, `var.name` will be used)"
22+
default = ""
23+
}
24+
25+
variable "username" {
26+
description = "The username for the RDS instance (if not specified, `var.name` will be used)"
27+
default = ""
28+
}
29+
2030
variable "password" {
2131
description = "Postgres user password"
2232
}
@@ -130,10 +140,10 @@ resource "aws_db_instance" "main" {
130140
# Database
131141
engine = "${var.engine}"
132142
engine_version = "${var.engine_version}"
133-
username = "${var.name}"
143+
username = "${coalesce(var.username, var.name)}"
134144
password = "${var.password}"
135145
multi_az = "${var.multi_az}"
136-
name = "${var.name}"
146+
name = "${coalesce(var.database, var.name)}"
137147

138148
# Backups / maintenance
139149
backup_retention_period = "${var.backup_retention_period}"

0 commit comments

Comments
 (0)