generated from geekcell/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
157 lines (117 loc) · 4.8 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
* # Terraform AWS RDS Aurora Cluster
*
* This Terraform module provides a preconfigured solution for setting up AWS RDS Aurora clusters in your AWS account.
* With this module, you can easily and efficiently create and manage RDS Aurora clusters with advanced features. Our
* team has extensive experience working with AWS RDS Aurora and has optimized this module to provide the best possible
* experience for users.
*
* By using this Terraform module, you can save time and effort in setting
* up and managing your RDS Aurora clusters, as well as ensure that your data
* is secure and protected. The module creates two users on the RDS Proxy,
* one with DML rights and one with DDL rights, to provide an additional
* layer of security and management. The autoscaling feature is also
* preconfigured, allowing for efficient and automatic management of
* resources based on your workload. The module encapsulates all necessary
* configurations, making it easy to use and integrate into your existing
* AWS environment. Whether you are just getting started with AWS RDS Aurora
* or looking for a more efficient way to manage your clusters, this
* Terraform module provides a preconfigured solution with advanced features
* such as extended backups, user management, and autoscaling.
*/
module "rds_cluster" {
source = "./modules/rds_cluster"
# The name of the cluster
cluster_identifier = var.cluster_identifier
# How many read replicas to create
additional_reader_capacity = var.additional_reader_capacity
# The engine
engine = var.engine
engine_version = var.engine_version
engine_mode = var.engine_mode
database_name = var.database_name
# Network
db_subnet_group_name = var.database_subnet_group_name
vpc_security_group_ids = var.vpc_security_group_ids_rds_cluster
port = var.port
# Security
deletion_protection = var.deletion_protection
preferred_backup_window = var.preferred_backup_window
preferred_maintenance_window = var.preferred_maintenance_window
backup_retention_period = var.backup_retention_period
# Maintenance
allow_major_version_upgrade = var.allow_major_version_upgrade
apply_immediately = var.apply_immediately
# Parameter Groups
db_cluster_parameter_group_name = length(var.db_cluster_parameters) > 0 ? module.db_cluster_parameter_group[0].name : var.db_cluster_parameter_group_name
db_instance_parameter_group_name = length(var.db_instance_parameters) > 0 ? module.db_instance_parameter_group[0].name : var.db_instance_parameter_group_name
# Cloudwatch Logs
enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports
tags = var.tags
}
module "rds_cluster_instance" {
source = "./modules/rds_cluster_instance/"
# Assign to which cluster
cluster_identifier = module.rds_cluster.id
# The engine version to use
engine = var.engine
engine_version = var.engine_version
# Instance identifier
identifier = var.cluster_identifier
# Instance class
instance_class = var.instance_class
# Network
db_subnet_group_name = var.database_subnet_group_name
# Security
apply_immediately = var.apply_immediately
# Maintenance
auto_minor_version_upgrade = var.auto_minor_version_upgrade
# Performance Insights
performance_insights_enabled = var.performance_insights_enabled
performance_insights_retention_period = var.performance_insights_retention_period
# Cloudwatch Logs
monitoring_interval = var.monitoring_interval
tags = var.tags
}
module "db_proxy" {
count = var.enable_db_proxy ? 1 : 0
source = "./modules/db_proxy/"
# Proxy name
name = var.cluster_identifier
# Users
users = var.db_proxy_users
# Cluster settings
rds_cluster_identifier = module.rds_cluster.id
vpc_subnet_ids = var.vpc_subnet_ids
vpc_security_group_ids = var.vpc_security_group_ids_rds_proxy
tags = var.tags
}
module "db_event_subscription" {
source = "./modules/db_event_subscription/"
# Event subscription name
name = var.cluster_identifier
# Source(s)
source_type = "db-cluster"
source_ids = [
module.rds_cluster.id
]
recipients = var.database_event_recipients
}
module "db_instance_parameter_group" {
count = length(var.db_instance_parameters) > 0 ? 1 : 0
source = "./modules/db_parameter_group/"
name = coalesce(var.db_instance_parameter_group_name, var.cluster_identifier)
family = var.db_instance_family
type = "instance"
parameters = var.db_instance_parameters
tags = var.tags
}
module "db_cluster_parameter_group" {
count = length(var.db_cluster_parameters) > 0 ? 1 : 0
source = "./modules/db_parameter_group/"
name = coalesce(var.db_cluster_parameter_group_name, var.cluster_identifier)
family = var.db_cluster_family
type = "cluster"
parameters = var.db_cluster_parameters
tags = var.tags
}