This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
forked from aliyun/terraform-provider-alicloud
-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.tf
40 lines (37 loc) · 1.88 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
// If there is not specifying vpc_id, the module will launch a new vpc
resource "alicloud_vpc" "vpc" {
count = var.vpc_id == "" ? 1 : 0
cidr_block = var.vpc_cidr
}
// According to the vswitch cidr blocks to launch several vswitches
resource "alicloud_vswitch" "vswitches" {
count = length(var.vswitch_ids) > 0 ? 0 : length(var.vswitch_cidrs)
vpc_id = var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id
cidr_block = element(var.vswitch_cidrs, count.index)
availability_zone = element(var.availability_zone, count.index)
}
resource "alicloud_cs_kubernetes" "k8s" {
count = var.k8s_number
master_vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)): length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches.*.id))
worker_vswitch_ids = length(var.vswitch_ids) > 0 ? split(",", join(",", var.vswitch_ids)): length(var.vswitch_cidrs) < 1 ? [] : split(",", join(",", alicloud_vswitch.vswitches.*.id))
master_instance_types = var.master_instance_types
worker_instance_types = var.worker_instance_types
worker_number = var.worker_number
node_cidr_mask = var.node_cidr_mask
enable_ssh = var.enable_ssh
install_cloud_monitor = var.install_cloud_monitor
cpu_policy = var.cpu_policy
proxy_mode = var.proxy_mode
password = var.password
pod_cidr = var.pod_cidr
service_cidr = var.service_cidr
# version can not be defined in variables.tf. Options: 1.16.6-aliyun.1|1.14.8-aliyun.1
version = "1.16.6-aliyun.1"
dynamic "addons" {
for_each = var.cluster_addons
content {
name = lookup(addons.value, "name", var.cluster_addons)
config = lookup(addons.value, "config", var.cluster_addons)
}
}
}