-
Notifications
You must be signed in to change notification settings - Fork 38
/
main.tf
83 lines (66 loc) · 1.9 KB
/
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
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
provider "ibm" {
region = var.region
ibmcloud_api_key = var.ibmcloud_api_key
ibmcloud_timeout = var.ibmcloud_timeout
}
locals {
BASENAME = "${var.prefix}vpc-pubpriv"
user_data_frontend = <<EOF
#!/bin/bash
apt-get update
apt-get install -y nginx
echo "I am the frontend server" > /var/www/html/index.html
service nginx start
EOF
user_data_backend = <<EOF
#!/bin/bash
apt-get update
apt-get install -y nginx
echo "I am the backend server" > /var/www/html/index.html
service nginx start
EOF
}
data "ibm_is_image" "os" {
name = var.image_name
}
module "vpc_pub_priv" {
source = "../tfmodule"
basename = local.BASENAME
vpc_name = var.vpc_name
resource_group_name = var.resource_group_name
ssh_key_name = var.ssh_key_name
zone = var.zone
backend_pgw = var.backend_pgw
profile = var.profile
ibm_is_image_id = data.ibm_is_image.os.id
maintenance = var.maintenance
frontend_user_data = local.user_data_frontend
backend_user_data = local.user_data_backend
}
locals {
bastion_ip = module.vpc_pub_priv.bastion_floating_ip_address
}
output "BASTION_IP_ADDRESS" {
value = local.bastion_ip
}
output "sshbastion" {
value = "ssh root@${local.bastion_ip}"
}
output "sshfrontend" {
value = "ssh -o ProxyJump=root@${local.bastion_ip} root@${module.vpc_pub_priv.frontend_network_interface_address}"
}
output "FRONT_IP_ADDRESS" {
value = module.vpc_pub_priv.frontend_floating_ip_address
}
output "FRONT_NIC_IP" {
value = module.vpc_pub_priv.frontend_network_interface_address
}
output "sshbackend" {
value = "ssh -o ProxyJump=root@${local.bastion_ip} root@${module.vpc_pub_priv.backend_network_interface_address}"
}
output "BACK_IP_ADDRESS" {
value = module.vpc_pub_priv.backend_floating_ip_address
}
output "BACK_NIC_IP" {
value = module.vpc_pub_priv.backend_network_interface_address
}