-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy path850799-Adarsh.tf
61 lines (45 loc) · 1.03 KB
/
850799-Adarsh.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
provider "aws" {
region = "${var.region}"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
resource "aws_instance" "example" {
ami = $(lookup(var.ami_id, var.region))
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
#Provisioners
provisioner "remote-exec" {
inline = [
"sudo amazon-linux install nginx1.2",
"sudo system start nginx"
]
}
connection{
user = "aws_instance"
host = "${aws_instance.example.id}"
}
}
#Variables.tf
variable "region" {
default = "us-east-1"
}
variable "access_key" {
default = "yyyyyyyyyy"
}
variable "secret_key" {
default = "xxxxxxxxx"
}
variable "ami_id" {
type = "map"
default = {
us-east-1 = "ami-xxxxxxxxx"
ud-west-2 = "ami-yyyyyyyyy"
us-central-1 = "ami-zzzzzzzzz"
}
}
variable "instance_type" {
default = "t2.micro"
}
variable "key_name" {
default = "ec2-example"
}