-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
43 lines (38 loc) · 969 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
38
39
40
41
42
43
data "ibm_is_instances" "insts" {
vpc = var.vpc_id
}
locals {
workload_ip_list = flatten([for ins in data.ibm_is_instances.insts.instances :
[ins.primary_network_interface[0].primary_ipv4_address]
])
}
output "workload" {
value = local.workload_ip_list
}
resource "null_resource" "application-install" {
count = var.number_vsi_workload
connection {
type = "ssh"
user = "root"
bastion_host = var.floating_ip_address
host = local.workload_ip_list[count.index]
private_key = var.ssh_private_key
agent = false
timeout = "15m"
}
provisioner "remote-exec" {
inline = [
"apt-get update",
"apt-get install apache2 -y"
]
}
provisioner "file" {
content = <<EOT
<html>
<img src="https://raw.githubusercontent.com/IBM/infra-to-app-with-landing-zone/main/docs/header.jpg">
<h1> You did it!! </h1>
</html>
EOT
destination = "/var/www/html/index.html"
}
}