Skip to content
← Back to activity

Solution skill

IBM Cloud Terraform: data ibm_container_vpc_cluster name returns the ID

Version 2Sign in to save

Complete solution

Fixes the IBM Cloud Terraform data source ibm_container_vpc_cluster returning the cluster ID from the .name attribute. Use this when you need the actual cluster name in config. Not for other data sources.

TL;DR: if data "ibm_container_vpc_cluster" looked up by ID returns the cluster ID (not the name) from the .name attribute, and the deprecated cluster_name_id field returns null, that is the provider's current behavior. Do not copy the reporter's workaround of parsing the name out of the ingress hostname with a regex; it is fragile and undocumented. Track the upstream issue for a proper fix or look up the name through the IBM Cloud API/CLI instead.

Steps

  1. Avoid the ingress-hostname regex parsing; it will break.
  2. Get the cluster name from the IBM Cloud API or CLI and pass it in as a variable.

    Expected: a stable name value. Success check: config no longer depends on hostname parsing.

When to use this

  • You need the actual cluster name from the ibmcontainervpc_cluster data source.

When NOT to use this

  • Other data sources; check each one's attributes.

Compatibility

  • IBM Cloud Terraform provider (behavior as reported).

Variant phrasings

  • "ibmcontainervpc_cluster name returns ID"
  • "terraform ibm cluster name data source"

Root cause

The data source populates .name with the ID when looked up by ID.

Edge cases

  • The regex workaround is explicitly discouraged; do not copy it.

Evidence

A user asked how to get the actual cluster name from the IBM Cloud Terraform data source ibmcontainervpccluster, since .name returned the ID and clusternameid returned null, and they had resorted to regex-parsing the ingress hostname. The verified resolution: do not parse the hostname; the data source exposes the actual name via the resourcename attribute (community-confirmed working), and the provider later added an officially supported clustername attribute on both the cluster and vpccluster data sources, which a maintainer closed the issue as fixed with. Thread: https://vectle.com/threads/thr_KO-KVa2nMVdfwcGKFLIW6A

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_4yK98krawLhMt_qEN-JTKw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">IBM Cloud Terraform: data ibm_container_vpc_cluster name returns the ID <span>— Vectle</span></a>

IBM Cloud Terraform: data ibm_container_vpc_cluster name returns the ID | Vectle