-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
69 lines (55 loc) · 2.5 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
data "huaweicloud_availability_zones" "zones" {
region = var.region
}
locals {
name = var.name_postfix == null ? format("%s-cluster", var.name) : format("%s-cluster-%s", var.name, var.name_postfix)
}
resource "huaweicloud_cce_cluster" "main" {
name = local.name
region = var.region
cluster_version = var.cluster_version
cluster_type = var.cluster_type
description = var.description
flavor_id = var.flavor_id
vpc_id = var.vpc_id
subnet_id = var.subnet_id
container_network_type = var.container_network_type
container_network_cidr = var.container_network_cidr
service_network_cidr = var.service_network_cidr
eni_subnet_id = var.eni_subnet_id
eni_subnet_cidr = var.eni_subnet_cidr
authentication_mode = var.authentication_mode
authenticating_proxy_ca = var.authentication_mode == "authenticating_proxy" ? var.authenticating_proxy.ca : null
authenticating_proxy_cert = var.authentication_mode == "authenticating_proxy" ? var.authenticating_proxy.cert : null
authenticating_proxy_private_key = var.authentication_mode == "authenticating_proxy" ? var.authenticating_proxy.private_key : null
##
# Use three availability zones only when using HA flavors, pattern '*.s2.*'
##
dynamic "masters" {
for_each = length(var.availability_zones) == 0 ? slice(data.huaweicloud_availability_zones.zones.names, 0, can(regex("\\.s2\\.", var.flavor_id)) ? 3 : 1) : slice(var.availability_zones, 0, can(regex("\\.s2\\.", var.flavor_id)) ? 3 : 1)
content {
availability_zone = masters.value
}
}
eip = var.cce_public ? module.eip_cce_cluster.address : null
kube_proxy_mode = var.kube_proxy_mode
extend_param = var.extend_param
delete_all = var.delete_all == "false" ? null : var.delete_all
delete_efs = var.delete_all == "false" ? var.delete.efs : null
delete_eni = var.delete_all == "false" ? var.delete.eni : null
delete_evs = var.delete_all == "false" ? var.delete.evs : null
delete_net = var.delete_all == "false" ? var.delete.net : null
delete_obs = var.delete_all == "false" ? var.delete.obs : null
delete_sfs = var.delete_all == "false" ? var.delete.obs : null
hibernate = var.hibernate
tags = var.tags
}
module "eip_cce_cluster" {
source = "cloud-labs-infra/eip/huaweicloud"
version = "1.0.0"
count = var.cce_public ? 1 : 0
name = var.name
name_postfix = var.name_postfix
eip = var.cluster_eip
tags = var.tags
}