-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
38 lines (33 loc) · 873 Bytes
/
main.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
resource "aws_key_pair" "key_pair" {
key_name = "key_pair_${var.formation_name}"
public_key = file(var.public_key_file)
tags = {
DoNotDelete = "true"
}
lifecycle {
create_before_destroy = true
}
}
module "infra_formation" {
count = var.user_number
source = "./module"
user_number = tostring(count.index)
instance_names = var.instance_names
ami = var.image
ami_owner = var.image_owner
public_key = aws_key_pair.key_pair.key_name
}
resource "local_file" "ip" {
filename = "formation_${formatdate("DD_MM_YY",timestamp())}.csv"
content = local.content
depends_on = [
module.infra_formation
]
}
locals {
ip_list = [for k, v in module.infra_formation : module.infra_formation[k].ips]
content = "User;${join(";", var.instance_names)}\n${join("\n", local.ip_list)}"
}
output "test" {
value = local.content
}