-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws_rds.tf
More file actions
56 lines (42 loc) · 1.61 KB
/
aws_rds.tf
File metadata and controls
56 lines (42 loc) · 1.61 KB
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
# Associate the RDS Database with the primary and secondary subnets.
resource "aws_db_subnet_group" "database" {
name = format("%s_%s_subnet_group", var.app_acronym, var.app_environment)
subnet_ids = [aws_subnet.primary.id, aws_subnet.secondary.id]
tags = {
Environment = var.app_environment
Application = var.app_acronym
}
}
# RDS DB Scaling info -
# https://aws.amazon.com/blogs/database/scaling-your-amazon-rds-instance-vertically-and-horizontally/
resource "aws_db_instance" "database" {
# identifier is like name for this resource.
identifier = format("%s-%s-database", var.app_acronym, var.app_environment)
engine = "mariadb"
engine_version = "10.11.8"
instance_class = "db.t3.micro"
username = var.rds_username
db_name = var.rds_db_name
db_subnet_group_name = aws_db_subnet_group.database.name
vpc_security_group_ids = [aws_security_group.main_sg.id]
# Use Secret Manager to manage the password
manage_master_user_password = true
kms_key_id = aws_kms_key.app_kms_key.arn
storage_encrypted = true
# For updating & backups.
backup_retention_period = 7
backup_window = "03:00-04:00"
blue_green_update {
enabled = true
}
# For auto-scaling of storage
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#storage-autoscaling
allocated_storage = 20
max_allocated_storage = 100
skip_final_snapshot = true
publicly_accessible = false
tags = {
Environment = var.app_environment
Application = var.app_acronym
}
}