Adds (or updates) a policy document associated with the specified user. For information about policies, refer to Overview of Policies in Using AWS Identity and Access Management.
For information about limits on the number of policies you can associate with a user, see Limitations on IAM Entities in Using AWS Identity and Access Management.
Because policy documents can be large, you should use POST rather than GET when calling
PutUserPolicy
. For information about setting up signatures and authorization
through the API, go to Signing AWS API Requests in the AWS General Reference. For general
information about using the Query API with IAM, go to Making Query Requests in Using IAM.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
Name of the user to associate the policy with. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: |
|
|
Required |
Name of the policy document. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: |
|
|
Required |
The policy document. [Constraints: The value must be between 1 and 131072 characters, and must match the following regular expression pattern: |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Set a user policy.
// Instantiate the class $iam = new AmazonIAM(); // Generate the user policy $policy = new CFPolicy($iam, array( 'Statement' => array( array( 'Effect' => 'Allow', 'Action' => '*', 'Resource' => '*' ) ) )); // Set the user policy $response = $iam->put_user_policy('johndoe2', 'user-policy', $policy->get_json()); // Success? var_dump($response->isOK());Result:
bool(true)
Related Methods
Source
Method defined in services/iam.class.php | Toggle source view (9 lines) | View on GitHub