generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.tf
57 lines (44 loc) · 1.33 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
locals {
db_subnet_ids = var.db_public_access ? var.public_subnet_ids : var.private_subnet_ids
}
resource "aws_db_instance" "this" {
count = var.create_db_instance ? 1 : 0
identifier = "${local.envname}-database"
engine = "postgres"
engine_version = var.db_engine_version
instance_class = var.db_instance_class
allocated_storage = 100
username = var.db_username
password = var.db_password
port = var.db_port
publicly_accessible = var.db_public_access
vpc_security_group_ids = [aws_security_group.db.id]
db_subnet_group_name = aws_db_subnet_group.this.name
allow_major_version_upgrade = true
auto_minor_version_upgrade = true
maintenance_window = "Mon:00:00-Mon:03:00"
snapshot_identifier = var.db_snapshot_migration
copy_tags_to_snapshot = true
skip_final_snapshot = true
backup_retention_period = 0
backup_window = "03:00-06:00"
enabled_cloudwatch_logs_exports = ["postgresql", "upgrade"]
deletion_protection = false
delete_automated_backups = false
tags = merge(
var.tags,
{
"Name" = format("%s-database", local.envname)
},
)
}
resource "aws_db_subnet_group" "this" {
name = local.envname
subnet_ids = local.db_subnet_ids
tags = merge(
var.tags,
{
"Name" = format("%s", local.envname)
},
)
}