-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy path850968-Nohar.txt
83 lines (56 loc) · 1.48 KB
/
850968-Nohar.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
#------- SOURCES -------
provider "aws" "webserver" { - 5
access_key = {}
secret_key = {}
region = "${var.region}"
ami = "${lookup[var.aws_amis , var.region]}"
type = "t2.micro"
}
data "template_file" "webserve_template" {
template = "${file("${path.module}/app_access.tpl")}"
vars {
arn = "${aws_instance.web_server.arn}"
}
}
connection {
type = "ssh"
user = "ec2-user"
private_key = "${file("${path.module}/awa_rsa")}"
}
output "public_ips"{
value = "${aws_instances.webserver.*.public_ip}"
}
#------- DATA VARS ------- datas.tfvars
var "aws_amis"{ - 7
type = "map"
amis = { Region1 : ami1,
Region2 : ami2,
Region3 : ami3 }
}
resource "aws_security_group" "web_server_sec_group" { - 17
ingress {
from_port = 0
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0"]
}
}
#------- TEMPLATE ------- app_access.tpl
template "app" {
Version : "version_number"
"Statement": [{"Effect": "Allow",
"Action": ["ec2:Descrideinstances","ec2:Describeiterations"],
"Resource": "${arn}" }]
}
#------- PROVISIONER ------- To deploy the app
provisioner "deploy_app" { - 5
source = "${path.module}/app_name"
destination = "$(file"(${path.module}/source.tf)")"
inline = [ "chmod +x ${destination}" , "${destination}" ]
}