Skip to content

Commit 899501b

Browse files
Jordan-Williams2Jordan-Williams2
authored andcommitted
feat: onboard cloudpak 4 data
1 parent d3b4e7c commit 899501b

File tree

5 files changed

+143
-26
lines changed

5 files changed

+143
-26
lines changed

tests/resources/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The terraform code in this directory is used by the existing resource test in tests/pr_test.go

tests/resources/main.tf

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,91 @@
11
##############################################################################
2-
# SLZ VPC
2+
# Resource Group
33
##############################################################################
44

5-
module "landing_zone" {
6-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone//patterns//roks-quickstart?ref=v7.4.4"
7-
ibmcloud_api_key = var.ibmcloud_api_key
8-
region = var.region
9-
prefix = var.prefix
10-
resource_tags = var.resource_tags
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.2.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+
# VPC + Subnet + Public Gateway
15+
#
16+
# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow
17+
# all traffic ingress/egress by default.
18+
# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and
19+
# ACLs/Security Groups for network security.
20+
########################################################################################################################
21+
22+
resource "ibm_is_vpc" "vpc" {
23+
name = "${var.prefix}-vpc"
24+
resource_group = module.resource_group.resource_group_id
25+
address_prefix_management = "auto"
26+
tags = var.resource_tags
27+
}
28+
29+
resource "ibm_is_subnet" "subnet_zone_1" {
30+
name = "${var.prefix}-subnet-1"
31+
vpc = ibm_is_vpc.vpc.id
32+
resource_group = module.resource_group.resource_group_id
33+
zone = "${var.region}-1"
34+
total_ipv4_address_count = 256
35+
}
36+
37+
########################################################################################################################
38+
# OCP VPC cluster (single zone)
39+
########################################################################################################################
40+
41+
locals {
42+
cluster_vpc_subnets = {
43+
default = [
44+
{
45+
id = ibm_is_subnet.subnet_zone_1.id
46+
cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
47+
zone = ibm_is_subnet.subnet_zone_1.zone
48+
}
49+
]
50+
}
51+
52+
worker_pools = [
53+
{
54+
subnet_prefix = "default"
55+
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
56+
machine_type = "bx2.16x64"
57+
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
58+
operating_system = "REDHAT_8_64"
59+
}
60+
]
61+
}
62+
63+
module "ocp_base" {
64+
source = "terraform-ibm-modules/base-ocp-vpc/ibm"
65+
version = "3.49.0"
66+
resource_group_id = module.resource_group.resource_group_id
67+
region = var.region
68+
tags = var.resource_tags
69+
cluster_name = "${var.prefix}-cluster"
70+
force_delete_storage = true
71+
vpc_id = ibm_is_vpc.vpc.id
72+
vpc_subnets = local.cluster_vpc_subnets
73+
worker_pools = local.worker_pools
74+
access_tags = []
75+
}
76+
77+
##############################################################################
78+
# Monitoring:
79+
# - Cloud Monitoring instance
80+
##############################################################################
81+
82+
module "cloudpak_data" {
83+
source = "../../solutions/fully-configurable"
84+
ibmcloud_api_key = var.ibmcloud_api_key
85+
prefix = var.prefix
86+
region = var.region
87+
cluster_name = module.ocp_base.cluster_name
88+
cluster_rg_id = module.resource_group.resource_group_id
89+
cpd_admin_password = var.cpd_admin_password
90+
cpd_entitlement_key = var.cpd_entitlement_key
1191
}

tests/resources/outputs.tf

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,38 @@
22
# Outputs
33
##############################################################################
44

5-
output "prefix" {
6-
value = module.landing_zone.prefix
7-
description = "prefix"
8-
}
9-
105
output "region" {
116
value = var.region
127
description = "Region where SLZ ROKS Cluster is deployed."
138
}
149

15-
output "workload_cluster_id" {
16-
value = module.landing_zone.workload_cluster_id
17-
description = "workload cluster ID."
10+
output "cluster_id" {
11+
value = module.ocp_base.cluster_id
12+
description = "ID of the cluster."
13+
}
14+
15+
output "cluster_crn" {
16+
value = module.ocp_base.cluster_crn
17+
description = "CRN of the cluster."
18+
}
19+
20+
output "cluster_resource_group_id" {
21+
value = module.ocp_base.resource_group_id
22+
description = "Resource group ID of the cluster."
23+
}
24+
25+
output "cluster_name" {
26+
value = module.ocp_base.cluster_name
27+
description = "Name of the cluster."
28+
}
29+
30+
output "instance_id" {
31+
value = module.cloud_monitoring.crn
32+
description = "The cloud monitoring instance crn."
1833
}
1934

20-
output "workload_rg_id" {
21-
value = module.landing_zone.workload_rg_id
22-
description = "workload resource group ID."
35+
output "access_key" {
36+
value = module.cloud_monitoring.access_key
37+
description = "The access key of the provisioned IBM Cloud Monitoring instance."
38+
sensitive = true
2339
}

tests/resources/variables.tf

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
11
variable "ibmcloud_api_key" {
22
type = string
3-
description = "The IBM Cloud API key to deploy resources."
3+
description = "The IBM Cloud API Key."
44
sensitive = true
55
}
66

77
variable "region" {
88
type = string
9-
description = "Region to provision all resources created by this example"
9+
description = "Region to provision all resources created by this example."
1010
default = "us-south"
1111
}
1212

1313
variable "prefix" {
1414
type = string
15-
description = "Prefix to append to all resources created by this example"
16-
default = "slz-vpc"
15+
description = "Prefix to append to all resources created by this example."
16+
default = "agent-da"
1717
}
1818

1919
variable "resource_tags" {
2020
type = list(string)
21-
description = "Optional list of tags to be added to created resources"
22-
default = []
21+
description = "Optional list of tags to be added to created resources."
22+
default = ["logs-agent-ocp"]
23+
}
24+
25+
variable "resource_group" {
26+
type = string
27+
description = "The name of an existing resource group to provision resources in. If not specified, a new resource group is created with the `prefix` variable."
28+
default = null
29+
}
30+
31+
variable "cpd_admin_password" {
32+
type = string
33+
description = "The password for the Cloud Pak for Data admin user."
34+
sensitive = true
35+
default = "cpd-admin-password" # pragma: allowlist secret
36+
}
37+
38+
variable "cpd_entitlement_key" {
39+
type = string
40+
description = "The entitlement key for Cloud Pak for Data."
41+
sensitive = true
2342
}

tests/resources/version.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
12
terraform {
2-
required_version = ">= 1.0.0"
3+
required_version = ">= 1.9.0"
34
required_providers {
45
ibm = {
56
source = "ibm-cloud/ibm"
6-
version = ">= 1.49.0, < 2.0.0"
7+
version = ">= 1.76.1"
78
}
89
}
910
}

0 commit comments

Comments
 (0)