Lister les versions d’une politique gérée

Vous pouvez lister toutes les versions existantes d’une politique gérée et retrouver quelle est celle par défaut qui est appliquée aux identités EIM (utilisateurs ou groupes) auxquelles la politique est attachée.

Lister les versions d’une politique gérée avec OSC CLI

À ce jour, cette section est disponible en anglais uniquement.

The ReadPolicyVersions command lists information about all the policy versions of a specified managed policy.

Request sample
$ osc-cli api ReadPolicyVersions --profile "default" \
    --FirstItem 1 \
    --PolicyOrn "orn:ows:idauth::012345678910:policy/example/example-user-policy" \
    --ResultsPerPage 30

This command contains the following attributes that you need to specify:

  • FirstItem: (optional) The item starting the list of policies requested.

  • PolicyOrn: The OUTSCALE Resource Name (ORN) of the policy. For more information, see Resource Identifiers.

  • ResultsPerPage: (optional) The maximum number of items that can be returned in a single response (by default, 100).

The ReadPolicyVersions command returns the following elements:

  • HasMoreItems: If true, there are more items to return using the FirstItem parameter in a new request.

  • MaxResultsLimit: Indicates maximum results defined for the operation.

  • PolicyVersions: A list of all the versions of the policy.

    • Body: The policy document, corresponding to a JSON string that contains the policy. For more information, see EIM Reference Information and EIM Policy Generator.

    • CreationDate: The date and time (UTC) at which the version was created.

    • DefaultVersion: If true, the version is the default one.

    • VersionId: The ID of the version.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "MaxResultsLimit": 30,
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "PolicyVersions": [
    {
      "VersionId": "v1",
      "DefaultVersion": true,
      "CreationDate": "2010-10-01T12:34:56.789+0000",
      "Body": "{\"Statement\": [ {\"Effect\": \"Allow\", \"Action\": [\"*\"], \"Resource\": [\"*\"]} ]}"
    }
  ],
  "HasMoreItems": true
}

Lister les versions d’une politique gérée avec oapi-cli

À ce jour, cette section est disponible en anglais uniquement.

The ReadPolicyVersions command lists information about all the policy versions of a specified managed policy.

Request sample
$ oapi-cli --profile "default" ReadPolicyVersions \
    --FirstItem 1 \
    --PolicyOrn "orn:ows:idauth::012345678910:policy/example/example-user-policy" \
    --ResultsPerPage 30

This command contains the following attributes that you need to specify:

  • FirstItem: (optional) The item starting the list of policies requested.

  • PolicyOrn: The OUTSCALE Resource Name (ORN) of the policy. For more information, see Resource Identifiers.

  • ResultsPerPage: (optional) The maximum number of items that can be returned in a single response (by default, 100).

The ReadPolicyVersions command returns the following elements:

  • HasMoreItems: If true, there are more items to return using the FirstItem parameter in a new request.

  • MaxResultsLimit: Indicates maximum results defined for the operation.

  • PolicyVersions: A list of all the versions of the policy.

    • Body: The policy document, corresponding to a JSON string that contains the policy. For more information, see EIM Reference Information and EIM Policy Generator.

    • CreationDate: The date and time (UTC) at which the version was created.

    • DefaultVersion: If true, the version is the default one.

    • VersionId: The ID of the version.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "MaxResultsLimit": 30,
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "PolicyVersions": [
    {
      "VersionId": "v1",
      "DefaultVersion": true,
      "CreationDate": "2010-10-01T12:34:56.789+0000",
      "Body": "{\"Statement\": [ {\"Effect\": \"Allow\", \"Action\": [\"*\"], \"Resource\": [\"*\"]} ]}"
    }
  ],
  "HasMoreItems": true
}

Lister les versions d’une politique gérée avec AWS CLI

Avant de commencer : Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

Pour lister les versions d’une politique gérée, utilisez la commande list-policy-versions en suivant cette syntaxe :

Exemple de requête
$ aws iam list-policy-versions \
    --profile YOUR_PROFILE \
    --policy-arn arn:aws:iam::123456789012:policy/my-policy \
    --endpoint https://eim.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • policy-arn : L’OUTSCALE Resource Name (ORN) de la politique.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI.

La commande list-policy-versions renvoie les éléments suivants :

  • Versions : Informations à propos d’une ou plusieurs versions de la politique. Cet élément contient les informations suivantes :

    • CreateDate : La date et l’heure de création de la version de la politique.

    • VersionId : L’ID de la version de la politique.

    • IsDefaultVersion : Si true, la version de la politique est celle par défaut.

Exemple de résultat
{
  "Versions": [
    {
      "CreateDate": "2016-06-24T09:12:44Z",
      "VersionId": "v2",
      "IsDefaultVersion": true
    },
    {
      "CreateDate": "2016-05-12T18:43:524Z",,
      "VersionId": "v1",
      "IsDefaultVersion": false
    }
  ]
}

Pages connexes

Méthode API correspondante

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.