Skip to content

Commit 0a9e0e7

Browse files
committed
CORS-2933: IBMCloud: Service endpoint override TF
Adding support to terraform to allow overrides of IBM Cloud service endpoints. This is a hard requirement for disconnected cluster support, to allow use of non-default endpoints for IBM Cloud services. Related: https://issues.redhat.com/browse/CORS-2933
1 parent 77a6bb5 commit 0a9e0e7

File tree

8 files changed

+64
-12
lines changed

8 files changed

+64
-12
lines changed

data/data/ibmcloud/bootstrap/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/bootstrap/ignition.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
locals {
2+
# Use the direct COS endpoint if IBM Cloud Service Endpoints are being overridden,
3+
# as public and private may not be available. The direct endpoint requires
4+
# additional IBM Cloud Account configuration, which must be configured when using
5+
# Service Endpoint overrides.
6+
cos_endpoint_type = local.endpoint_visibility == "private" ? "direct" : "public"
7+
}
8+
19
############################################
210
# COS bucket
311
############################################
412

513
resource "ibm_cos_bucket" "bootstrap_ignition" {
614
bucket_name = "${local.prefix}-bootstrap-ignition"
15+
endpoint_type = local.cos_endpoint_type
716
resource_instance_id = var.cos_resource_instance_crn
817
region_location = var.ibmcloud_region
918
storage_class = "smart"
@@ -16,9 +25,10 @@ resource "ibm_cos_bucket" "bootstrap_ignition" {
1625
resource "ibm_cos_bucket_object" "bootstrap_ignition" {
1726
bucket_crn = ibm_cos_bucket.bootstrap_ignition.crn
1827
bucket_location = ibm_cos_bucket.bootstrap_ignition.region_location
19-
key = "bootstrap.ign"
2028
content_file = var.ignition_bootstrap_file
29+
endpoint_type = local.cos_endpoint_type
2130
etag = filemd5(var.ignition_bootstrap_file)
31+
key = "bootstrap.ign"
2232
}
2333

2434
############################################

data/data/ibmcloud/master/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/network/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/network/image/main.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
locals {
2-
prefix = var.cluster_id
2+
# Use the direct COS endpoint if IBM Cloud Service Endpoints are being overridden,
3+
# as public and private may not be available. The direct endpoint requires
4+
# additional IBM Cloud Account configuration, which must be configured when using
5+
# Service Endpoint overrides.
6+
cos_endpoint_type = var.endpoint_visibility == "private" ? "direct" : "public"
7+
prefix = var.cluster_id
38
}
49

510
resource "ibm_cos_bucket" "images" {
6-
bucket_name = "${local.prefix}-vsi-image"
11+
bucket_name = "${local.prefix}-vsi-image"
12+
# Use the direct COS endpoint if IBM Cloud Service endpoints are being overridden,
13+
# as public and private may not be available. Direct requires additional IBM Cloud
14+
# Account configuration
15+
endpoint_type = local.cos_endpoint_type
716
resource_instance_id = var.cos_resource_instance_crn
817
region_location = var.region
918
storage_class = "smart"
@@ -13,6 +22,7 @@ resource "ibm_cos_bucket_object" "file" {
1322
bucket_crn = ibm_cos_bucket.images.crn
1423
bucket_location = ibm_cos_bucket.images.region_location
1524
content_file = var.image_filepath
25+
endpoint_type = local.cos_endpoint_type
1626
key = basename(var.image_filepath)
1727
}
1828

data/data/ibmcloud/network/image/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ variable "tags" {
2525
variable "cos_resource_instance_crn" {
2626
type = string
2727
}
28+
29+
variable "endpoint_visibility" {
30+
type = string
31+
}

data/data/ibmcloud/network/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module "image" {
4848
resource_group_id = local.resource_group_id
4949
tags = local.tags
5050
cos_resource_instance_crn = ibm_resource_instance.cos.crn
51+
endpoint_visibility = local.endpoint_visibility
5152
}
5253

5354
############################################

data/data/ibmcloud/variables-ibmcloud.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ variable "ibmcloud_image_filepath" {
5555
# Top-level module variables (optional)
5656
#######################################
5757

58+
variable "ibmcloud_endpoints_json_file" {
59+
type = string
60+
description = "JSON file containing IBM Cloud service endpoints"
61+
default = ""
62+
}
63+
5864
variable "ibmcloud_preexisting_vpc" {
5965
type = bool
6066
description = "Specifies whether an existing VPC should be used or a new one created for installation."

0 commit comments

Comments
 (0)