|
| 1 | +############################################################################## |
| 2 | +# Input Variables |
| 3 | +############################################################################## |
| 4 | + |
| 5 | +variable "ibmcloud_api_key" { |
| 6 | + type = string |
| 7 | + description = "The IBM Cloud api token" |
| 8 | + sensitive = true |
| 9 | +} |
| 10 | + |
| 11 | +variable "prefix" { |
| 12 | + type = string |
| 13 | + description = "Prefix for name of all resource created by this example" |
| 14 | + default = "base-ocp-std" |
| 15 | + validation { |
| 16 | + error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." |
| 17 | + condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +variable "region" { |
| 22 | + type = string |
| 23 | + description = "Region where resources are created" |
| 24 | + default = "eu-gb" |
| 25 | +} |
| 26 | + |
| 27 | +variable "resource_group" { |
| 28 | + type = string |
| 29 | + description = "An existing resource group name to use for this example, if unset a new resource group will be created" |
| 30 | + default = null |
| 31 | +} |
| 32 | + |
| 33 | +variable "resource_tags" { |
| 34 | + type = list(string) |
| 35 | + description = "Optional list of tags to be added to created resources" |
| 36 | + default = [] |
| 37 | +} |
| 38 | + |
| 39 | +variable "ocp_version" { |
| 40 | + type = string |
| 41 | + description = "Version of the OCP cluster to provision" |
| 42 | + default = null |
| 43 | +} |
| 44 | + |
| 45 | +############################################################################## |
| 46 | +# VPC variables |
| 47 | +############################################################################## |
| 48 | + |
| 49 | +variable "vpc_name" { |
| 50 | + type = string |
| 51 | + description = "Name of the VPC" |
| 52 | + default = "management" |
| 53 | +} |
| 54 | + |
| 55 | +variable "public_gateway" { |
| 56 | + description = "Create a public gateway in any of the three zones with `true`." |
| 57 | + type = object({ |
| 58 | + zone-1 = optional(bool) |
| 59 | + zone-2 = optional(bool) |
| 60 | + zone-3 = optional(bool) |
| 61 | + }) |
| 62 | + default = { |
| 63 | + zone-1 = true |
| 64 | + zone-2 = false |
| 65 | + zone-3 = false |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +variable "addresses" { |
| 70 | + description = "OPTIONAL - IP range that will be defined for the VPC for a certain location. Use only with manual address prefixes" |
| 71 | + type = object({ |
| 72 | + zone-1 = optional(list(string)) |
| 73 | + zone-2 = optional(list(string)) |
| 74 | + zone-3 = optional(list(string)) |
| 75 | + }) |
| 76 | + default = { |
| 77 | + zone-1 = ["10.10.10.0/24"] |
| 78 | + zone-2 = ["10.20.10.0/24"] |
| 79 | + zone-3 = ["10.30.10.0/24"] |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +variable "subnets" { |
| 84 | + description = "List of subnets for the vpc. For each item in each array, a subnet will be created. Items can be either CIDR blocks or total ipv4 addressess. Public gateways will be enabled only in zones where a gateway has been created" |
| 85 | + type = object({ |
| 86 | + zone-1 = list(object({ |
| 87 | + acl_name = string |
| 88 | + name = string |
| 89 | + cidr = string |
| 90 | + public_gateway = optional(bool) |
| 91 | + })) |
| 92 | + zone-2 = list(object({ |
| 93 | + acl_name = string |
| 94 | + name = string |
| 95 | + cidr = string |
| 96 | + public_gateway = optional(bool) |
| 97 | + })) |
| 98 | + zone-3 = list(object({ |
| 99 | + acl_name = string |
| 100 | + name = string |
| 101 | + cidr = string |
| 102 | + public_gateway = optional(bool) |
| 103 | + })) |
| 104 | + }) |
| 105 | + |
| 106 | + default = { |
| 107 | + zone-1 = [ |
| 108 | + { |
| 109 | + acl_name = "vpc-acl" |
| 110 | + name = "zone-1" |
| 111 | + cidr = "10.10.10.0/24" |
| 112 | + } |
| 113 | + ], |
| 114 | + zone-2 = [ |
| 115 | + { |
| 116 | + acl_name = "vpc-acl" |
| 117 | + name = "zone-2" |
| 118 | + cidr = "10.20.10.0/24" |
| 119 | + } |
| 120 | + ], |
| 121 | + zone-3 = [ |
| 122 | + { |
| 123 | + acl_name = "vpc-acl" |
| 124 | + name = "zone-3" |
| 125 | + cidr = "10.30.10.0/24" |
| 126 | + } |
| 127 | + ] |
| 128 | + } |
| 129 | +} |
| 130 | + |
| 131 | +variable "worker_pools" { |
| 132 | + type = list(object({ |
| 133 | + subnet_prefix = string |
| 134 | + pool_name = string |
| 135 | + machine_type = string |
| 136 | + workers_per_zone = number |
| 137 | + resource_group_id = optional(string) |
| 138 | + labels = optional(map(string)) |
| 139 | + })) |
| 140 | + description = "List of worker pools." |
| 141 | + default = [ |
| 142 | + { |
| 143 | + subnet_prefix = "zone-1" |
| 144 | + pool_name = "default" # ibm_container_vpc_cluster automatically names standard pool "standard" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) |
| 145 | + machine_type = "bx2.4x16" |
| 146 | + workers_per_zone = 2 |
| 147 | + }, |
| 148 | + { |
| 149 | + subnet_prefix = "zone-2" |
| 150 | + pool_name = "zone-2" |
| 151 | + machine_type = "bx2.4x16" |
| 152 | + workers_per_zone = 2 |
| 153 | + }, |
| 154 | + { |
| 155 | + subnet_prefix = "zone-3" |
| 156 | + pool_name = "zone-3" |
| 157 | + machine_type = "bx2.4x16" |
| 158 | + workers_per_zone = 2 |
| 159 | + } |
| 160 | + ] |
| 161 | +} |
| 162 | + |
| 163 | +variable "worker_pools_taints" { |
| 164 | + type = map(list(object({ key = string, value = string, effect = string }))) |
| 165 | + description = "Map of lists containing node taints by node-pool name" |
| 166 | + |
| 167 | + default = { |
| 168 | + all = [] |
| 169 | + default = [] |
| 170 | + zone-2 = [{ |
| 171 | + key = "dedicated" |
| 172 | + value = "zone-2" |
| 173 | + effect = "NoExecute" |
| 174 | + }] |
| 175 | + zone-3 = [{ |
| 176 | + key = "dedicated" |
| 177 | + value = "zone-3" |
| 178 | + effect = "NoExecute" |
| 179 | + }] |
| 180 | + } |
| 181 | +} |
| 182 | + |
| 183 | +############################################################################## |
0 commit comments