-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec2.tf
67 lines (54 loc) · 1.57 KB
/
ec2.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
58
59
60
61
62
63
64
65
66
67
data "aws_ami" "amazon_linux" {
most_recent = true
filter {
name = "owner-alias"
values = ["amazon"]
}
filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
}
resource "tls_private_key" "lab" {
algorithm = "RSA"
rsa_bits = "2048"
}
resource "local_file" "key" {
content = "${tls_private_key.lab.private_key_pem}"
filename = "${path.module}/instance.pem"
}
resource "aws_key_pair" "lab" {
key_name = "aws-route-lab"
public_key = "${tls_private_key.lab.public_key_openssh}"
}
resource "aws_instance" "a" {
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.a.id}"]
subnet_id = "${aws_subnet.a.id}"
key_name = "${aws_key_pair.lab.key_name}"
# Do I need these?
source_dest_check = false # might be required for the gateway to receive traffic that doesn't match its IP.
associate_public_ip_address = true
tags {
Name = "lab-instance-a"
Lab = "aws-route-lab"
}
}
resource "aws_instance" "b" {
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.b.id}"]
subnet_id = "${aws_subnet.b.id}"
key_name = "${aws_key_pair.lab.key_name}"
#network_interface {
#
#}
# Do I need these?
source_dest_check = false # might be required for the gateway to receive traffic that doesn't match its IP.
associate_public_ip_address = true
tags {
Name = "lab-instance-b"
Lab = "aws-route-lab"
}
}