@@ -3,8 +3,8 @@ variable "region" {
3
3
}
4
4
5
5
provider "aws" {
6
- region = " ${ var . region } "
7
- # region = "us-east-1" # Virginia
6
+ # region = "${var.region}"
7
+ region = " us-east-1" # Virginia
8
8
# region = "us-east-2" # Ohio
9
9
# region = "us-west-1" # California
10
10
# region = "us-west-2" # Oregon
@@ -23,57 +23,58 @@ provider "aws" {
23
23
}
24
24
25
25
resource "aws_instance" "ssocks" {
26
- count = 1 # number of copies to spin up - if you put 1000 here, your bill might surprise you...
27
- ami = " ${ data . aws_ami . ubuntu . id } "
28
- instance_type = " t2.micro"
29
- key_name = " ssocks_key"
26
+ count = 1 # number of copies to spin up - if you put 1000 here, your bill might surprise you...
27
+ ami = " ${ data . aws_ami . ubuntu . id } "
28
+ instance_type = " t2.micro"
29
+ key_name = " ssocks_key"
30
30
security_groups = [
31
31
" ${ aws_security_group . ssh_https . name } "
32
32
]
33
33
34
34
provisioner "remote-exec" {
35
- script = " scripts/provision.sh"
35
+ script = " scripts/provision.sh"
36
36
connection {
37
37
type = " ssh"
38
38
user = " ubuntu"
39
39
private_key = " ${ file (" ~/.ssh/ssocks_key.pem" )} "
40
+ host = self. public_ip
40
41
}
41
42
}
42
43
43
44
# Return the public dns names into a local file for later use.
44
45
provisioner "local-exec" {
45
- command = " echo ${ self . public_dns } >> public_dns.txt"
46
+ command = " echo ${ self . public_dns } >> public_dns.txt"
46
47
}
47
48
}
48
49
49
50
resource "aws_security_group" "ssh_https" {
50
- count = 1
51
- name = " ssh_https"
52
- description = " Allow all inbound traffic"
51
+ # count = 1
52
+ name = " ssh_https"
53
+ description = " Allow all inbound traffic"
53
54
54
55
ingress {
55
- from_port = 443
56
- to_port = 443
57
- protocol = " tcp"
58
- cidr_blocks = [" 0.0.0.0/0" ]
56
+ from_port = 443
57
+ to_port = 443
58
+ protocol = " tcp"
59
+ cidr_blocks = [" 0.0.0.0/0" ]
59
60
}
60
61
61
62
ingress {
62
- from_port = 22
63
- to_port = 22
64
- protocol = " tcp"
65
- cidr_blocks = [" 0.0.0.0/0" ]
63
+ from_port = 22
64
+ to_port = 22
65
+ protocol = " tcp"
66
+ cidr_blocks = [" 0.0.0.0/0" ]
66
67
}
67
68
68
69
egress {
69
- from_port = 0
70
- to_port = 65535
71
- protocol = " tcp"
72
- cidr_blocks = [" 0.0.0.0/0" ]
70
+ from_port = 0
71
+ to_port = 65535
72
+ protocol = " tcp"
73
+ cidr_blocks = [" 0.0.0.0/0" ]
73
74
}
74
75
75
- tags = {
76
- Name = " ssh_https"
76
+ tags = {
77
+ Name = " ssh_https"
77
78
}
78
79
}
79
80
@@ -90,13 +91,13 @@ data "aws_ami" "ubuntu" {
90
91
91
92
resource "null_resource" "after_cleanup" {
92
93
provisioner "local-exec" {
93
- when = " destroy"
94
- command = " rm -f public_dns.txt"
94
+ when = destroy
95
+ command = " rm -f public_dns.txt"
95
96
}
96
97
}
97
98
98
99
resource "null_resource" "before_cleanup" {
99
100
provisioner "local-exec" {
100
- command = " rm -f public_dns.txt"
101
+ command = " rm -f public_dns.txt"
101
102
}
102
103
}
0 commit comments