[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-02。"],[[["\u003cp\u003eConfig Connector enables resources to reference other resources through dependencies or links, where dependencies are required resources and links tie together independent resources.\u003c/p\u003e\n"],["\u003cp\u003eResource references are specified in the \u003ccode\u003espec\u003c/code\u003e section of a resource's YAML file, using the pattern \u003ccode\u003eresourceNameRef\u003c/code\u003e with a \u003ccode\u003ename\u003c/code\u003e field to identify the referenced resource.\u003c/p\u003e\n"],["\u003cp\u003eConfig Connector supports external references, allowing managed resources to link to unmanaged Google Cloud resources, with the format for the \u003ccode\u003eexternal\u003c/code\u003e field defined in the resource's documentation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eIAMPolicy\u003c/code\u003e, \u003ccode\u003eIAMPartialPolicy\u003c/code\u003e, and \u003ccode\u003eIAMPolicyMember\u003c/code\u003e also support external references, requiring a \u003ccode\u003ekind\u003c/code\u003e value and following specific formats listed in their documentation.\u003c/p\u003e\n"],["\u003cp\u003eConfig Connector permits resources in one namespace to reference resources in another namespace, requiring additional permissions via a RoleBinding when in namespaced-mode.\u003c/p\u003e\n"]]],[],null,["# Creating resource references\n============================\n\n*** ** * ** ***\n\nA Google Cloud resource created with Config Connector can\nreference other resources. Config Connector defines these relationships through\n*resource references*. This topic explains how to create resources with\nreferences.\n\nTypes of references\n-------------------\n\nIn Config Connector, references can be *dependencies* or *links*.\n\nDependencies\n: A dependency reference refers to an existing Google Cloud\n resource necessary for the Config Connector resource. For example, a firewall\n rule cannot exist without a network\n\nLinks\n: A link reference ties independent resources together. For example, a\n Project can be associated with a Billing Account.\n\nSpecifying resource references\n------------------------------\n\nYou specify resource references in the resource's `spec`. The field's name\nis the resource's short name followed by `Ref`. For example:\n\n- The reference to a `PubSubTopic` named `topic` is `topicRef`.\n- The reference to a `StorageBucket` named `bucket` is `bucketRef`.\n\nThe reference is an object with a single field (`name`). The resource in\n`resourceRef` is replaced with the reference's name.\n\nThe following YAML file describes a Pub/Sub `PubSubSubscription` that references\na `PubSubTopic` named `myTopic`. \n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubSubscription\n metadata:\n name: pubsubsubscription-referencing-topic\n spec:\n topicRef:\n name: myTopic\n\nPub/Sub example\n---------------\n\n### Create a PubSubTopic\n\nIn this example, you create a `PubSubSubscription` that depends on a\n`PubSubTopic`.\n\n1. Copy the following into a file named `pubsub-topic.yaml`:\n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubTopic\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eTOPIC_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eTOPIC_NAME\u003c/var\u003e with your desired `PubSubTopic` name\n\n For example, to create a topic named `myTopic` you could use the following YAML\n file: \n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubTopic\n metadata:\n name: myTopic\n\n2. Create the `PubSubTopic` with `kubectl apply`.\n\n ```\n kubectl --namespace CC_NAMESPACE apply -f pubsub-topic.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n\n### Create a PubSubSubscription\n\n1. Copy the following into a file named \\`pubsub-subscription.yaml:\n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubSubscription\n metadata:\n name: pubsubsubscription-referencing-topic\n spec:\n topicRef:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eTOPIC_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eTOPIC_NAME\u003c/var\u003e with the `PubSubTopic` name you used in step 1.\n For example, the YAML referencing the topic `myTopic` you created earlier is: \n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubSubscription\n metadata:\n name: pubsubsubscription-referencing-topic\n spec:\n topicRef:\n name: myTopic\n\n2. Create the `PubSubSubscription` with `kubectl apply`.\n\n ```\n kubectl --namespace CC_NAMESPACE apply -f pubsub-subscription.yaml \n ```\n\n Replace \u003cvar translate=\"no\"\u003eCC_NAMESPACE\u003c/var\u003e with the namespace Config Connector\n manages resources from.\n\nExternal references\n-------------------\n\n|\n| **Beta**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nConfig Connector can reference resources that it does not manage. These are\nknown as **External References** . For example, the `ComputeURLMap` below\nreferences a `BackendService` named `test-backendservice`. \n\n apiVersion: compute.cnrm.cloud.google.com/v1beta1\n kind: ComputeURLMap\n metadata:\n name: test-urlmap\n spec:\n location: global\n defaultService:\n backendServiceRef:\n external: https://www.googleapis.com/compute/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/global/backendServices/test-backendservice\n\nThe format of values accepted by `external` depends on the resource. Consult the\ndocumentation for particular resources in the [Resource\nreference](/config-connector/docs/reference/resources). You can find out what\nvalues `external` accepts by reading the descriptions of the resource's\n`external` fields.\n\n### IAMPolicy, IAMPartialPolicy and IAMPolicyMember\n\n`IAMPolicy`, `IAMPartialPolicy` and `IAMPolicyMember` also supports External\nReferences. For example, the `IAMPolicyMember` below references a `Project` with\nthe project ID `test-project`. \n\n apiVersion: iam.cnrm.cloud.google.com/v1beta1\n kind: IAMPolicyMember\n metadata:\n name: test-iampolicymember\n spec:\n member: serviceAccount:test-serviceaccount@test-project.iam.gserviceaccount.com\n role: roles/storage.admin\n resourceRef:\n kind: Project\n external: projects/test-project\n\n| **Note:** You must set values for `kind` when using external references with `IAMPolicy`, `IAMPartialPolicy` and `IAMPolicyMember`.\n\nYou can find out what format the `external` field accepts by reading the\n[reference documentation](/config-connector/docs/reference/resources). The\n[IAMPolicy](/config-connector/docs/reference/resource-docs/iam/iampolicy),\n[IAMPartialPolicy](/config-connector/docs/reference/resource-docs/iam/iampartialpolicy)\nand [IAMPolicyMember](/config-connector/docs/reference/resource-docs/iam/iampolicymember)\npages list the accepted format for all supported resources. The formats are listed\nin the \"External Reference Formats\" column of the *Supported Resources* table.\nYou can also go to an individual resource's reference page (for example,\n[PubSubTopic](/config-connector/docs/reference/resource-docs/pubsub/pubsubtopic))\nand look at the value listed in the \"IAM External Reference Format\" row of the\nresource's summary table.\n\nCross-namespace references\n--------------------------\n\nConfig Connector allows resources to reference resources in other namespaces.\nHowever, if Config Connector is installed in\n[namespaced-mode](/config-connector/docs/concepts/installation-types#namespaced),\nyou need to grant Config Connector additional permissions to allow for\ncross-namespace references.\n\nFor example, if you want to create resources in \u003cvar translate=\"no\"\u003eNAMESPACE_A\u003c/var\u003e that\nreference resources in \u003cvar translate=\"no\"\u003eNAMESPACE_B\u003c/var\u003e, you need create the following\n`RoleBinding`: \n\n apiVersion: rbac.authorization.k8s.io/v1\n kind: RoleBinding\n metadata:\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eNAMESPACE_B\u003c/span\u003e\u003c/var\u003e\n name: allow-references-from-\u003cvar translate=\"no\"\u003eNAMESPACE_A\u003c/var\u003e\n roleRef:\n apiGroup: rbac.authorization.k8s.io\n kind: ClusterRole\n name: cnrm-viewer\n subjects:\n - kind: ServiceAccount\n name: cnrm-controller-manager-\u003cvar translate=\"no\"\u003eNAMESPACE_A\u003c/var\u003e\n namespace: cnrm-system\n\nWhat's next\n-----------\n\n- Review the [Resource reference](/config-connector/docs/reference/resources) to\n learn about the resources Config Connector supports.\n\n- See how you can use a resource reference to a\n [Secret](/config-connector/docs/how-to/secrets) in your Config Connector\n cluster."]]