You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::IAM::Group

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(name, options = {}) ⇒ Object

    Parameters:

    • name (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :name (required, String)
    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#arnString (readonly)

The Amazon Resource Name (ARN) specifying the group. For more information about ARNs and how to use them in policies, see IAM Identifiers in the IAM User Guide.

Returns:

  • (String)

    The Amazon Resource Name (ARN) specifying the group.

#create_dateTime (readonly)

The date and time, in ISO 8601 date-time format, when the group was created.

Returns:

  • (Time)

    The date and time, in [ISO 8601 date-time format][1], when the group was created.

#group_idString (readonly)

The stable and unique string identifying the group. For more information about IDs, see IAM Identifiers in the IAM User Guide.

Returns:

  • (String)

    The stable and unique string identifying the group.

#group_nameString (readonly)

The friendly name that identifies the group.

Returns:

  • (String)

    The friendly name that identifies the group.

#nameString (readonly)

Returns:

  • (String)

#pathString (readonly)

The path to the group. For more information about paths, see IAM Identifiers in the IAM User Guide.

Returns:

  • (String)

    The path to the group.

Instance Method Details

#add_user(options = {}) ⇒ Struct

Adds the specified user to the specified group.

Examples:

Request syntax example with placeholder values


group.add_user({
  user_name: "existingUserNameType", # required
})

Options Hash (options):

  • :user_name (required, String)

    The name of the user to add.

    This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#attach_policy(options = {}) ⇒ Struct

Attaches the specified managed policy to the specified IAM group.

You use this API to attach a managed policy to a group. To embed an inline policy in a group, use PutGroupPolicy.

For more information about policies, see Managed Policies and Inline Policies in the IAM User Guide.

Examples:

Request syntax example with placeholder values


group.attach_policy({
  policy_arn: "arnType", # required
})

Options Hash (options):

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#attached_policies(options = {}) ⇒ Collection<Policy>

Returns a Collection of Policy resources. No API requests are made until you call an enumerable method on the collection. Client#list_attached_group_policies will be called multiple times until every Policy has been yielded.

Examples:

Request syntax example with placeholder values


group.attached_policies({
  path_prefix: "policyPathType",
  marker: "markerType",
  max_items: 1,
})

Enumerating Policy resources.

group.attached_policies.each do |policy|
  # yields each policy
end

Enumerating Policy resources with a limit.

group.attached_policies.limit(10).each do |policy|
  # yields at most 10 attached_policies
end

Options Hash (options):

  • :path_prefix (String)

    The path prefix for filtering the results. This parameter is optional. If it is not included, it defaults to a slash (/), listing all policies.

    This parameter allows (through its regex pattern) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercased letters.

  • :marker (String)

    Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the Marker element in the response that you received to indicate where the next call should start.

  • :max_items (Integer)

    Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the IsTruncated response element is true.

    If you do not include this parameter, the number of items defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the IsTruncated response element returns true, and Marker contains a value to include in the subsequent call that tells the service where to continue from.

Returns:

See Also:

#create(options = {}) ⇒ Group

Examples:

Request syntax example with placeholder values


group.create({
  path: "pathType",
})

Basic usage

group = group.create(options)
group.name
#=> "group-name"

Options Hash (options):

  • :path (String)

    The path to the group. For more information about paths, see IAM Identifiers in the IAM User Guide.

    This parameter is optional. If it is not included, it defaults to a slash (/).

    This parameter allows (through its regex pattern) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercased letters.

Returns:

See Also:

#create_policy(options = {}) ⇒ GroupPolicy

Examples:

Request syntax example with placeholder values


group.create_policy({
  policy_name: "policyNameType", # required
  policy_document: "policyDocumentType", # required
})

Basic usage

grouppolicy = group.create_policy(options)
grouppolicy.name
#=> "grouppolicy-name"

Options Hash (options):

  • :policy_name (required, String)

    The name of the policy document.

    This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

  • :policy_document (required, String)

    The policy document.

    You must provide policies in JSON format in IAM. However, for AWS CloudFormation templates formatted in YAML, you can provide the policy in JSON or YAML format. AWS CloudFormation always converts a YAML policy to JSON format before submitting it to IAM.

    The regex pattern used to validate this parameter is a string of characters consisting of the following:

    • Any printable ASCII character ranging from the space character (\u0020) through the end of the ASCII character range

    • The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)

    • The special characters tab (\u0009), line feed (\u000A), and carriage return (\u000D)

Returns:

See Also:

#deleteStruct

Deletes the specified IAM group. The group must not contain any users or have any attached policies.

Examples:

Request syntax example with placeholder values


group.delete()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#detach_policy(options = {}) ⇒ Struct

Removes the specified managed policy from the specified IAM group.

A group can also have inline policies embedded with it. To delete an inline policy, use the DeleteGroupPolicy API. For information about policies, see Managed Policies and Inline Policies in the IAM User Guide.

Examples:

Request syntax example with placeholder values


group.detach_policy({
  policy_arn: "arnType", # required
})

Options Hash (options):

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#policies(options = {}) ⇒ Collection<GroupPolicy>

Returns a Collection of Aws::IAM::GroupPolicy resources. No API requests are made until you call an enumerable method on the collection. Client#list_group_policies will be called multiple times until every Aws::IAM::GroupPolicy has been yielded.

Examples:

Request syntax example with placeholder values


group.policies({
  marker: "markerType",
  max_items: 1,
})

Enumerating Aws::IAM::GroupPolicy resources.

group.policies.each do |grouppolicy|
  # yields each grouppolicy
end

Enumerating Aws::IAM::GroupPolicy resources with a limit.

group.policies.limit(10).each do |grouppolicy|
  # yields at most 10 policies
end

Options Hash (options):

  • :marker (String)

    Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the Marker element in the response that you received to indicate where the next call should start.

  • :max_items (Integer)

    Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the IsTruncated response element is true.

    If you do not include this parameter, the number of items defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the IsTruncated response element returns true, and Marker contains a value to include in the subsequent call that tells the service where to continue from.

Returns:

See Also:

#policy(name) ⇒ GroupPolicy

Parameters:

Returns:

See Also:

#remove_user(options = {}) ⇒ Struct

Removes the specified user from the specified group.

Examples:

Request syntax example with placeholder values


group.remove_user({
  user_name: "existingUserNameType", # required
})

Options Hash (options):

  • :user_name (required, String)

    The name of the user to remove.

    This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#update(options = {}) ⇒ Group

Examples:

Request syntax example with placeholder values


group.update({
  new_path: "pathType",
  new_group_name: "groupNameType",
})

Basic usage

group = group.update(options)
group.name
#=> "group-name"

Options Hash (options):

  • :new_path (String)

    New path for the IAM group. Only include this if changing the group\'s path.

    This parameter allows (through its regex pattern) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercased letters.

  • :new_group_name (String)

    New name for the IAM group. Only include this if changing the group\'s name.

    IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both \"MyResource\" and \"myresource\".

Returns:

See Also:

#users(options = {}) ⇒ Collection<User>

Returns a Collection of User resources. No API requests are made until you call an enumerable method on the collection. Client#get_group will be called multiple times until every User has been yielded.

Examples:

Request syntax example with placeholder values


group.users({
  marker: "markerType",
  max_items: 1,
})

Enumerating User resources.

group.users.each do |user|
  # yields each user
end

Enumerating User resources with a limit.

group.users.limit(10).each do |user|
  # yields at most 10 users
end

Options Hash (options):

  • :marker (String)

    Use this parameter only when paginating results and only after you receive a response indicating that the results are truncated. Set it to the value of the Marker element in the response that you received to indicate where the next call should start.

  • :max_items (Integer)

    Use this only when paginating results to indicate the maximum number of items you want in the response. If additional items exist beyond the maximum you specify, the IsTruncated response element is true.

    If you do not include this parameter, the number of items defaults to 100. Note that IAM might return fewer results, even when there are more results available. In that case, the IsTruncated response element returns true, and Marker contains a value to include in the subsequent call that tells the service where to continue from.

Returns:

  • (Collection<User>)

See Also: