You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(iam): support fromGroupName() for IAM groups (#17243)
IAM Policies and Users already support import by name. Extending same for Groups
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@@ -439,6 +439,26 @@ const user = iam.User.fromUserAttributes(this, 'MyImportedUserByAttributes', {
439
439
});
440
440
```
441
441
442
+
## Groups
443
+
444
+
An IAM user group is a collection of IAM users. User groups let you specify permissions for multiple users.
445
+
446
+
```ts
447
+
const group =newiam.Group(this, 'MyGroup');
448
+
```
449
+
450
+
To import an existing group by ARN:
451
+
452
+
```ts
453
+
const group =iam.Group.fromGroupArn(this, 'MyImportedGroupByArn', 'arn:aws:iam::account-id:group/group-name');
454
+
```
455
+
456
+
To import an existing group by name [with path](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names):
457
+
458
+
```ts
459
+
const group =iam.Group.fromGroupName(this, 'MyImportedGroupByName', 'group-name');
460
+
```
461
+
442
462
To add a user to a group (both for a new and imported user/group):
443
463
444
464
```ts
@@ -450,12 +470,11 @@ user.addToGroup(group);
450
470
group.addUser(user);
451
471
```
452
472
453
-
454
473
## Features
455
474
456
-
* Policy name uniqueness is enforced. If two policies by the same name are attached to the same
475
+
* Policy name uniqueness is enforced. If two policies by the same name are attached to the same
457
476
principal, the attachment will fail.
458
-
* Policy names are not required - the CDK logical ID will be used and ensured to be unique.
459
-
* Policies are validated during synthesis to ensure that they have actions, and that policies
477
+
* Policy names are not required - the CDK logical ID will be used and ensured to be unique.
478
+
* Policies are validated during synthesis to ensure that they have actions, and that policies
460
479
attached to IAM principals specify relevant resources, while policies attached to resources
0 commit comments