Skip to content

Commit 3d4b1bc

Browse files
author
Md Anam Raihan
committed
add worker pool example
1 parent 7f9e360 commit 3d4b1bc

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

examples/worker_pool/main.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
########################################################################################################################
2+
# Resource Group
3+
########################################################################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.4.0"
8+
# if an existing resource group is not set (null) create a new one using prefix
9+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
10+
existing_resource_group_name = var.resource_group
11+
}
12+
13+
14+
module "worker_pools" {
15+
source = "../../modules/worker-pool"
16+
resource_group_id = module.resource_group.resource_group_id
17+
cluster_id = var.cluster_id
18+
worker_pools = var.worker_pools
19+
vpc_subnets = var.vpc_subnets
20+
vpc_id = var.vpc_id
21+
}

examples/worker_pool/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
5+
#output "myoutput" {
6+
# description = "Description of my output"
7+
# value = "value"
8+
# depends_on = [<some resource>]
9+
#}
10+
11+
##############################################################################

examples/worker_pool/provider.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
########################################################################################################################
2+
# Terraform providers
3+
########################################################################################################################
4+
5+
provider "ibm" {
6+
ibmcloud_api_key = var.ibmcloud_api_key
7+
region = var.region
8+
visibility = "public"
9+
}

examples/worker_pool/variables.tf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
########################################################################################################################
2+
# Input Variables
3+
########################################################################################################################
4+
5+
variable "ibmcloud_api_key" {
6+
type = string
7+
description = "The IBM Cloud api key"
8+
sensitive = true
9+
}
10+
11+
variable "prefix" {
12+
type = string
13+
description = "Prefix for name of all resource created by this example"
14+
validation {
15+
error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
16+
condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
17+
}
18+
}
19+
20+
variable "region" {
21+
type = string
22+
description = "Region where resources are created"
23+
}
24+
25+
variable "resource_group" {
26+
type = string
27+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
28+
default = null
29+
}
30+
31+
variable "cluster_id" {
32+
type = string
33+
description = "The ID of the cluster"
34+
}
35+
36+
variable "worker_pools" {
37+
type = list(object({
38+
subnet_prefix = optional(string)
39+
vpc_subnets = optional(list(object({
40+
id = string
41+
zone = string
42+
cidr_block = string
43+
})))
44+
pool_name = string
45+
machine_type = string
46+
workers_per_zone = number
47+
resource_group_id = optional(string)
48+
operating_system = string
49+
labels = optional(map(string))
50+
minSize = optional(number)
51+
secondary_storage = optional(string)
52+
maxSize = optional(number)
53+
enableAutoscaling = optional(bool)
54+
boot_volume_encryption_kms_config = optional(object({
55+
crk = string
56+
kms_instance_id = string
57+
kms_account_id = optional(string)
58+
}))
59+
additional_security_group_ids = optional(list(string))
60+
}))
61+
description = "List of worker pools"
62+
}
63+
64+
variable "vpc_subnets" {
65+
type = map(list(object({
66+
id = string
67+
zone = string
68+
cidr_block = string
69+
})))
70+
description = "Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster is created."
71+
}
72+
73+
variable "vpc_id" {
74+
type = string
75+
description = "ID of the VPC instance where this cluster is provisioned."
76+
}
77+

examples/worker_pool/version.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_version = ">= 1.9.0"
3+
4+
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
5+
# module's version.tf (basic and add_rules_to_sg), and 1 example that will always use the latest provider version (advanced, fscloud and multiple mzr).
6+
required_providers {
7+
ibm = {
8+
source = "ibm-cloud/ibm"
9+
version = ">= 1.78.2"
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)