-
Notifications
You must be signed in to change notification settings - Fork 8
/
aws_compute.tf
66 lines (53 loc) · 1.4 KB
/
aws_compute.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
resource "aws_key_pair" "iperf" {
key_name = "iperf-key"
public_key = "${var.EC2_SSH_PUB_KEY}"
}
resource "aws_security_group" "allow_vpn" {
name = "allow_vpn"
description = "Allow all traffic from vpn resources"
vpc_id = "${aws_vpc.aws-vpc.id}"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["${var.gcp_subnet1_cidr}"]
}
}
resource "aws_security_group" "allow_ssh" {
name = "allow_ssh"
description = "Allow ssh access from anywhere"
vpc_id = "${aws_vpc.aws-vpc.id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "iperf" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.aws_instance_type}"
subnet_id = "${aws_subnet.vpc-subnet1.id}"
key_name = "${aws_key_pair.iperf.key_name}"
associate_public_ip_address = true
vpc_security_group_ids = [
"${aws_security_group.allow_vpn.id}",
"${aws_security_group.allow_ssh.id}",
]
user_data = "${file("aws_userdata.sh")}"
tags {
Name = "${var.aws_region}-vpn-iperf"
}
}