-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.tf
More file actions
29 lines (23 loc) · 763 Bytes
/
instance.tf
File metadata and controls
29 lines (23 loc) · 763 Bytes
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
resource "aws_instance" "first_instance" {
ami = "${var.ami["instance_ami"]}"
instance_type = "${var.ami["instance_type"]}"
count = "1"
subnet_id = "${aws_subnet.Public_Subnet1.id}"
key_name = "my_key"
associate_public_ip_address = true
vpc_security_group_ids = ["${aws_security_group.allow-ssh-and-egress.id}",]
//public_dns = cannot be set
provisioner "remote-exec" {
inline = [
"sudo apt update && sudo apt install nginx -y",
]
connection {
type = "ssh"
user = "ubuntu"
private_key = "${file("~/.ssh/my_key.pem")}"
}
}
}
output "addresses" {
value = ["${aws_instance.first_instance.public_dns}", "${aws_instance.first_instance.associate_public_ip_address}" ]
}