-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2.tf
63 lines (47 loc) · 1.46 KB
/
ec2.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
62
63
variable "instancias" {
description = "Nombre de las instancias"
type = list(string)
default = ["apache"]
}
resource "aws_instance" "public_instance" {
#count = length(var.instancias)
for_each = toset(var.instancias)
ami = var.ec2_specs["ami"]
instance_type = var.ec2_specs["instance_type"]
subnet_id = aws_subnet.public_subnet.id
key_name = data.aws_key_pair.key.key_name
vpc_security_group_ids = [aws_security_group.sg_public_instance.id]
user_data = file("scripts/userdata.sh")
tags = {
"Name" = "${each.value}-${local.sufix}"
}
}
resource "aws_instance" "monitoring_instance" {
count = var.enable_monitoring == 1 ? 1 : 0
ami = var.ec2_specs["ami"]
instance_type = var.ec2_specs["instance_type"]
subnet_id = aws_subnet.public_subnet.id
key_name = data.aws_key_pair.key.key_name
vpc_security_group_ids = [aws_security_group.sg_public_instance.id]
user_data = file("scripts/userdata.sh")
tags = {
"Name" = "Monitoreo-${local.sufix}"
}
}
/*
variable "cadena" {
type = string
default = "ami-123, AMI-AAV, ami-12f"
}
variable "palabras" {
type = list(string)
default = ["hola", "como", "estan"]
}
variable "entornos" {
type = map(string)
default = {
"prod" = "10.10.0.0/16"
"dev" = "172.16.0.0/16"
}
}
*/