Créer une politique incluse

Vous pouvez créer une politique incluse intégrée à un utilisateur ou un groupe. Les politiques incluses sont ainsi appliquées à cet utilisateur ou à tous les utilisateurs appartenant à ce groupe.

Créer une politique incluse avec OSC CLI

Créer une politique incluse intégrée à un utilisateur

Voir l’exemple de commande PutUserPolicy dans la documentation de l’API EIM.

Créer une politique incluse intégrée à un groupe

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

The PutUserGroupPolicy command creates or updates an inline policy included in a specified group.
The policy is automatically applied to all the users of the group after its creation.

Request sample
$ osc-cli api PutUserGroupPolicy --profile "default" \
    --PolicyDocument '"{\"Statement\": [ {\"Effect\": \"Allow\", \"Action\": [\"*\"], \"Resource\": [\"*\"]} ]}"' \
    --PolicyName "example-usergroup-policy" \
    --UserGroupName "example-usergroup" \
    --UserGroupPath "/example/"

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

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

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

  • PolicyName: The name of the policy.

  • UserGroupName: The name of the group.

  • UserGroupPath: (optional) The path to the group. If not specified, it is set to a slash (/).

The PutUserGroupPolicy command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Créer une politique incluse avec oapi-cli

Créer une politique incluse intégrée à un groupe

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

The PutUserGroupPolicy command creates or updates an inline policy included in a specified group.
The policy is automatically applied to all the users of the group after its creation.

Request sample
$ oapi-cli --profile "default" PutUserGroupPolicy \
    --PolicyDocument --jsonstr-file "policy.json" \
    --PolicyName "example-usergroup-policy" \
    --UserGroupName "example-usergroup" \
    --UserGroupPath "/example/"

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

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

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

  • PolicyName: The name of the policy.

  • UserGroupName: The name of the group.

  • UserGroupPath: (optional) The path to the group. If not specified, it is set to a slash (/).

The PutUserGroupPolicy command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Créer une politique incluse avec AWS CLI

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

Créer une politique incluse intégrée à un utilisateur

Pour créer une nouvelle politique incluse intégrée à un utilisateur, utilisez la commande put-user-policy en suivant cette syntaxe :

Exemple de requête
$ aws iam put-user-policy \
    --profile YOUR_PROFILE \
    --user-name Jane \
    --policy-name AdminAccess \
    --policy-document file://policy \
    --endpoint https://eim.eu-west-2.outscale.com

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

La nouvelle politique incluse est intégrée à l’utilisateur spécifié.

Créer une politique incluse intégrée à un groupe

Pour créer une nouvelle politique incluse intégrée à un groupe, utilisez la commande put-group-policy en suivant cette syntaxe :

Exemple de requête
$ aws iam put-group-policy \
    --profile YOUR_PROFILE \
    --group-name Admin \
    --policy-name AdminAccess \
    --policy-document file://policy \
    --endpoint https://eim.eu-west-2.outscale.com

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

La nouvelle politique incluse est intégrée au groupe spécifié.

Pages connexes

Méthodes API correspondantes

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.