Skip to content

Commit

Permalink
feat(aurora): naming rule change (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-ook authored Apr 22, 2022
1 parent de9c51c commit 99607a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions label.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
resource "random_string" "iid" {
for_each = { for k, v in var.aurora_instances : k => v }
length = 5
upper = false
lower = true
number = false
special = false
}

resource "random_string" "uid" {
length = 12
upper = false
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ resource "aws_db_parameter_group" "db" {

# rds cluster
resource "aws_rds_cluster" "db" {
cluster_identifier_prefix = format("%s-", local.name)
cluster_identifier = local.name
engine = lookup(var.aurora_cluster, "engine", local.default_cluster.engine)
engine_mode = lookup(var.aurora_cluster, "engine_mode", local.default_cluster.engine_mode)
engine_version = lookup(var.aurora_cluster, "version", local.default_cluster.version)
Expand All @@ -88,8 +88,8 @@ resource "aws_rds_cluster" "db" {

# rds instances
resource "aws_rds_cluster_instance" "db" {
for_each = { for key, val in var.aurora_instances : key => val }
identifier_prefix = format("instance-%s-", each.key)
for_each = { for k, v in var.aurora_instances : k => v }
identifier = join("-", [local.name, random_string.iid[each.key].result])
cluster_identifier = aws_rds_cluster.db.id
engine = lookup(var.aurora_cluster, "engine", local.default_cluster.engine)
engine_version = lookup(var.aurora_cluster, "version", local.default_cluster.version)
Expand Down

0 comments on commit 99607a5

Please sign in to comment.