PutUserPolicy() public method

Adds or updates an inline policy document that is embedded in the specified IAM user.

An IAM user can also have a managed policy attached to it. To attach a managed policy to a user, use AttachUserPolicy. To create a new managed policy, use CreatePolicy. For information about policies, see Managed Policies and Inline Policies in the IAM User Guide.

For information about limits on the number of inline policies that you can embed in a user, see Limitations on IAM Entities in the IAM User Guide.

Because policy documents can be large, you should use POST rather than GET when calling PutUserPolicy. For general information about using the Query API with IAM, go to Making Query Requests in the IAM User Guide.

/// The request was rejected because it attempted to create resources beyond the current /// AWS account limits. The error message describes the limit exceeded. /// /// The request was rejected because the policy document was malformed. The error message /// describes the specific error. /// /// The request was rejected because it referenced an entity that does not exist. The /// error message describes the entity. /// /// The request processing has failed because of an unknown error, exception or failure. ///
public PutUserPolicy ( PutUserPolicyRequest request ) : PutUserPolicyResponse
request PutUserPolicyRequest Container for the necessary parameters to execute the PutUserPolicy service method.
return PutUserPolicyResponse
示例#1
0
        private static void AddPolicy()
        {
            var client = new AmazonIdentityManagementServiceClient();
            var policyRequest = new PutUserPolicyRequest
            {
                UserName = "******",
                PolicyName = "EC2Policy",
                PolicyDocument =
                    "{\"Version\": \"2012-10-17\",\"Statement\": [ {\"Sid\": \"Stmt1453760589829\",\"Action\": [\"ec2:DescribeInstances\"],\"Effect\": \"Allow\",\"Resource\":\"*\"}]}"
            };

            var policyResponse = client.PutUserPolicy(policyRequest);
            Console.WriteLine("Policy Added");
        }