put_group_policy ( $group_name, $policy_name, $policy_document, $opt )

Adds (or updates) a policy document associated with the specified group. 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 group, 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 PutGroupPolicy. 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

$group_name

string

Required

Name of the group to associate the policy with. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: [\w+=,.@-]*]

$policy_name

string

Required

Name of the policy document. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: [\w+=,.@-]*]

$policy_document

string

Required

The policy document. [Constraints: The value must be between 1 and 131072 characters, and must match the following regular expression pattern: [\u0009\u000A\u000D\u0020-\u00FF]+]

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Set a group policy.

// Instantiate the class
$iam = new AmazonIAM();

// Generate the group policy
$policy = new CFPolicy($iam, array(
	'Statement' => array(
		array(
			'Effect' => 'Allow',
			'Action' => '*',
			'Resource' => '*'
		)
	)
));

// Set the group policy
$response = $iam->put_group_policy('abcd_group', 'group-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

public function put_group_policy($group_name, $policy_name, $policy_document, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['GroupName'] = $group_name;
    $opt['PolicyName'] = $policy_name;
    $opt['PolicyDocument'] = $policy_document;
    
    return $this->authenticate('PutGroupPolicy', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback