-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy path851401-gaurav nailwal.tf.txt
98 lines (62 loc) · 1.53 KB
/
851401-gaurav nailwal.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# template for running a 2 tier arc
# stateless app
VARIABLES :
variables "aws_access_key"{}
variables "aws_secret_key"{}
connection {
type = "ssh"
port = 22
user = "ec2_user"
private_key = "put private key"
}
resources "aws_instance" "my_instance"{
ami = "put ami id"
instance = "t2.micro"
}
resources "aws_instance" "my_instance"{
ami = "put ami id"
instance = "t2.micro"
}
resources "route" "rout"{
route = 10.0.2.1
}
resources "subnet" "sub"{
subnet = 10.0.2.1/24
}
resources "gateway" "gat"{
gateway =10.0.2.1
}
resource "aws_key_pair" "kp"{
key_name= "aws_key"
private_key = "${file("path of the file")}"
}
resource "aws_elb" "load balancer"{
name = "test_elb"
instance = ["$(instance1)","$(indtance2)"]
security_group = ["$(aws_security_group.elb_security_group.id)"]
}
resource "aws_security_group" "grp"{
"here we define the aws security group"
}
resource "elb_security_group" "elb-grp"{
id = "elbsecid"
}
provider "aws"{
aws_access_key = "${var.aws_access_key}"
aws_secret_key = "${var.aws_secret_key}"
aws_region = "region of your choice"
}
provisioner:{
script = [
here we put the path to that script that installs apache .the script contain following command
apt-get update
apt-get install apache2
service apache2 start
]
}
Shell command:
$export TF_VAR_aws_access_key = "access key"
$export TF_VAR_aws_secret_key = "secret key"
terraform init
terraform plan
terraform apply