Skip to content

Commit 099b94b

Browse files
authored
feat: added support to force all api calls made by the module to use IBM Cloud private endpoints for use cases where the runtime may not have access to the public network. This can be achieved by setting the use_private_endpoint variable to true.<br>- As part of this effort the ibmcloud_api_key input variable has been removed as an input for the module. (#442)
1 parent a005704 commit 099b94b

File tree

16 files changed

+124
-105
lines changed

16 files changed

+124
-105
lines changed

.secrets.baseline

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-04-23T04:36:25Z",
6+
"generated_at": "2024-06-14T08:51:41Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -77,16 +77,6 @@
7777
}
7878
],
7979
"results": {
80-
"README.md": [
81-
{
82-
"hashed_secret": "dce1f02ca7cc4b63ac43008b7a3ce96e702a0c24",
83-
"is_secret": false,
84-
"is_verified": false,
85-
"line_number": 49,
86-
"type": "Secret Keyword",
87-
"verified_result": null
88-
}
89-
],
9080
"ibm_catalog.json": [
9181
{
9282
"hashed_secret": "a03815a5700107eb9f0d1a9608d2fcbdc48b7f5d",

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Optionally, the module supports advanced security group management for the worke
4646
module "ocp_base" {
4747
source = "terraform-ibm-modules/base-ocp-vpc/ibm"
4848
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
49-
ibmcloud_api_key = "XXXXXXXXXXXXXXXXXXX"
5049
cluster_name = "example-cluster-name"
5150
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX"
5251
region = "us-south"
@@ -230,6 +229,9 @@ Optionally, you need the following permissions to attach Access Management tags
230229
| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source |
231230
| [ibm_container_cluster_versions.cluster_versions](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_versions) | data source |
232231
| [ibm_container_vpc_worker_pool.all_pools](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_worker_pool) | data source |
232+
| [ibm_iam_account_settings.iam_account_settings](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/iam_account_settings) | data source |
233+
| [ibm_iam_auth_token.reset_api_key_tokendata](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/iam_auth_token) | data source |
234+
| [ibm_iam_auth_token.tokendata](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/iam_auth_token) | data source |
233235
| [ibm_is_lbs.all_lbs](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/is_lbs) | data source |
234236
| [ibm_is_virtual_endpoint_gateways.all_vpes](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/is_virtual_endpoint_gateways) | data source |
235237
@@ -252,7 +254,6 @@ Optionally, you need the following permissions to attach Access Management tags
252254
| <a name="input_enable_registry_storage"></a> [enable\_registry\_storage](#input\_enable\_registry\_storage) | Set to `true` to enable IBM Cloud Object Storage for the Red Hat OpenShift internal image registry. Set to `false` only for new cluster deployments in an account that is allowlisted for this feature. | `bool` | `true` | no |
253255
| <a name="input_existing_cos_id"></a> [existing\_cos\_id](#input\_existing\_cos\_id) | The COS id of an already existing COS instance to use for OpenShift internal registry storage. Only required if 'enable\_registry\_storage' and 'use\_existing\_cos' are true | `string` | `null` | no |
254256
| <a name="input_force_delete_storage"></a> [force\_delete\_storage](#input\_force\_delete\_storage) | Flag indicating whether or not to delete attached storage when destroying the cluster - Default: false | `bool` | `false` | no |
255-
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | APIkey that's associated with the account to use, set via environment variable TF\_VAR\_ibmcloud\_api\_key | `string` | n/a | yes |
256257
| <a name="input_ignore_worker_pool_size_changes"></a> [ignore\_worker\_pool\_size\_changes](#input\_ignore\_worker\_pool\_size\_changes) | Enable if using worker autoscaling. Stops Terraform managing worker count | `bool` | `false` | no |
257258
| <a name="input_kms_config"></a> [kms\_config](#input\_kms\_config) | Use to attach a KMS instance to the cluster. If account\_id is not provided, defaults to the account in use. | <pre>object({<br> crk_id = string<br> instance_id = string<br> private_endpoint = optional(bool, true) # defaults to true<br> account_id = optional(string) # To attach KMS instance from another account<br> wait_for_apply = optional(bool, true) # defaults to true so terraform will wait until the KMS is applied to the master, ready and deployed<br> })</pre> | `null` | no |
258259
| <a name="input_manage_all_addons"></a> [manage\_all\_addons](#input\_manage\_all\_addons) | Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module will destroy any addons that were installed by other sources. | `bool` | `false` | no |
@@ -264,6 +265,7 @@ Optionally, you need the following permissions to attach Access Management tags
264265
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The Id of an existing IBM Cloud resource group where the cluster will be grouped. | `string` | n/a | yes |
265266
| <a name="input_tags"></a> [tags](#input\_tags) | Metadata labels describing this cluster deployment, i.e. test | `list(string)` | `[]` | no |
266267
| <a name="input_use_existing_cos"></a> [use\_existing\_cos](#input\_use\_existing\_cos) | Flag indicating whether or not to use an existing COS instance for OpenShift internal registry storage. Only applicable if 'enable\_registry\_storage' is true | `bool` | `false` | no |
268+
| <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Set this to true to force all api calls to use the IBM Cloud private endpoints. | `bool` | `false` | no |
267269
| <a name="input_verify_worker_network_readiness"></a> [verify\_worker\_network\_readiness](#input\_verify\_worker\_network\_readiness) | By setting this to true, a script will run kubectl commands to verify that all worker nodes can communicate successfully with the master. If the runtime does not have access to the kube cluster to run kubectl commands, this should be set to false. | `bool` | `true` | no |
268270
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | Id of the VPC instance where this cluster will be provisioned | `string` | n/a | yes |
269271
| <a name="input_vpc_subnets"></a> [vpc\_subnets](#input\_vpc\_subnets) | Metadata that describes the VPC's subnets. Obtain this information from the VPC where this cluster will be created | <pre>map(list(object({<br> id = string<br> zone = string<br> cidr_block = string<br> })))</pre> | n/a | yes |

examples/add_rules_to_sg/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ locals {
166166
module "ocp_base" {
167167
source = "../.."
168168
cluster_name = var.prefix
169-
ibmcloud_api_key = var.ibmcloud_api_key
170169
resource_group_id = module.resource_group.resource_group_id
171170
region = var.region
172171
force_delete_storage = true

examples/advanced/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ locals {
150150
module "ocp_base" {
151151
source = "../.."
152152
cluster_name = var.prefix
153-
ibmcloud_api_key = var.ibmcloud_api_key
154153
resource_group_id = module.resource_group.resource_group_id
155154
region = var.region
156155
force_delete_storage = true

examples/basic/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ locals {
6969

7070
module "ocp_base" {
7171
source = "../.."
72-
ibmcloud_api_key = var.ibmcloud_api_key
7372
resource_group_id = module.resource_group.resource_group_id
7473
region = var.region
7574
tags = var.resource_tags

examples/cross_kms_support/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ locals {
7575

7676
module "ocp_base" {
7777
source = "../.."
78-
ibmcloud_api_key = var.ibmcloud_api_key
7978
resource_group_id = module.resource_group.resource_group_id
8079
region = var.region
8180
tags = var.resource_tags

examples/custom_sg/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ module "custom_sg" {
9494

9595
module "ocp_base" {
9696
source = "../.."
97-
ibmcloud_api_key = var.ibmcloud_api_key
9897
resource_group_id = module.resource_group.resource_group_id
9998
region = var.region
10099
tags = var.resource_tags

examples/fscloud/main.tf

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,38 @@ locals {
232232
]
233233
}
234234

235+
########################################################################################################################
236+
# Security groups
237+
# Creating some security group for illustration purpose in this example.
238+
# Real-world sg would have your own rules set in the `security_group_rules` input.
239+
########################################################################################################################
240+
241+
module "custom_sg" {
242+
for_each = toset(["custom-lb-sg"])
243+
source = "terraform-ibm-modules/security-group/ibm"
244+
version = "2.6.1"
245+
add_ibm_cloud_internal_rules = false
246+
security_group_name = each.key
247+
security_group_rules = []
248+
resource_group = module.resource_group.resource_group_id
249+
vpc_id = module.vpc.vpc_id
250+
}
251+
235252
module "ocp_fscloud" {
236-
source = "../../modules/fscloud"
237-
cluster_name = var.prefix
238-
ibmcloud_api_key = var.ibmcloud_api_key
239-
resource_group_id = module.resource_group.resource_group_id
240-
region = var.region
241-
force_delete_storage = true
242-
vpc_id = module.vpc.vpc_id
243-
vpc_subnets = local.cluster_vpc_subnets
244-
existing_cos_id = module.cos_fscloud.cos_instance_id
245-
worker_pools = local.worker_pools
246-
tags = var.resource_tags
247-
access_tags = var.access_tags
248-
ocp_version = var.ocp_version
253+
source = "../../modules/fscloud"
254+
cluster_name = var.prefix
255+
resource_group_id = module.resource_group.resource_group_id
256+
region = var.region
257+
force_delete_storage = true
258+
vpc_id = module.vpc.vpc_id
259+
vpc_subnets = local.cluster_vpc_subnets
260+
existing_cos_id = module.cos_fscloud.cos_instance_id
261+
worker_pools = local.worker_pools
262+
tags = var.resource_tags
263+
access_tags = var.access_tags
264+
ocp_version = var.ocp_version
265+
additional_lb_security_group_ids = [module.custom_sg["custom-lb-sg"].security_group_id]
266+
use_private_endpoint = true
249267
kms_config = {
250268
instance_id = var.hpcs_instance_guid
251269
crk_id = local.cluster_hpcs_cluster_key_id

examples/multiple_mzr_clusters/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ module "ocp_base_cluster_1" {
123123
worker_pools_taints = local.worker_pool_taints
124124
ocp_version = var.ocp_version
125125
tags = var.resource_tags
126-
ibmcloud_api_key = var.ibmcloud_api_key
127126
}
128127

129128
module "ocp_base_cluster_2" {
@@ -138,7 +137,6 @@ module "ocp_base_cluster_2" {
138137
worker_pools_taints = local.worker_pool_taints
139138
ocp_version = var.ocp_version
140139
tags = var.resource_tags
141-
ibmcloud_api_key = var.ibmcloud_api_key
142140
}
143141

144142
########################################################################################################################

main.tf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,19 @@ resource "ibm_resource_tag" "cluster_access_tag" {
245245
# new key, and simply use the key created by this script. So hence should not face 404s anymore.
246246
# The IKS team are tracking internally https://github.ibm.com/alchemy-containers/armada-ironsides/issues/5023
247247

248+
data "ibm_iam_auth_token" "reset_api_key_tokendata" {
249+
}
250+
251+
data "ibm_iam_account_settings" "iam_account_settings" {
252+
}
253+
248254
resource "null_resource" "reset_api_key" {
249255
provisioner "local-exec" {
250-
command = "${path.module}/scripts/reset_iks_api_key.sh ${var.region} ${var.resource_group_id}"
256+
command = "${path.module}/scripts/reset_iks_api_key.sh ${var.region} ${var.resource_group_id} ${var.use_private_endpoint}"
251257
interpreter = ["/bin/bash", "-c"]
252258
environment = {
253-
IBMCLOUD_API_KEY = var.ibmcloud_api_key
259+
IAM_TOKEN = data.ibm_iam_auth_token.reset_api_key_tokendata.iam_access_token
260+
ACCOUNT_ID = data.ibm_iam_account_settings.iam_account_settings.account_id
254261
}
255262
}
256263
}
@@ -495,15 +502,20 @@ locals {
495502
lbs_associated_with_cluster = length(var.additional_lb_security_group_ids) > 0 ? [for lb in data.ibm_is_lbs.all_lbs[0].load_balancers : lb.id if strcontains(lb.name, local.cluster_id)] : []
496503
}
497504

505+
506+
data "ibm_iam_auth_token" "tokendata" {
507+
depends_on = [data.ibm_is_lbs.all_lbs]
508+
}
509+
498510
resource "null_resource" "confirm_lb_active" {
499511
count = length(var.additional_lb_security_group_ids)
500-
depends_on = [data.ibm_is_lbs.all_lbs]
512+
depends_on = [data.ibm_iam_auth_token.tokendata]
501513

502514
provisioner "local-exec" {
503-
command = "${path.module}/scripts/confirm_lb_active.sh ${var.region} ${var.resource_group_id} ${local.lbs_associated_with_cluster[count.index]}"
515+
command = "${path.module}/scripts/confirm_lb_active.sh ${var.region} ${local.lbs_associated_with_cluster[count.index]} ${var.use_private_endpoint}"
504516
interpreter = ["/bin/bash", "-c"]
505517
environment = {
506-
IBMCLOUD_API_KEY = var.ibmcloud_api_key
518+
IAM_TOKEN = data.ibm_iam_auth_token.tokendata.iam_access_token
507519
}
508520
}
509521
}

0 commit comments

Comments
 (0)