-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy path850504-Nikhil.tf.txt
76 lines (55 loc) · 1.29 KB
/
850504-Nikhil.tf.txt
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
68
69
70
71
72
73
74
75
76
provider "aws" {
access_key="aws-access_key"
secretr_key="aws-secret_key"
region="us-east-1"
}
#vpc
resource "aws_vps" "default" {
cider_block= "10.0.0.0/10"
}
#nternet gateway
resource "aws_internet_gateway" "default" {
vpc_id="$(aws_vps.default.id)"
}
#vpc gateway access
resource "aws_route" "internet_access" {
route_table_id = "$(aws_vps.default.main_route_table_id)"
destinatiopn_cidr_block = "0.0.0.0/0"
gateway_id= "$(aws_internet_gateway.default.id)"
}
#to access ELB
resource "aws_security_group" "ELB" {
name= "two_tier_arch"
vpc_id="$(aws_vps.default.id)"
ingress {
from_port = 80
to_port = 80
protocol= "tcp"
cider_block = "0.0.0.0/0"
}
egress {
from_port = 0
to_port = 0
protocol= "-1"
cider_block = "0.0.0.0/0"
}
}
resource "aws_instance" "web_server" {
connection {
user = "username"
host= "hostname"
}
}
provisioner "server" {
inline = [
"sudo -y update"
"sudo service start"
]
}
data "template file" "server" {
template= "$${username},$${public_key}"
vars{
username="local"
public_key="local_key"
}
}