-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.tf
93 lines (80 loc) · 4.07 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
83
84
85
86
87
88
89
90
91
###########################################
# Account: Resource group creation...
###########################################
resource "ibm_resource_group" "group" {
count = var.resource_group_name != "" ? 0 : 1
name = "${var.basename}-group"
tags = var.tags
}
data "ibm_resource_group" "group" {
count = var.resource_group_name != "" ? 1 : 0
name = var.resource_group_name
}
locals {
resource_group_id = var.resource_group_name != "" ? data.ibm_resource_group.group.0.id : ibm_resource_group.group.0.id
resource_group_name = var.resource_group_name != "" ? data.ibm_resource_group.group.0.name : ibm_resource_group.group.0.name
# create logging and monitoring are now done by the user by hand - changes for IBM Cloud Logs, the log and metric routing.
step1_create_logging = false
step1_create_monitoring = false
}
###########################################
# Step 1: Provision Cloud services...
###########################################
module "create_services" {
count = var.step1_create_services ? 1 : 0
source = "./modules/create_services"
basename = var.basename
region = var.region
resource_group_id = local.resource_group_id
tags = var.tags
create_logging = local.step1_create_logging
create_monitoring = local.step1_create_monitoring
}
#############################################################################
#Step 2: Create a VPC and its resources...
#############################################################################
module "create_vpc" {
count = var.step2_create_vpc ? 1 : 0
source = "./modules/create_vpc"
basename = var.basename
region = var.region
resource_group_id = local.resource_group_id
resource_group_name = local.resource_group_name
image_name = var.image_name
ssh_keyname = var.ssh_keyname
is_dynamic = var.step3_is_dynamic
instance_count = var.step3_instance_count
keyprotect_guid = module.create_services.0.keyprotect_guid
keyprotect_key_type = module.create_services.0.keyprotect_key_type
keyprotect_key_id = module.create_services.0.keyprotect_key_id
keyprotect_crn = module.create_services.0.keyprotect_crn
postgresql_key = module.create_services.0.postgresql_key
postgresql_crn = module.create_services.0.postgresql_crn
cos_key = module.create_services.0.cos_key
bucket_name = module.create_services.0.bucket_name
is_scheduled = var.step3_is_scheduled
}
#############################################################################
#Step 3: Create a dedicated host group, host and an instance with encrypted volume...
#############################################################################
module "create_dedicated" {
count = var.step4_create_dedicated ? 1 : 0
source = "./modules/create_dedicated"
basename = var.basename
resource_group_id = local.resource_group_id
region = var.region
resource_group_name = local.resource_group_name
image_name = var.image_name
ssh_keyname_dedicated = var.ssh_keyname_dedicated
tags = concat(var.tags, ["dedicated"])
keyprotect_guid = module.create_services.0.keyprotect_guid
keyprotect_key_type = module.create_services.0.keyprotect_key_type
keyprotect_key_id = module.create_services.0.keyprotect_key_id
keyprotect_crn = module.create_services.0.keyprotect_crn
resize_dedicated_instance = var.step5_resize_dedicated_instance
postgresql_key = module.create_services.0.postgresql_key
postgresql_crn = module.create_services.0.postgresql_crn
cos_key = module.create_services.0.cos_key
bucket_name = module.create_services.0.bucket_name
resize_dedicated_instance_volume = var.step5_resize_dedicated_instance_volume
}