Listing the Versions of a Managed Policy

You can list all the existing versions of a managed policy and find out which is the default one that is applied to the EIM identities (users or groups) the policy is attached to.

Listing the Versions of a Managed Policy Using OSC CLI

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
}

Listing the Versions of a Managed Policy Using oapi-cli

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
}

Listing the Versions of a Managed Policy Using AWS CLI

Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI.

To list the versions of a managed policy, use the list-policy-versions command following this syntax:

Request sample
$ 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

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

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • policy-arn: The OUTSCALE Resource Name (ORN) of the policy.

  • endpoint: The endpoint corresponding to the Region you want to send the request to. For more information, see Installing and Configuring AWS CLI.

The list-policy-versions command returns the following elements:

  • Versions: Information about one or more policy versions. This element contains the following information:

    • CreateDate: The date and time of creation of the policy version.

    • VersionId: The ID of the policy version.

    • IsDefaultVersion: If true, the policy version is the default one.

Result sample
{
  "Versions": [
    {
      "CreateDate": "2016-06-24T09:12:44Z",
      "VersionId": "v2",
      "IsDefaultVersion": true
    },
    {
      "CreateDate": "2016-05-12T18:43:524Z",,
      "VersionId": "v1",
      "IsDefaultVersion": false
    }
  ]
}

Related Pages

Corresponding API Method

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.