Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Mengekspor dan mengimpor resource ke Config Connector
Halaman ini menjelaskan perintah config-connector export dan cara menggunakannya untuk
mengekspor resource Google Cloud ke dalam file YAML,
yang kemudian dapat Anda impor ke Config Connector. Jika Anda sudah memiliki akses ke file YAML resource,
ikuti langkah-langkah di Mengelola dan menghapus resource
untuk mendapatkan resource.
Batasan
Tidak semua resource mendukung perintah export. Untuk mendapatkan daftar resource
yang didukung, jalankan config-connector print-resources.
Dapatkan nama resource lengkap untuk resource yang ingin Anda ekspor.
Jika tidak mengetahui nama lengkap resource, Anda mungkin dapat menemukannya dengan salah satu metode berikut:
Ganti NAMESPACE dengan namespace tempat Config Connector mengelola resource.
Pastikan Config Connector mengelola resource dengan menjalankan perintah berikut:
kubectldescribeRESOURCE_TYPERESOURCE_NAME
Ganti kode berikut:
RESOURCE_TYPE: jenis resource, misalnya pubsubtopic.
RESOURCE_NAME: nama resource. Nama ini tidak harus berupa
nama resource lengkap.
Setelah Config Connector mengakuisisi resource, Anda dapat mengelola resource tersebut
dengan mengikuti langkah-langkah di Mengelola dan menghapus resource.
config-connector Kolom opsional alat CLI
Saat menjalankan perintah config-connector export, Anda dapat meneruskan
kolom opsional berikut:
--output: Jalur output opsional yang menonaktifkan output standar. Jika berupa
file, hasilnya akan berisi semua output perintah; jika berupa direktori,
direktori akan berisi file baru untuk setiap resource dalam output.
--iam-format: Menentukan jenis output resource IAM
dengan ekspor Anda. Opsi yang tersedia adalah
policy
(default), policymember,
atau none.
--filter-deleted-iam-members: Menentukan apakah akan memfilter akun utama IAM yang dihapus.
Opsinya adalah true atau false. Nilai defaultnya adalah false.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-11 UTC."],[[["\u003cp\u003eThe \u003ccode\u003econfig-connector export\u003c/code\u003e command allows users to export existing Google Cloud resources into Config Connector YAML files, enabling them to be managed within Config Connector.\u003c/p\u003e\n"],["\u003cp\u003eWhen exporting, providing the full resource name to \u003ccode\u003econfig-connector export\u003c/code\u003e generates a YAML manifest that can be imported into Config Connector.\u003c/p\u003e\n"],["\u003cp\u003eIf a resource already exists with the same name, Config Connector will take control of the resource with the provided YAML, unless there are conflicts with immutable fields.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003econfig-connector print-resources\u003c/code\u003e command can be used to display a list of resources supported by the \u003ccode\u003econfig-connector\u003c/code\u003e tool, along with their respective resource name formats.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003econfig-connector export\u003c/code\u003e command supports command line options including output location, oauth2-token, iam-format type, filter for deleted IAM members, and verbose logging.\u003c/p\u003e\n"]]],[],null,["# Export and import resources to Config Connector\n===============================================\n\n*** ** * ** ***\n\nThis page describes the `config-connector export` command and how to use it to\nexport Google Cloud resources into YAML files,\nwhich you can subsequently import into Config Connector. If you already have access to the resource's YAML file,\nfollow the steps in [Managing and deleting resources](/config-connector/docs/how-to/managing-deleting-resources)\nto acquire the resource instead.\n\nLimitations\n-----------\n\nNot all resources support the `export` command. To get a list of supported\nresources, run `config-connector print-resources`.\n| **Tip:** If a resource is not supported by `export`, but is supported by `bulk-export`, you can try [filtering an Asset Inventory export with `bulk-export`](/config-connector/docs/how-to/import-export/bulk-export#discovering_resources_to_import).\n\nBefore you begin\n----------------\n\n1. [Install the `config-connector` CLI tool](/config-connector/docs/how-to/import-export/overview).\n2. To simplify commands, set your default namespace by running the following command: \n\n ```\n kubectl config set-context --current --namespace NAMESPACE_NAME\n ```\n Replace \u003cvar translate=\"no\"\u003eNAMESPACE_NAME\u003c/var\u003e with your namespace name.\n3. Get the [full resource name](/iam/docs/full-resource-names) for the resource that you want to export. If you don't know the resource's full name, you might be able to find it with one of the following methods:\n - [Use Cloud Asset Inventory to search for a resource](/asset-inventory/docs/search-resources).\n - Use the `describe` or `list` command for the resource, for example `gcloud pubsub topics describe sample-topic --format \"value(name)\"`.\n - Check the resource's product documentation for a guide on getting the resource ID, for example [Getting a Cloud Key Management Service resource ID](/kms/docs/getting-resource-ids).\n\nExport a resource\n-----------------\n\nYou can use the `config-connector` CLI tool to export an existing resource into a YAML file.\n\nTo export a resource into a YAML file, run the following command: \n\n config-connector export \u003cvar translate=\"no\"\u003eRESOURCE_ID\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eRESOURCE_ID\u003c/var\u003e with the full name of the resource that you want to export.\n\nThe command outputs the resource in YAML format that can be used by Config Connector.\nThe output should resemble the following example: \n\n apiVersion: pubsub.cnrm.cloud.google.com/v1beta1\n kind: PubSubTopic\n metadata:\n annotations:\n cnrm.cloud.google.com/project-id: my-example-project\n name: sample-topic\n\nImport a resource into Config Connector\n---------------------------------------\n\nAfter you have the YAML file for the resource that you want Config Connector\nto acquire, complete the following steps:\n\n1. Pass your resource into Config Connector by running the following command:\n\n config-connector export \u003cvar translate=\"no\"\u003eRESOURCE_ID\u003c/var\u003e | kubectl apply -f - --namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e with the namespace that Config Connector\n manages resources from.\n2. Confirm that Config Connector is managing the resource by running the\n following command:\n\n kubectl describe \u003cvar translate=\"no\"\u003eRESOURCE_TYPE\u003c/var\u003e \u003cvar translate=\"no\"\u003eRESOURCE_NAME\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eRESOURCE_TYPE\u003c/var\u003e: the resource type, for example `pubsubtopic`.\n - \u003cvar translate=\"no\"\u003eRESOURCE_NAME\u003c/var\u003e: the resource name. This doesn't have to be the full resource name.\n\nAfter Config Connector acquires the resource, you can manage that resource\nby following the steps in [Managing and deleting resources](/config-connector/docs/how-to/managing-deleting-resources).\n\n`config-connector` CLI tool optional fields\n-------------------------------------------\n\nWhen running the `config-connector export` command, you can pass the\nfollowing optional fields: \n\n config-connector export RESOURCE_NAME \\\n --output FILENAME \\\n --oauth2-token TOKEN \\\n --iam-format [policy | policymember | none] \\\n --filter-deleted-iam-members [true | false] \\\n --verbose\n\n- `--output`: An optional output path that disables standard output. When a file, the result contains all the command output; when a directory, the directory contains a new file for each resource in the output.\n- `--oauth2-token`: An [OAUTH2 token](/sdk/gcloud/reference/auth/application-default/print-access-token) as the Google Cloud identity. By default, `config-connector` uses the [Google Cloud CLI default credentials](/sdk/docs/authorizing).\n- `--iam-format`: Specifies the kind of IAM resources output with your export. Options are [`policy`](/config-connector/docs/reference/resource-docs/iam/iampolicy) (default), [`policymember`](/config-connector/docs/reference/resource-docs/iam/iampolicymember), or `none`.\n- `--filter-deleted-iam-members`: Specifies whether to filter out deleted IAM principals. Options are `true` or `false`. The default value is `false`.\n- `--verbose`: Enables verbose logging.\n\nWhat's next\n-----------\n\n- Read about how Config Connector [acquires existing Google Cloud resources](/config-connector/docs/how-to/managing-deleting-resources#acquiring_an_existing_resource).\n- [Learn about the resources that Config Connector supports](/config-connector/docs/reference/overview)."]]