resourceID 欄位可讓您更靈活地命名具有使用者指定資源 ID 的 Google Cloud資源。您可以使用 Config Connector 資源中的 resourceID 欄位,在相同命名空間內的不同專案、資料夾、組織或父項資源下,定義多個相同類型的 Config Connector 資源,並使用相同的 Google Cloud資源名稱。 Google Cloud 資源名稱也不受 Kubernetes 物件名稱的命名慣例限制。此外,resourceID 欄位可讓您取得具有服務產生資源 ID 的 Google Cloud 資源。
apiVersion:resourcemanager.cnrm.cloud.google.com/v1beta1kind:Foldermetadata:annotations:cnrm.cloud.google.com/organization-id:ORG_ID# Remove the deletion-policy annotation if it is safe to delete the# folder when the resource is deleted from your cluster.cnrm.cloud.google.com/deletion-policy:"abandon"name:folder-sample-for-acquisitionspec:resourceID:ACQUIRED_FOLDER_IDdisplayName:ACQUIRED_FOLDER_DISPLAY_NAME
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eresourceID\u003c/code\u003e field in Config Connector allows you to explicitly specify the resource ID of a Google Cloud resource, offering flexibility in naming.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003eresourceID\u003c/code\u003e, you can manage multiple Config Connector resources with the same Google Cloud resource name across different projects, folders, or organizations within a namespace.\u003c/p\u003e\n"],["\u003cp\u003eResource IDs can be user-specified, defined by the user, or service-generated, determined by the service during resource creation.\u003c/p\u003e\n"],["\u003cp\u003eSpecifying \u003ccode\u003eresourceID\u003c/code\u003e enables both the creation of new resources and the acquisition of existing ones, with the system attempting acquisition if the resource has a service-generated ID.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003eresourceID\u003c/code\u003e provides flexibility, it can also lead to conflicts with multiple resources sharing the same name in a namespace, requiring manual conflict resolution.\u003c/p\u003e\n"]]],[],null,["# Managing resources with the resourceID field\n============================================\n\n*** ** * ** ***\n\nThis page explains how to manage resources with the `resourceID` field.\n\nConfig Connector lets you explicitly specify the [resource\nID](/apis/design/resource_names#resource_id) of a Google Cloud\nresource using the immutable but optional *`resourceID` field* to create or\nacquire the resource. \"Immutable, but optional\" means that you can choose to\nspecify or not specify the `resourceID` field, but you can't make any changes to\nthe value of the `resourceID` field after applying the manifest to your cluster.\n\nThe `resourceID` field increases the flexibility of naming a Google Cloud\nresource that has a\n[user-specified resource ID](#types_of_resource_ids). Using the `resourceID`\nfield in your Config Connector resources, you can define multiple\nConfig Connector resources of the same kind with the same Google Cloud\nresource name under different projects, folders, organizations or parent\nresources within the same namespace. The Google Cloud resource name is\nalso not restricted by the\n[naming convention](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names)\nof a Kubernetes object name. In addition, the `resourceID` field enables the\nacquisition of a Google Cloud resource that has a [service-generated\nresource ID](#types_of_resource_ids).\n\nConfig Connector makes the namespace the \"owner\" of a resource to prevent it\nfrom being taken by another owner. However, if you are using the `resourceID` field,\nthere can be multiple resources with the same Google Cloud resource name,\ncreated under the same namespace. These resources create conflicts that Config Connector\ncannot [manage](/config-connector/docs/concepts/managing-conflicts). You need to\nresolve any conflicts manually.\n\nTypes of resource IDs\n---------------------\n\nIn Config Connector, resource IDs can be *user-specified* or\n*service-generated*.\n\nUser-specified resource IDs\n: A resource ID that is determined, specified, and passed in by the user before\n the resource creation. You can create or acquire a resource that has a\n user-specified resource ID with the `resourceID` field.\n\nService-generated resource IDs\n: A resource ID that is generated by the service during the resource creation.\n It can be retrieved by the user after the resource is successfully created. You\n can acquire a resource that has a service-generated resource ID with the\n `resourceID` field. Leave the field unspecified if you want to create a new\n resource that has a service-generated resource ID. See the list of [Resources with a service-generated resource\n ID](/config-connector/docs/how-to/managing-deleting-resources#service-generated-resource-id).\n\nSpecifying the resourceID field\n-------------------------------\n\nYou can specify the `resourceID` field in the resource's `spec`.\n\nThe following manifest describes how to specify the `resourceID` field for a\nPub/Sub topic. The name of the Config Connector resource is\n`pubsub-topic-sample` and the name of the Pub/Sub topic is\n`pubsub-topic-id`. \n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubTopic\n metadata:\n name: pubsub-topic-sample\n spec:\n resourceID: pubsub-topic-id\n\nCreating a resource with the resourceID field\n---------------------------------------------\n\n| **Note:** When you manage a Google Cloud resource with the `resourceID` field, if the resource has a service-generated resource ID, Config Connector assumes the resource already exists and tries to acquire the resource.\n\n### Creating a BigQuery dataset\n\nIn this example, you create a new BigQuery dataset using\nConfig Connector with the `resourceID` field. The value of the `resourceID`\nfield should follow the\n[naming convention for the `datasetId` field](https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets#datasetreference)\nof the BigQuery dataset.\n\n1. Copy the following contents into a file named `bigquery-dataset.yaml`.\n\n apiVersion: bigquery.cnrm.cloud.google.com/v1beta1\n kind: BigQueryDataset\n metadata:\n name: bigquerydataset-sample-for-creation\n spec:\n resourceID: bigquerydataset_sample_with_resourceid\n defaultTableExpirationMs: 3600000\n description: \"BigQuery Dataset Sample with the ResourceID Field\"\n friendlyName: bigquerydataset-sample-with-resourceid\n location: US\n\n2. Apply the YAML file to your cluster.\n\n ```\n kubectl apply --namespace CC_NAMESPACE -f bigquery-dataset.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n3. Use `kubectl describe` to see details on the dataset.\n\n ```\n kubectl describe --namespace CC_NAMESPACE bigquerydataset bigquerydataset-sample-for-creation\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n\nAcquiring a resource with the resourceID field\n----------------------------------------------\n\nWhen you manage a Google Cloud resource with the `resourceID` field,\nConfig Connector acquires the resource if:\n\n- The resource has a user-specified resource ID, and the values in the manifest and the resource name match an existing resource; Or,\n- The resource has a service-generated resource ID.\n\n### Acquiring a folder\n\nTo acquire a folder using Config Connector with the `resourceID` field, complete\nthe following steps:\n\n1. Copy the following contents into a file named `folder.yaml`.\n\n apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1\n kind: Folder\n metadata:\n annotations:\n cnrm.cloud.google.com/organization-id: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eORG_ID\u003c/span\u003e\u003c/var\u003e\n # Remove the deletion-policy annotation if it is safe to delete the\n # folder when the resource is deleted from your cluster.\n cnrm.cloud.google.com/deletion-policy: \"abandon\"\n name: folder-sample-for-acquisition\n spec:\n resourceID: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eACQUIRED_FOLDER_ID\u003c/span\u003e\u003c/var\u003e\n displayName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eACQUIRED_FOLDER_DISPLAY_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eORG_ID\u003c/var\u003e with the numeric ID for your organization.\n - \u003cvar translate=\"no\"\u003eACQUIRED_FOLDER_ID\u003c/var\u003e with the numeric ID for the folder to be acquired.\n - \u003cvar translate=\"no\"\u003eACQUIRED_FOLDER_DISPLAY_NAME\u003c/var\u003e with the display name for the folder to be acquired.\n2. Apply the YAML file to your cluster.\n\n ```\n kubectl apply --namespace CC_NAMESPACE -f folder.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n3. Use `kubectl describe` to see details on the folder.\n\n ```\n kubectl describe --namespace CC_NAMESPACE folder folder-sample-for-acquisition\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n\nWhat's next\n-----------\n\nReview the [Resource reference](/config-connector/docs/reference/resources) to\nlearn about the resources Config Connector supports."]]