-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_server.tf
54 lines (44 loc) · 1.43 KB
/
db_server.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
data "aws_ami" "arm_db" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
# Canonical
owners = ["099720109477"]
}
resource "aws_instance" "db_server" {
ami = var.db_ami == "" ? data.aws_ami.arm_db.id : var.db_ami
instance_type = var.db_inst_type
subnet_id = module.vpc.private_subnets[0]
vpc_security_group_ids = [module.db_security_group.security_group_id,
module.bastion_access_security_group.security_group_id,
module.updates_security_group.security_group_id]
key_name = var.key_pair_name
iam_instance_profile = aws_iam_instance_profile.s3_backup.name
associate_public_ip_address = false
user_data = var.install_httpd ? file("${path.module}/scripts/init-script.sh") : null
root_block_device {
volume_size = 40
}
tags = {
Name = "bravo-db"
}
}
resource "aws_ebs_volume" "db_data" {
availability_zone = data.aws_availability_zones.available.names[0]
type = "io2"
iops = 3000
size = var.db_volume_size
}
resource "aws_volume_attachment" "db_data_attach" {
count = length(aws_instance.app_server)
# Will be auto-renamed nvme1n1
device_name = "/dev/sdh"
volume_id = aws_ebs_volume.db_data.id
instance_id = aws_instance.db_server.id
}