Adds the specified role to the specified instance profile. For more information about roles, go to Working with Roles. For more information about instance profiles, go to About Instance Profiles.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
Name of the instance profile to update. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: |
|
|
Required |
Name of the role to add. [Constraints: The value must be between 1 and 64 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
Test the preparation of instance profiles and roles.
// Instantiate the client $iam = new AmazonIAM(); // Role policy $role_policy = new CFPolicy($iam, array( 'Statement' => array( array( 'Effect' => 'Allow', 'Action' => '*', 'Resource' => '*' ) ) )); // Create role $response = $iam->create_role('example-role', AmazonIAM::STANDARD_EC2_ASSUME_ROLE_POLICY); var_dump($response->isOK()); // Create instance profile $response = $iam->create_instance_profile('example-profile'); var_dump($response->isOK()); // Put role policy $response = $iam->put_role_policy('example-role', 'example-role-policy', $role_policy->get_json()); var_dump($response->isOK()); // Add role to instance $response = $iam->add_role_to_instance_profile('example-profile', 'example-role'); var_dump($response->isOK());Result:
bool(true) bool(true) bool(true) bool(true)
Source
Method defined in services/iam.class.php | Toggle source view (8 lines) | View on GitHub