Skip to content

Commit c67b743

Browse files
authored
Added rds as backing service (#43)
* Added rds as backing service * Added rds as backing service * Added rds as backing service * Added rds as backing service * Added rds as backing service * Fix ingress * Fix ingress * Added rds outputs * Added rds outputs * Added enabled option * Update versions of rds and elastic search * Pin propriate version * Address PR comments * Address Comments * Address Comments * Address Comments * Address Comments
1 parent 4043504 commit c67b743

File tree

2 files changed

+218
-1
lines changed

2 files changed

+218
-1
lines changed

aws/backing-services/elasticsearch.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ locals {
6363
}
6464

6565
module "elasticsearch" {
66-
source = "git::https://github.com/cloudposse/terraform-aws-elasticsearch.git?ref=tags/0.1.2"
66+
source = "git::https://github.com/cloudposse/terraform-aws-elasticsearch.git?ref=tags/0.1.3"
6767
namespace = "${var.namespace}"
6868
stage = "${var.stage}"
6969
name = "${var.ELASTICSEARCH_NAME}"

aws/backing-services/rds.tf

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
variable "RDS_NAME" {
2+
type = "string"
3+
default = "rds"
4+
description = "RDS instance name"
5+
}
6+
7+
variable "RDS_ENABLED" {
8+
type = "string"
9+
default = "false"
10+
description = "Set to true to create rds instance"
11+
}
12+
13+
# Don't use `root`
14+
# ("MasterUsername root cannot be used as it is a reserved word used by the engine")
15+
variable "RDS_ADMIN_NAME" {
16+
type = "string"
17+
description = "RDS DB admin user name"
18+
}
19+
20+
# Must be longer than 8 chars
21+
# ("The parameter MasterUserPassword is not a valid password because it is shorter than 8 characters")
22+
variable "RDS_ADMIN_PASSWORD" {
23+
type = "string"
24+
description = "RDS DB password for the admin user"
25+
}
26+
27+
# Don't use `default`
28+
# ("DatabaseName default cannot be used as it is a reserved word used by the engine")
29+
variable "RDS_DB_NAME" {
30+
type = "string"
31+
description = "RDS DB database name"
32+
}
33+
34+
# db.t2.micro is free tier
35+
# https://aws.amazon.com/rds/free
36+
variable "RDS_INSTANCE_TYPE" {
37+
type = "string"
38+
default = "db.t2.micro"
39+
description = "EC2 instance type for RDS DB"
40+
}
41+
42+
variable "RDS_ENGINE" {
43+
type = "string"
44+
default = "mysql"
45+
description = "RDS DB engine"
46+
}
47+
48+
variable "RDS_ENGINE_VERSION" {
49+
type = "string"
50+
default = "5.6"
51+
description = "RDS DB engine version"
52+
}
53+
54+
variable "RDS_PORT" {
55+
type = "string"
56+
default = "3306"
57+
description = "RDS DB port"
58+
}
59+
60+
variable "RDS_DB_PARAMETER_GROUP" {
61+
type = "string"
62+
default = "mysql5.6"
63+
description = "RDS DB engine version"
64+
}
65+
66+
variable "RDS_CLUSTER_ENABLED" {
67+
type = "string"
68+
default = "true"
69+
description = "Set to false to prevent the module from creating any resources"
70+
}
71+
72+
variable "RDS_SNAPSHOT" {
73+
type = "string"
74+
default = ""
75+
description = "Set to a snapshot ID to restore from snapshot"
76+
}
77+
78+
variable "RDS_PARAMETER_GROUP_NAME" {
79+
type = "string"
80+
default = ""
81+
description = "Existing parameter group name to use"
82+
}
83+
84+
variable "RDS_MULTI_AZ" {
85+
type = "string"
86+
default = "false"
87+
description = "Run instaces in multiple az"
88+
}
89+
90+
variable "RDS_STORAGE_TYPE" {
91+
type = "string"
92+
default = "gp2"
93+
description = "Storage type"
94+
}
95+
96+
variable "RDS_STORAGE_SIZE" {
97+
type = "string"
98+
default = "20"
99+
description = "Storage size"
100+
}
101+
102+
variable "RDS_STORAGE_ENCRYPTED" {
103+
type = "string"
104+
default = "false"
105+
description = "Set true to encrypt storage"
106+
}
107+
108+
variable "RDS_AUTO_MINOR_VERSION_UPGRADE" {
109+
type = "string"
110+
default = "false"
111+
description = "Allow automated minor version upgrade (e.g. from Postgres 9.5.3 to Postgres 9.5.4)"
112+
}
113+
114+
variable "RDS_ALLOW_MAJOR_VERSION_UPGRADE" {
115+
type = "string"
116+
default = "false"
117+
description = "Allow major version upgrade"
118+
}
119+
120+
variable "RDS_APPLY_IMMEDIATELY" {
121+
type = "string"
122+
default = "true"
123+
description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window"
124+
}
125+
126+
variable "RDS_SKIP_FINAL_SNAPSHOT" {
127+
type = "string"
128+
default = "false"
129+
description = "If true (default), no snapshot will be made before deleting DB"
130+
}
131+
132+
variable "RDS_BACKUP_RETENTION_PERIOD" {
133+
type = "string"
134+
default = "7"
135+
description = "Backup retention period in days. Must be > 0 to enable backups"
136+
}
137+
138+
variable "RDS_BACKUP_WINDOW" {
139+
type = "string"
140+
default = "22:00-03:00"
141+
description = "When AWS can perform DB snapshots, can't overlap with maintenance window"
142+
}
143+
144+
module "rds" {
145+
source = "git::https://github.com/cloudposse/terraform-aws-rds.git?ref=tags/0.4.1"
146+
enabled = "${var.RDS_ENABLED}"
147+
namespace = "${var.namespace}"
148+
stage = "${var.stage}"
149+
name = "${var.RDS_NAME}"
150+
dns_zone_id = "${var.zone_id}"
151+
host_name = "${var.RDS_NAME}"
152+
security_group_ids = ["${module.kops_metadata.nodes_security_group_id}"]
153+
database_name = "${var.RDS_DB_NAME}"
154+
database_user = "${var.RDS_ADMIN_NAME}"
155+
database_password = "${var.RDS_ADMIN_PASSWORD}"
156+
database_port = "${var.RDS_PORT}"
157+
multi_az = "${var.RDS_MULTI_AZ}"
158+
storage_type = "${var.RDS_STORAGE_TYPE}"
159+
allocated_storage = "${var.RDS_STORAGE_SIZE}"
160+
storage_encrypted = "${var.RDS_STORAGE_ENCRYPTED}"
161+
engine = "${var.RDS_ENGINE}"
162+
engine_version = "${var.RDS_ENGINE_VERSION}"
163+
instance_class = "${var.RDS_INSTANCE_TYPE}"
164+
db_parameter_group = "${var.RDS_DB_PARAMETER_GROUP}"
165+
parameter_group_name = "${var.RDS_PARAMETER_GROUP_NAME}"
166+
publicly_accessible = "false"
167+
subnet_ids = ["${module.subnets.private_subnet_ids}"]
168+
vpc_id = "${module.vpc.vpc_id}"
169+
snapshot_identifier = "${var.RDS_SNAPSHOT}"
170+
auto_minor_version_upgrade = "${var.RDS_AUTO_MINOR_VERSION_UPGRADE}"
171+
allow_major_version_upgrade = "${var.RDS_ALLOW_MAJOR_VERSION_UPGRADE}"
172+
apply_immediately = "${var.RDS_APPLY_IMMEDIATELY}"
173+
skip_final_snapshot = "${var.RDS_SKIP_FINAL_SNAPSHOT}"
174+
copy_tags_to_snapshot = "true"
175+
backup_retention_period = "${var.RDS_BACKUP_RETENTION_PERIOD}"
176+
backup_window = "${var.RDS_BACKUP_WINDOW}"
177+
}
178+
179+
output "rds_instance_id" {
180+
value = "${module.rds.instance_id}"
181+
description = "RDS ID of the instance"
182+
}
183+
184+
output "rds_instance_address" {
185+
value = "${module.rds.instance_address}"
186+
description = "RDS address of the instance"
187+
}
188+
189+
output "rds_instance_endpoint" {
190+
value = "${module.rds.instance_endpoint}"
191+
description = "RDS DNS Endpoint of the instance"
192+
}
193+
194+
output "rds_port" {
195+
value = "${var.RDS_PORT}"
196+
description = "RDS port"
197+
}
198+
199+
output "rds_db_name" {
200+
value = "${var.RDS_DB_NAME}"
201+
description = "RDS db name"
202+
}
203+
204+
output "rds_root_user" {
205+
value = "${var.RDS_ADMIN_NAME}"
206+
description = "RDS root user name"
207+
}
208+
209+
output "rds_root_password" {
210+
value = "${var.RDS_ADMIN_PASSWORD}"
211+
description = "RDS root password"
212+
}
213+
214+
output "rds_hostname" {
215+
value = "${module.rds.hostname}"
216+
description = "RDS host name of the instance"
217+
}

0 commit comments

Comments
 (0)