Tester les modifications de stratégie de refus avec Policy Simulator
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment simuler une modification de stratégie de refus IAM à l'aide de Policy Simulator. Elle explique également comment interpréter les résultats de la simulation et comment appliquer la simulation de stratégie de refus si vous le souhaitez.
Cette fonctionnalité n'évalue l'accès qu'en fonction des stratégies de refus.
Pour savoir comment simuler d'autres types de règles, consultez les ressources suivantes :
Pour obtenir les autorisations nécessaires pour tester les modifications apportées aux stratégies de refus, demandez à votre administrateur de vous accorder le rôle IAM Administrateur des refus (roles/iam.denyAdmin) dans l'organisation.
Pour en savoir plus sur l'attribution de rôles, consultez la page Gérer l'accès aux projets, aux dossiers et aux organisations.
Sélectionnez un projet, un dossier ou une organisation.
Suivez la procédure permettant de créer une stratégie de refus, mais ne cliquez pas sur Créer après avoir saisi les détails de la stratégie de refus. Cliquez plutôt sur Tester la règle.
Simulez la modification d'une stratégie de refus :
Dans la console Google Cloud , accédez à l'onglet Refuser de la page IAM.
Sélectionnez un projet, un dossier ou une organisation.
Dans la colonne ID de la stratégie, cliquez sur l'ID de la stratégie que vous souhaitez modifier.
Cliquez sur editModifier.
Mettez à jour la stratégie de refus :
Pour modifier le nom à afficher de la règle, modifiez le champ Nom à afficher.
Pour modifier une règle de refus existante, cliquez sur la règle de refus, puis modifiez les comptes principaux de la règle, les comptes principaux soumis à des exceptions, les autorisations refusées, les autorisations d'exception ou la condition de refus.
Pour supprimer une règle de refus, recherchez la règle de refus que vous souhaitez supprimer, puis cliquez sur deleteSupprimer dans la ligne correspondante.
Pour ajouter une règle de refus, cliquez sur Ajouter une règle de refus, puis créez une règle de refus comme vous le feriez pour créer une stratégie de refus.
Lorsque vous avez terminé de mettre à jour la stratégie de refus, cliquez sur Tester les modifications.
Lorsque vous cliquez sur Tester la règle ou Tester les modifications, Policy Simulator lance la simulation et vous redirige vers la page Rapports de simulation de refus.
Vous pouvez quitter cette page sans perdre votre progression.
Attendre la fin d'une simulation
Une fois la simulation lancée, la console Google Cloud génère une notification indiquant que la simulation est en cours d'exécution.
Une fois la simulation terminée, la console Google Cloud génère une autre notification indiquant que la simulation est terminée. Lorsque vous recevez cette notification, vous pouvez afficher le rapport de simulation.
Chaque utilisateur peut avoir jusqu'à 10 simulations en cours.
Afficher un rapport de simulation
Dans la console Google Cloud , accédez à la page Rapports de simulation de refus.
Recherchez la simulation dont vous souhaitez consulter le rapport, puis cliquez sur Afficher le rapport sur la ligne correspondante.
Le rapport de simulation contient les éléments suivants :
Aperçu des détails de la simulation, y compris la stratégie simulée, l'action simulée et l'heure de la simulation.
Un bouton Afficher la règle ou Afficher les modifications de la règle, qui affiche la règle simulée au format JSON lorsque vous cliquez dessus. Si vous simulez la modification de la règle, la différence entre la règle actuelle et la règle simulée peut également s'afficher.
Une section Résultats de la simulation, qui affiche les résultats de la simulation. Pour savoir comment interpréter ces résultats, consultez Résultats de Policy Simulator.
Agir en fonction d'une simulation
Après avoir examiné un rapport de simulation, vous pouvez effectuer les actions suivantes :
Exporter les résultats de la simulation : pour exporter les résultats d'une simulation au format CSV, cliquez sur Exporter les résultats.
Lorsque vous cliquez sur ce bouton, un fichier CSV contenant les rapports de simulation est téléchargé sur votre ordinateur.
Appliquer la simulation de modification de stratégie : pour appliquer la stratégie ou la modification de stratégie simulée, cliquez sur Définir la stratégie.
Lorsque vous cliquez sur ce bouton, la console Google Cloud définit la règle simulée.
Modifiez la modification simulée de la stratégie : pour apporter d'autres modifications à la stratégie ou à la modification de stratégie simulée, cliquez sur Modifier la stratégie.
Lorsque vous cliquez sur ce bouton, la console Google Cloud vous redirige vers l'éditeur de règles de refus.
Vous pouvez également cliquer sur Annuler pour quitter le rapport de simulation sans effectuer d'action.
Afficher l'historique des simulations
La page Rapports de simulation de refus contient un tableau listant toutes les simulations que vous avez effectuées au cours des 14 derniers jours. Cette liste est propre à chaque utilisateur et ne peut pas être partagée.
Pour afficher la page Rapports de simulation de refus :
Dans la console Google Cloud , accédez à l'onglet Refuser de la page IAM.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Test deny policy changes with Policy Simulator\n\n| **Preview**\n|\n|\n| This 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 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\n\u003cbr /\u003e\n\nThis page describes how to simulate a change to an IAM [deny\npolicy](/iam/docs/deny-overview) using Policy Simulator. It also explains how to\ninterpret the results of the simulation, and how to apply the simulated deny\npolicy if you choose to.\n\nThis feature only evaluates access based on deny policies.\n\nTo learn how to simulate other types of policies, see the following:\n\n- [Test organization policy changes with\n Policy Simulator](/policy-intelligence/docs/test-organization-policies)\n- [Test principal access boundary policy changes with\n Policy Simulator](/policy-intelligence/docs/simulate-pab-policies)\n- [Test role changes with Policy Simulator](/policy-intelligence/docs/simulate-iam-policies)\n\nBefore you begin\n----------------\n\n-\n\n\n Enable the Policy Simulator and Identity and Access Management APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=policysimulator.googleapis.com,iam.googleapis.com)\n- Optional: Learn [how\n Policy Simulator for deny policies works](/policy-intelligence/docs/deny-simulator-overview).\n\n### Required roles\n\n\nTo get the permissions that\nyou need to test changes to deny policies,\n\nask your administrator to grant you the\n\n\n[Deny Admin](/iam/docs/roles-permissions/iam#iam.denyAdmin) (`roles/iam.denyAdmin`)\nIAM role on the organization.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nSimulate a change to a deny policy\n----------------------------------\n\nSimulating a deny policy involves the following steps:\n\n1. [Starting the simulation](#start-simulation)\n2. [Waiting for the simulation to finish](#wait)\n3. [Viewing the simulation report](#view-report)\n4. [Taking action based on the simulation](#take-action)\n\n### Start a simulation\n\nYou can start a simulation in the following ways:\n\n- Simulate a new deny policy:\n\n 1. In the Google Cloud console, go to the **Deny** tab on the **IAM** page.\n\n [Go\n to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam/deny?supportedpurview=project,folder,organizationId)\n 1. Select a project, folder, or organization.\n 2. Follow the steps to [create a deny policy](/iam/docs/deny-access#create-deny-policy), but don't click **Create** after entering the deny policy details. Instead, click **Test policy**.\n- Simulate an edit to a deny policy:\n\n 1. In the Google Cloud console, go to the **Deny** tab on the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam/deny?supportedpurview=project,folder,organizationId)\n 2. Select a project, folder, or organization.\n\n 3. In the **Policy ID** column, click the ID of the policy that you want to\n edit.\n\n 4. Click edit **Edit**.\n\n 5. Update the deny policy:\n\n - To change the policy display name, edit the **Display name** field.\n - To edit an existing deny rule, click the deny rule, and then modify the rule's principals, exception principals, denied permissions, exception permissions, or denial condition.\n - To remove a deny rule, find the deny rule that you want to delete, and then click delete **Delete** in that row.\n - To add a deny rule, click **Add deny rule** , and then create a deny rule like you do when you [create a deny policy](/iam/docs/deny-access#create-deny-policy).\n 6. When you're done updating the deny policy, click **Test changes**.\n\nWhen you click **Test policy** or **Test changes** , Policy Simulator\nstarts the simulation and redirects you to the **Deny simulation reports** page.\nYou can navigate away from this page without losing progress.\n\n### Wait for a simulation to complete\n\nAfter you start a simulation, the Google Cloud console generates a notification\nthat the simulation is running.\n\nAfter the simulation finishes, the Google Cloud console generates another\nnotification that the simulation is complete. When you receive this notification,\nyou can [view the simulation report](#view-report).\n\nEach user can have up to 10 in-progress simulations.\n\n### View a simulation report\n\n1. In the Google Cloud console, go to the **Deny simulation reports** page.\n\n [Go to Deny simulation reports](https://console.cloud.google.com/iam-admin/iam/deny/simulation-reports/)\n2. Find the simulation whose report you want to view, then click **View report** in\n that row.\n\nThe simulation report contains the following:\n\n- An overview of the simulation details, including the simulated policy, the simulated action, and the simulation time.\n- A **View policy** or **View policy changes** button, which, when clicked, displays the simulated policy in JSON format. If you're simulating the policy change, then it might also display the difference between the current policy and the simulated policy.\n- A **Replay results** section, which displays the results of the simulation. To learn how to interpret these results, see [Policy Simulator\n results](/policy-intelligence/docs/deny-simulator-overview#review-results).\n\nTake action based on a simulation\n---------------------------------\n\nAfter reviewing a simulation report, you can take the following actions:\n\n- **Export the simulation results** : To export the results of a simulation as a\n CSV file, click **Export results**.\n\n When you click this button, a CSV file with the simulation reports is\n downloaded to your computer.\n- **Apply the simulated policy change** : To apply the simulated policy or policy\n change, click **Set policy**.\n\n When you click this button, the Google Cloud console sets the simulated\n policy.\n- **Edit the simulated change to the policy** : To make further changes to the\n simulated policy or policy change, click **Modify policy**.\n\n When you click this button, the Google Cloud console redirects you to the\n deny policy editor.\n\nAlternatively, you can click **Cancel** to leave the simulation report without\ntaking any action.\n\nView simulation history\n-----------------------\n\nThe **Deny simulation reports** page contains a table listing all of the simulations\nthat you've run over the past 14 days. This list is unique to each user and\ncan't be shared.\n\nTo view the **Deny simulation reports** page, do the following:\n\n1. In the Google Cloud console, go to the **Deny** tab on the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam/deny?supportedpurview=project,folder,organizationId)\n2. Select the project, folder, or organization that you want to view simulations\n for.\n\n3. Click schedule **Simulation history**.\n\nFor each simulation, the page lists the policy that the simulation is for, the\ndate that you started the simulation, and the status of the simulation.\n\nSimulations can have the following statuses:\n\n- **In progress**: The simulation is running, but hasn't completed yet. You can have up to 10 in-progress simulations.\n- **Completed**: The simulation is complete.\n- **Error**: The simulation couldn't be completed due to an error.\n\nWhat's next\n-----------\n\n- [Test organization policy changes with\n Policy Simulator](/policy-intelligence/docs/test-organization-policies)\n- [Test role changes with Policy Simulator](/policy-intelligence/docs/simulate-iam-policies)"]]