Der Support für Cloud Deployment Manager endet am 31. Dezember 2025. Wenn Sie derzeit Deployment Manager verwenden, müssen Sie bis zum 31. Dezember 2025 zu Infrastructure Manager oder einer alternativen Bereitstellungstechnologie migrieren, damit Ihre Dienste ohne Unterbrechung weiterlaufen.
setIamPolicy-Aktion durch einen unterstützten Ressourcentyp ersetzen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Das Feature „Aktionen” ist ein Alphafeature, das die Reihe von API-Methoden erweitert, die Deployment Manager aufrufen kann. Da dieses Feature nicht unterstützt wird, empfehlen wir Ihnen, Ihre bestehende Nutzung von Aktionen zu unterstützten Alternativen zu migrieren. Die häufig verwendete Aktion storage.buckets.setIamPolicy entspricht dem vorhandenen Ressourcentyp virtual.buckets.iamMemberBinding von Deployment Manager, durch den Sie die Aktion ersetzen können.
Bereitstellung von storage.buckets.setIamPolicy zu virtual.buckets.iamMemberBinding migrieren
Die Ressource virtual.buckets.iamMemberBinding ist eine virtuelle Ressource, die eine IAM-Richtlinienbindung (Identity and Access Management) darstellt. Der vollständige Typ ist gcp-types/storage-v1:virtual.buckets.iamMemberBinding.
virtual.buckets.iamMemberBinding hat eine benutzerdefinierte Implementierung der CRUD-Vorgänge (Erstellen, Lesen, Aktualisieren und Löschen) aus dem Deployment Manager-Backend. Sie ruft eine ähnliche Methode wie die von der Aktion storage.buckets.setIamPolicy aufgerufene Methode auf. Sie wird jedoch als normale Ressource anstelle einer Aktion modelliert und folgt demselben Lebenszyklus wie ein normaler Ressourcentyp.
Um Ihre Bereitstellung zu migrieren, ersetzen Sie in allen Konfigurationsdateien für die Bereitstellung die Nutzung der Aktion storage.buckets.setIamPolicy durch die Ressource virtual.buckets.iamMemberBinding. Wenn Sie mehrere Bindungen haben, benötigen Sie möglicherweise mehrere Ressourcen, um dieselbe Logik für diese zu implementieren. Der virtuelle Typ ersetzt keine vorhandenen Bindungen für eine Ressource, sondern patcht die neuen Bindungen.
Nutzungsbeispiele für die manuelle Migration
Informationen zur manuellen Migration finden Sie in den folgenden Nutzungsbeispielen. In bestimmten Fällen, z. B. bei der Anwendung mehrerer IAM-Bindungen, müssen Sie der Ressource iamMemberBinding möglicherweise metadata.dependsOn oder Verweise auf andere Ressourcen hinzufügen, um Situationen wie Race-Bedingungen zu vermeiden.
YAML und Jinja
Das folgende Beispiel zeigt, wie die Aktion setIamPolicy in einer YAML-Konfigurationsdatei verwendet wird. Dieser Ansatz wird nicht unterstützt. Er sollte durch die Verwendung der virtuellen Ressource iamMemberBinding ersetzt werden:
-name:patch-iam-policyaction:gcp-types/storage-v1:storage.buckets.setIamPolicyproperties:bucket:policy:# existing policy, e.g. from a getIamPolicyActiongcpIamPolicyPatch:add:
Im folgenden Beispiel wird die empfohlene Verwendung der virtuellen Ressource iamMemberBinding in einer YAML- und Jinja-Vorlage gezeigt:
Das folgende Beispiel zeigt, wie die Aktion setIamPolicy in einer Python-Vorlage verwendet wird. Dieser Ansatz wird nicht unterstützt. Er sollte durch die Verwendung der virtuellen Ressource iamMemberBinding ersetzt werden:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[[["\u003cp\u003eThe Actions feature in Deployment Manager is an unsupported alpha feature, and migrating away from its usage is recommended.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003estorage.buckets.setIamPolicy\u003c/code\u003e Action, a commonly used method, should be replaced with the supported \u003ccode\u003evirtual.buckets.iamMemberBinding\u003c/code\u003e resource.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003evirtual.buckets.iamMemberBinding\u003c/code\u003e is a virtual resource that represents an IAM policy binding and functions as a regular resource type within Deployment Manager.\u003c/p\u003e\n"],["\u003cp\u003eMigrating from the \u003ccode\u003estorage.buckets.setIamPolicy\u003c/code\u003e Action to the \u003ccode\u003evirtual.buckets.iamMemberBinding\u003c/code\u003e resource requires updating deployment configuration files to replace the Action with the resource, with examples of both YAML and Python provided.\u003c/p\u003e\n"]]],[],null,["# Replacing the setIamPolicy Action with a supported resource type\n\nThe [Actions feature](/deployment-manager/docs/migrations/actions) is an alpha\nfeature that expands the range of API methods that Deployment Manager can\ncall. Because this feature is unsupported, we recommend that you\n[migrate your existing usage](/deployment-manager/docs/migrations/actions#migrating)\nof Actions to supported alternatives. The commonly-used Action\n`storage.buckets.setIamPolicy` corresponds to an existing Deployment Manager\nresource type, `virtual.buckets.iamMemberBinding`, which you can use to replace\nit.\n\nMigrating your deployment from `storage.buckets.setIamPolicy` to `virtual.buckets.iamMemberBinding`\n===================================================================================================\n\nThe `virtual.buckets.iamMemberBinding` resource is a virtual resource that\nrepresents an Identity and Access Management (IAM) policy binding. Its full type is\n`gcp-types/storage-v1:virtual.buckets.iamMemberBinding`.\n\n`virtual.buckets.iamMemberBinding` has a custom implementation of the create,\nread, update, and delete (CRUD) operations from the Deployment Manager\nbackend. It calls a similar method to the method called by the Action\n`storage.buckets.setIamPolicy`, but it is modeled as a normal resource instead\nof an Action, and it follows the same lifecycle as a normal resource type.\n\nTo migrate your deployment, replace your usage of the Action\n`storage.buckets.setIamPolicy` with the resource\n`virtual.buckets.iamMemberBinding` in all of your deployment configuration\nfiles. If you have multiple bindings, you might need multiple resources to\nimplement the same logic across them. The virtual type doesn't replace any\nexisting bindings on a resource, but patches the new ones in.\n\nUsage examples for migrating manually\n-------------------------------------\n\nTo complete the migration manually, refer to the following usage examples. In\ncertain cases, such as the application of multiple IAM bindings,\nyou might need to add `metadata.dependsOn` or references to other resources to\nthe `iamMemberBinding` resource to avoid situations such as race conditions. \n\n### YAML + Jinja\n\nThe following is an example of how the `setIamPolicy` Action is used in a\nYAML configuration file. This approach is unsupported, and should be replaced\nwith usage of the `iamMemberBinding` virtual resource: \n\n - name: patch-iam-policy\n action: gcp-types/storage-v1:storage.buckets.setIamPolicy\n properties:\n bucket:\n policy: # existing policy, e.g. from a getIamPolicyAction\n gcpIamPolicyPatch:\n add:\n\nThe following sample shows the recommended usage of the\n`iamMemberBinding` virtual resource in a YAML and Jinja template: \n\n {% set BUCKETNAME = \"bucket-\" + env[\"deployment\"] %}\n\n resources:\n - type: gcp-types/storage-v1:buckets\n name: {{ BUCKETNAME }}\n properties:\n location: US\n storageClass: STANDARD\n - type: gcp-types/storage-v1:virtual.buckets.iamMemberBinding\n name: test-bucket-iam\n properties:\n bucket: $(ref.{{ BUCKETNAME }}.name)\n member: projectEditor:{{ env[\"project\"] }}\n role: roles/storage.admin\n\n### Python\n\nThe following is an example of how the `setIamPolicy` Action is used in a\nPython template. This approach is unsupported, and should be replaced with\nusage of the `iamMemberBinding` virtual resource: \n\n resources.append({\n 'name': 'add-iam-policy',\n 'action': 'gcp-types/storage-v1:storage.buckets.setIamPolicy',\n 'properties': {\n 'bucket': gcs_bucket,\n 'userProject': project,\n 'policy': '$(ref.get-iam-policy)',\n 'gcpIamPolicyPatch': {\n 'add': [{\n 'roles':\n 'roles/storage.objectViewer',\n 'members': [\n 'serviceAccount:$(ref.%s.serviceAccount)' % tpu_name\n ]\n }]\n }\n }\n })\n\nThe following sample shows the recommended usage of the\n`iamMemberBinding` virtual resource in a Python template: \n\n iam_policy_resource = {\n 'name': policy_name,\n 'type': 'gcp-types/storage-v1:virtual.buckets.iamMemberBinding',\n 'properties':\n {\n 'bucket': '$(ref.{}.name)'.format(context.env['name']),\n 'role': role['role'],\n 'member': member,\n }\n }\n\nYou can find additional samples related to the\n[`gcs-bucket.py` template](https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/master/dm/templates/gcs_bucket)\nin the\n[`cloud-foundation-toolkit` repository](https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit)\non GitHub. For a detailed demonstration of the process of converting the\n`gcs-bucket.py` template from using the Action `setIamPolicy` to using the\nvirtual resource `iamMemberBinding`, refer to the\n[example conversion](https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/pull/453/files).\nYou can also find\n[usage examples](https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/master/dm/templates/gcs_bucket/examples)\nof the converted template."]]