generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
144 lines (135 loc) · 6.43 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
locals {
project_id = var.project_name == null ? var.existing_project_id : module.project[0].id
# tflint-ignore: terraform_unused_declarations
validate_project_name_id = (var.project_name != null && var.existing_project_id != null) || (var.project_name == null && var.existing_project_id == null) ? tobool("Please provide exactly one of var.project_name or var.existing_project_id. Passing neither or both is invalid.") : true
}
##############################################################################
# Code Engine Project
##############################################################################
module "project" {
count = var.existing_project_id != null ? 0 : 1
source = "./modules/project"
name = var.project_name
resource_group_id = var.resource_group_id
}
##############################################################################
# Code Engine App
##############################################################################
module "app" {
depends_on = [module.secret, module.config_map]
source = "./modules/app"
for_each = var.apps
project_id = local.project_id
name = each.key
image_reference = each.value.image_reference
image_secret = each.value.image_secret
image_port = each.value.image_port
run_env_variables = each.value.run_env_variables
run_volume_mounts = each.value.run_volume_mounts
managed_domain_mappings = each.value.managed_domain_mappings
run_arguments = each.value.run_arguments
run_as_user = each.value.run_as_user
run_commands = each.value.run_commands
run_service_account = each.value.run_service_account
scale_concurrency = each.value.scale_concurrency
scale_concurrency_target = each.value.scale_concurrency_target
scale_cpu_limit = each.value.scale_cpu_limit
scale_ephemeral_storage_limit = each.value.scale_ephemeral_storage_limit
scale_initial_instances = each.value.scale_initial_instances
scale_max_instances = each.value.scale_max_instances
scale_memory_limit = each.value.scale_memory_limit
scale_min_instances = each.value.scale_min_instances
scale_request_timeout = each.value.scale_request_timeout
}
##############################################################################
# Code Engine Job
##############################################################################
module "job" {
depends_on = [module.secret, module.config_map]
source = "./modules/job"
for_each = var.jobs
project_id = local.project_id
name = each.key
image_reference = each.value.image_reference
image_secret = each.value.image_secret
run_env_variables = each.value.run_env_variables
run_volume_mounts = each.value.run_volume_mounts
run_arguments = each.value.run_arguments
run_as_user = each.value.run_as_user
run_commands = each.value.run_commands
run_mode = each.value.run_mode
run_service_account = each.value.run_service_account
scale_array_spec = each.value.scale_array_spec
scale_cpu_limit = each.value.scale_cpu_limit
scale_ephemeral_storage_limit = each.value.scale_ephemeral_storage_limit
scale_max_execution_time = each.value.scale_max_execution_time
scale_memory_limit = each.value.scale_memory_limit
scale_retry_limit = each.value.scale_retry_limit
}
##############################################################################
# Code Engine Config Map
##############################################################################
module "config_map" {
source = "./modules/config_map"
for_each = var.config_maps
project_id = local.project_id
name = each.key
data = each.value.data
}
##############################################################################
# Code Engine Secret
##############################################################################
module "secret" {
source = "./modules/secret"
for_each = var.secrets
project_id = local.project_id
name = each.key
data = sensitive(each.value.data)
format = each.value.format
# Issue with provider, service_access is not supported at the moment. https://github.com/IBM-Cloud/terraform-provider-ibm/issues/5232
# service_access = each.value.service_access
}
##############################################################################
# Code Engine Build
##############################################################################
module "build" {
source = "./modules/build"
for_each = var.builds
project_id = local.project_id
name = each.key
output_image = each.value.output_image
output_secret = each.value.output_secret
source_url = each.value.source_url
strategy_type = each.value.strategy_type
source_context_dir = each.value.source_context_dir
source_revision = each.value.source_revision
source_secret = each.value.source_secret
source_type = each.value.source_type
strategy_size = each.value.strategy_size
strategy_spec_file = each.value.strategy_spec_file
timeout = each.value.timeout
}
##############################################################################
# Code Engine Domain Mapping
##############################################################################
module "domain_mapping" {
depends_on = [module.secret, module.app]
source = "./modules/domain_mapping"
for_each = var.domain_mappings
project_id = local.project_id
name = each.key
tls_secret = each.value.tls_secret
components = each.value.components
}
##############################################################################
# Code Engine Binding
##############################################################################
module "binding" {
depends_on = [module.app, module.job]
source = "./modules/binding"
for_each = var.bindings
project_id = local.project_id
prefix = each.key
secret_name = each.value.secret_name
components = each.value.components
}