Group

class aws_cdk.aws_iam.Group(scope, id, *, group_name=None, managed_policies=None, path=None)

Bases: Resource

An IAM Group (collection of IAM users) lets you specify permissions for multiple users, which can make it easier to manage permissions for those users.

See:

https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html

ExampleMetadata:

infused

Example:

user = iam.User(self, "MyUser") # or User.fromUserName(stack, 'User', 'johnsmith');
group = iam.Group(self, "MyGroup") # or Group.fromGroupArn(stack, 'Group', 'arn:aws:iam::account-id:group/group-name');

user.add_to_group(group)
# or
group.add_user(user)
Parameters:
  • scope (Construct)

  • id (str)

  • group_name (Optional[str]) – A name for the IAM group. For valid values, see the GroupName parameter for the CreateGroup action in the IAM API Reference. If you don’t specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the group name. If you specify a name, you must specify the CAPABILITY_NAMED_IAM value to acknowledge your template’s capabilities. For more information, see Acknowledging IAM Resources in AWS CloudFormation Templates. Default: Generated by CloudFormation (recommended)

  • managed_policies (Optional[Sequence[IManagedPolicy]]) – A list of managed policies associated with this role. You can add managed policies later using addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName(policyName)). Default: - No managed policies.

  • path (Optional[str]) – The path to the group. For more information about paths, see IAM Identifiers in the IAM User Guide. Default: /

Methods

add_managed_policy(policy)

Attaches a managed policy to this group.

Parameters:

policy (IManagedPolicy) – The managed policy to attach.

Return type:

None

add_to_policy(statement)

Add to the policy of this principal.

Parameters:

statement (PolicyStatement)

Return type:

bool

add_to_principal_policy(statement)

Adds an IAM statement to the default policy.

Parameters:

statement (PolicyStatement)

Return type:

AddToPrincipalPolicyResult

add_user(user)

Adds a user to this group.

Parameters:

user (IUser)

Return type:

None

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy)

Return type:

None

attach_inline_policy(policy)

Attaches a policy to this group.

Parameters:

policy (Policy) – The policy to attach.

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

assume_role_action

When this Principal is used in an AssumeRole policy, the action to use.

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

grant_principal

The principal to grant permissions to.

group_arn

Returns the IAM Group ARN.

group_name

Returns the IAM Group Name.

node

The construct tree node associated with this construct.

policy_fragment

Return the policy fragment that identifies this principal in a Policy.

principal_account

The AWS account ID of this principal.

Can be undefined when the account is not known (for example, for service principals). Can be a Token - in that case, it’s assumed to be AWS::AccountId.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_group_arn(scope, id, group_arn)

Import an external group by ARN.

If the imported Group ARN is a Token (such as a CfnParameter.valueAsString or a Fn.importValue()) and the referenced group has a path (like arn:...:group/AdminGroup/NetworkAdmin), the groupName property will not resolve to the correct value. Instead it will resolve to the first path component. We unfortunately cannot express the correct calculation of the full path name as a CloudFormation expression. In this scenario the Group ARN should be supplied without the path in order to resolve the correct group resource.

Parameters:
  • scope (Construct) – construct scope.

  • id (str) – construct id.

  • group_arn (str) – the ARN of the group to import (e.g. arn:aws:iam::account-id:group/group-name).

Return type:

IGroup

classmethod from_group_name(scope, id, group_name)

Import an existing group by given name (with path).

This method has same caveats of fromGroupArn

Parameters:
  • scope (Construct) – construct scope.

  • id (str) – construct id.

  • group_name (str) – the groupName (path included) of the existing group to import.

Return type:

IGroup

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any)

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct)

Return type:

bool