This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
forked from Kong/kong-terraform-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurora.tf
68 lines (56 loc) · 2.06 KB
/
aurora.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
resource "aws_rds_cluster" "kong" {
count = var.enable_aurora && var.db_instance_count > 0 ? 1 : 0
cluster_identifier = format("%s-%s", var.service, var.environment)
engine = "aurora-postgresql"
engine_version = var.db_engine_version
engine_mode = var.db_engine_mode
master_username = var.db_username
master_password = random_string.master_password.result
backup_retention_period = var.db_backup_retention_period
db_subnet_group_name = var.db_subnets
db_cluster_parameter_group_name = format("%s-%s-cluster", var.service, var.environment)
vpc_security_group_ids = [aws_security_group.postgresql.id]
tags = merge(
{
"Name" = format("%s-%s", var.service, var.environment),
"Environment" = var.environment,
"Description" = var.description,
"Service" = var.service,
},
var.tags
)
}
resource "aws_rds_cluster_instance" "kong" {
count = var.enable_aurora ? var.db_instance_count : 0
identifier = format("%s-%s-%s", var.service, var.environment, count.index)
cluster_identifier = aws_rds_cluster.kong[0].id
engine = "aurora-postgresql"
engine_version = var.db_engine_version
instance_class = var.db_instance_class
db_subnet_group_name = var.db_subnets
db_parameter_group_name = format("%s-%s", var.service, var.environment)
tags = merge(
{
"Name" = format("%s-%s", var.service, var.environment),
"Environment" = var.environment,
"Description" = var.description,
"Service" = var.service,
},
var.tags
)
}
resource "aws_rds_cluster_parameter_group" "kong" {
count = var.enable_aurora && var.db_instance_count > 0 ? 1 : 0
name = format("%s-%s-cluster", var.service, var.environment)
family = var.db_family
description = var.description
tags = merge(
{
"Name" = format("%s-%s-cluster", var.service, var.environment),
"Environment" = var.environment,
"Description" = var.description,
"Service" = var.service,
},
var.tags
)
}