-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.tf
68 lines (55 loc) · 2.15 KB
/
db.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
68
module "wp_db" {
source = "terraform-aws-modules/rds-aurora/aws"
version = "4.3.0"
name = "${var.name_prefix}-wp-db"
engine = "aurora-mysql"
engine_mode = "serverless"
storage_encrypted = true
vpc_id = module.vpc.vpc_id
subnets = module.vpc.database_subnets
db_subnet_group_name = module.vpc.database_subnet_group_name
allowed_security_groups = [module.ecs_task_sg.this_security_group_id]
replica_scale_enabled = false
replica_count = 0
db_parameter_group_name = aws_db_parameter_group.aurora_mysql.id
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.aurora_mysql.id
database_name = "wordpress"
create_random_password = false
username = var.db_master_username
password = var.db_master_password
apply_immediately = true
skip_final_snapshot = true
scaling_configuration = {
auto_pause = var.db_autopause
min_capacity = var.db_min_capacity
max_capacity = var.db_max_capacity
seconds_until_auto_pause = var.db_autopause_after_seconds
timeout_action = "RollbackCapacityChange"
}
create_monitoring_role = false
tags = var.common_tags
}
resource "aws_db_parameter_group" "aurora_mysql" {
name = "${var.name_prefix}-aurora-db-mysql-parameter-group"
family = "aurora-mysql5.7"
description = "${var.name_prefix}-aurora-db-mysql-parameter-group"
tags = var.common_tags
}
resource "aws_rds_cluster_parameter_group" "aurora_mysql" {
name = "${var.name_prefix}-aurora-mysql-cluster-parameter-group"
family = "aurora-mysql5.7"
description = "${var.name_prefix}-aurora-mysql-cluster-parameter-group"
tags = var.common_tags
}
resource "aws_ssm_parameter" "db_master_user" {
name = "/${var.name_prefix}/db_master_user"
type = "SecureString"
value = var.db_master_username
tags = var.common_tags
}
resource "aws_ssm_parameter" "db_master_password" {
name = "/${var.name_prefix}/db_master_password"
type = "SecureString"
value = var.db_master_password
tags = var.common_tags
}