-
Notifications
You must be signed in to change notification settings - Fork 5
/
rds.tf
43 lines (36 loc) · 1.29 KB
/
rds.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
resource "aws_db_instance" "mysql" {
allocated_storage = 10
apply_immediately = true
engine = "mysql"
engine_version = "5.7.31"
instance_class = "db.t3.micro"
parameter_group_name = "default.mysql5.7"
iam_database_authentication_enabled = true
db_subnet_group_name = aws_db_subnet_group.mysql_subnet_group.name
vpc_security_group_ids = [aws_security_group.rds_sg.id]
name = var.db_name
username = var.db_username
password = var.db_password
port = var.db_port
storage_encrypted = true
skip_final_snapshot = true
backup_retention_period = 1
backup_window = "03:00-04:00"
maintenance_window = "Mon:00:00-Mon:02:00"
}
resource "aws_db_snapshot" "manual_snapshot" {
db_instance_identifier = aws_db_instance.mysql.identifier
db_snapshot_identifier = "manual-snapshot"
}
data "aws_subnet_ids" "database" {
vpc_id = var.vpc_id
filter {
name = "tag:Name"
values = var.subnet_names_db
}
}
resource "aws_db_subnet_group" "mysql_subnet_group" {
name = "mysql_subnet_group"
description = "Database subnets to attach the RDS instance to"
subnet_ids = data.aws_subnet_ids.database.ids
}