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(this, 'User', 'johnsmith'); group = iam.Group(self, "MyGroup") # or Group.fromGroupArn(this, '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 usingaddManagedPolicy(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.
See [IAM and AWS STS quotas, name requirements, and character limits] (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entities) for quota of managed policies attached to an IAM 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:
- 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 tree node.
- 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 aFn.importValue()
) and the referenced group has apath
(likearn:...:group/AdminGroup/NetworkAdmin
), thegroupName
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 thepath
in order to resolve the correct group resource.
- classmethod from_group_name(scope, id, group_name)
Import an existing group by given name (with path).
This method has same caveats of
fromGroupArn
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool