-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbastion-host.tf
33 lines (29 loc) · 1.01 KB
/
bastion-host.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
resource "aws_instance" "vprofile-bastion" {
ami = var.AMI
instance_type = "t2.micro"
key_name = aws_key_pair.vprofilekey.key_name
subnet_id = module.vpc.public_subnets[0]
count = var.instance_count
vpc_security_group_ids = [aws_security_group.vprofile-bastion-sg.id]
associate_public_ip_address = "true"
tags = {
Name = "vprofile-bastion"
PROJECT = "vprofile"
}
provisioner "file" {
content = templatefile("templates/db-deploy.tmpl", { rds-endpoint = aws_db_instance.vprofile-rds.address, dbuser = var.dbuser, dbpass = var.dbpass })
destination = "/tmp/vprofile-dbdeploy.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/vprofile-dbdeploy.sh",
"sudo /tmp/vprofile-dbdeploy.sh"
]
}
connection {
user = var.USER
private_key = file(var.PRIVATE_KEY)
host = self.public_ip
}
depends_on = [aws_db_instance.vprofile-rds]
}