AWS - IAM Identity Center
Amazon Web Services IAM Identity Center.
IT Services · AWS - IAM Identity Center
Details
| ID | AWS - IAM Identity Center |
|---|---|
| Provider | Amazon |
| Category | IT Services |
| From Version | 5.0.0 |
| Docker Image | demisto/boto3py3:1.0.0.10221838 |
| Supported Modules | Agentix XSIAM |
README
Amazon Web Services Identity and Access Management Identity Center(IAM)
For detailed instructions about setting up authentication, see: AWS Integrations - Authentication.
Configure AWS - IAM Identity Center in Cortex
| Parameter | Description | Required |
|---|---|---|
| Role Arn | False | |
| Role Session Name | A descriptive name for the assumed role session. | False |
| AWS Default Region | True | |
| Role Session Duration | False | |
| Identity Store ID | The Identity Store ID parameter is required for API requests. It can be provided as a parameter or as an argument. If the Identity Store ID was not specified - Test failure. | False |
| Access Key | False | |
| Secret Key | False | |
| Access Key | False | |
| Secret Key | False | |
| Timeout | The time in seconds until a timeout exception is reached. You can specify just the read timeout (for example 60) or also the connect timeout followed after a comma (for example 60,10). If a connect timeout is not specified, a default of 10 seconds will be used. | False |
| Retries | The maximum number of retry attempts when connection or throttling errors are encountered. Set to 0 to disable retries. The default value is 5 and the limit is 10. Note: Increasing the number of retries will increase the execution time. | False |
| Trust any certificate (not secure) | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
aws-iam-identitycenter-create-user
Creates a new IAM Identity Center user for your AWS account.
Base Command
aws-iam-identitycenter-create-user
Input
| Argument Name | Description | Required |
|---|---|---|
| userName | The username of the user to create. | Required |
| familyName | The family name of the user to create. | Required |
| givenName | The first name of the user to create. | Required |
| userEmailAddress | The email address of the user to create. | Optional |
| displayName | The display name of the user to create. | Required |
| profileUrl | The profile URL of the user to create. | Optional |
| userEmailAddressPrimary | Is this the primary email address for the associated resource?. Possible values are: yes, no. | Optional |
| userType | The type of the user to create. | Optional |
| title | The title of the user to create. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.User.UserId | string | The user ID. |
| AWS.IAMIdentityCenter.User.IdentityStoreId | string | Identity Store ID. |
Command example
!aws-iam-identitycenter-create-user displayName="John Doe" familyName=Doe givenName=John userName=johndoe userEmailAddress=johnDoe@gmail.com
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"User": {
"IdentityStoreId": "d-9967750fbd",
"UserId": "634418e2-20c1-703e-4358-a8312472c85d"
}
}
}
}
Human Readable Output
User johndoe has been successfully created with user id 634418e2-20c1-703e-4358-a8312472c85d
IdentityStoreId UserId d-9967750fbd 634418e2-20c1-703e-4358-a8312472c85d
aws-iam-identitycenter-get-user
Retrieves information about the specified IAM user.
Base Command
aws-iam-identitycenter-get-user
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| userName | The name of the user to get information about. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.User.UserName | string | The friendly name identifying the user. |
| AWS.IAMIdentityCenter.User.UserId | string | The stable and unique string identifying the user. |
| AWS.IAMIdentityCenter.User.ExternalIds.Issuer | String | The issuer for an external identifier. |
| AWS.IAMIdentityCenter.User.ExternalIds.Id | String | The identifier issued to this resource by an external identity provider. |
| AWS.IAMIdentityCenter.User.Name.Formatted | String | Formatted version of the user’s name for display. |
| AWS.IAMIdentityCenter.User.Name.FamilyName | String | The family name of the user. |
| AWS.IAMIdentityCenter.User.Name.GivenName | String | The given name of the user. |
| AWS.IAMIdentityCenter.User.Name.MiddleName | String | The middle name of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificPrefix | String | The honorific prefix of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificSuffix | String | The honorific suffix of the user. |
| AWS.IAMIdentityCenter.User.DisplayName | String | The name of the user formatted for display when referenced. |
| AWS.IAMIdentityCenter.User.NickName | String | An alternate name for the user. |
| AWS.IAMIdentityCenter.User.ProfileUrl | String | URL associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Value | String | Email address associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Type | String | Type of email address. |
| AWS.IAMIdentityCenter.User.Emails.Primary | String | Indicates whether this is the primary email address. |
| AWS.IAMIdentityCenter.User.Addresses.StreetAddress | String | Street address. |
| AWS.IAMIdentityCenter.User.Addresses.Locality | String | Address locality. |
| AWS.IAMIdentityCenter.User.Addresses.Region | String | Region of the address. |
| AWS.IAMIdentityCenter.User.Addresses.PostalCode | String | Postal code of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Country | String | Country of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Formatted | String | Formatted version of the address for display. |
| AWS.IAMIdentityCenter.User.Addresses.Type | String | Type of address. |
| AWS.IAMIdentityCenter.User.Addresses.Primary | String | Indicates whether this is the primary address. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Value | String | Phone number associated with the user. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Type | String | Type of phone number. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Primary | String | Indicates whether this is the primary phone number. |
| AWS.IAMIdentityCenter.User.UserType | String | Type of user. |
| AWS.IAMIdentityCenter.User.Title | String | Title of the user. |
| AWS.IAMIdentityCenter.User.PreferredLanguage | String | Preferred language of the user. |
| AWS.IAMIdentityCenter.User.Locale | String | Geographical region or location of the user. |
| AWS.IAMIdentityCenter.User.Timezone | String | Time zone of the user. |
| AWS.IAMIdentityCenter.User.IdentityStoreId | String | Globally unique identifier for the identity store. |
Command example
!aws-iam-identitycenter-get-user userName=johndoe
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"User": {
"DisplayName": "John Doe",
"Emails": [
{
"Value": "johnDoe@gmail.com"
}
],
"IdentityStoreId": "d-9967750fbd",
"Name": {
"FamilyName": "Doe",
"GivenName": "John"
},
"UserId": "634418e2-20c1-703e-4358-a8312472c85d",
"UserName": "johndoe"
}
}
}
}
Human Readable Output
AWS IAM Identity Center Users
DisplayName Emails UserId UserName John Doe johnDoe@gmail.com 634418e2-20c1-703e-4358-a8312472c85d johndoe
aws-iam-identitycenter-list-users
Lists the IAM users, returns all users in the AWS account.
Base Command
aws-iam-identitycenter-list-users
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| limit | Number of results to return. Default is 50. | Optional |
| nextToken | The pagination token. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.User.UserName | string | The friendly name identifying the user. |
| AWS.IAMIdentityCenter.User.UserId | string | The stable and unique string identifying the user. |
| AWS.IAMIdentityCenter.User.ExternalIds.Issuer | String | The issuer for an external identifier. |
| AWS.IAMIdentityCenter.User.ExternalIds.Id | String | The identifier issued to this resource by an external identity provider. |
| AWS.IAMIdentityCenter.User.Name.Formatted | String | Formatted version of the user’s name for display. |
| AWS.IAMIdentityCenter.User.Name.FamilyName | String | The family name of the user. |
| AWS.IAMIdentityCenter.User.Name.GivenName | String | The given name of the user. |
| AWS.IAMIdentityCenter.User.Name.MiddleName | String | The middle name of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificPrefix | String | The honorific prefix of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificSuffix | String | The honorific suffix of the user. |
| AWS.IAMIdentityCenter.User.DisplayName | String | The name of the user formatted for display when referenced. |
| AWS.IAMIdentityCenter.User.NickName | String | An alternate name for the user. |
| AWS.IAMIdentityCenter.User.ProfileUrl | String | URL associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Value | String | Email address associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Type | String | Type of email address. |
| AWS.IAMIdentityCenter.User.Emails.Primary | String | Indicates whether this is the primary email address. |
| AWS.IAMIdentityCenter.User.Addresses.StreetAddress | String | Street address. |
| AWS.IAMIdentityCenter.User.Addresses.Locality | String | Address locality. |
| AWS.IAMIdentityCenter.User.Addresses.Region | String | Region of the address. |
| AWS.IAMIdentityCenter.User.Addresses.PostalCode | String | Postal code of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Country | String | Country of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Formatted | String | Formatted version of the address for display. |
| AWS.IAMIdentityCenter.User.Addresses.Type | String | Type of address. |
| AWS.IAMIdentityCenter.User.Addresses.Primary | String | Indicates whether this is the primary address. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Value | String | Phone number associated with the user. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Type | String | Type of phone number. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Primary | String | Indicates whether this is the primary phone number. |
| AWS.IAMIdentityCenter.User.UserType | String | Type of user. |
| AWS.IAMIdentityCenter.User.Title | String | Title of the user. |
| AWS.IAMIdentityCenter.User.PreferredLanguage | String | Preferred language of the user. |
| AWS.IAMIdentityCenter.User.Locale | String | Geographical region or location of the user. |
| AWS.IAMIdentityCenter.User.Timezone | String | Time zone of the user. |
| AWS.IAMIdentityCenter.User.IdentityStoreId | String | Globally unique identifier for the identity store. |
| AWS.IAMIdentityCenter.UserNextToken | String | Pagination token. |
Command example
#### Context Example
```json
{
"AWS": {
"IAMIdentityCenter": {
"User": [
{
"DisplayName": "John Doe",
"Emails": [
{
"Value": "johnDoe@gmail.com"
}
],
"IdentityStoreId": "d-9967750fbd",
"Name": {
"FamilyName": "Doe",
"GivenName": "John"
},
"UserId": "8374c852-10e1-70e2-8996-5b0d54bf8ccd",
"UserName": "johndoe"
},
],
"UserNextToken": null
}
}
}
Human Readable Output
AWS IAM Identity Center Users
DisplayName Emails UserId UserName johndoe johnDoe@gmail.com 8374c852-10e1-70e2-8996-5b0d54bf8ccd johndoe
aws-iam-identitycenter-list-groups
Lists all the IAM groups in the AWS account.
Base Command
aws-iam-identitycenter-list-groups
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| limit | Number of results to return. Default is 50. | Optional |
| nextToken | The pagination token. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.Group.GroupId | String | The identifier for a group in the identity store. |
| AWS.IAMIdentityCenter.Group.DisplayName | String | The display name value for the group. |
| AWS.IAMIdentityCenter.Group.ExternalIds.Issuer | String | The issuer for an external identifier. |
| AWS.IAMIdentityCenter.Group.ExternalIds.Id | String | The identifier issued to this resource by an external identity provider. |
| AWS.IAMIdentityCenter.Group.Description | String | A description of the specified group. |
| AWS.IAMIdentityCenter.Group.IdentityStoreId | String | The globally unique identifier for the identity store. |
| AWS.IAMIdentityCenter.GroupNextToken | String | The pagination token used for the ListUsers and ListGroups API operations. |
Command example
#### Context Example
```json
{
"AWS": {
"IAMIdentityCenter": {
"Group": [
{
"DisplayName": "new",
"GroupId": "53142802-e001-7004-9134-9e6e4e1e10c0",
"IdentityStoreId": "d-9967750fbd"
}
],
"GroupNextToken": null
}
}
}
Human Readable Output
AWS IAM Identity Center Groups
DisplayName GroupId new 53142802-e001-7004-9134-9e6e4e1e10c0
aws-iam-identitycenter-list-groups-for-user
Lists the IAM Identity Center groups that the specified IAM user belongs to.
Base Command
aws-iam-identitycenter-list-groups-for-user
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| limit | Number of results to return. Default is 50. | Optional |
| nextToken | The pagination token. | Optional |
| userName | The name of the user to list groups for. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.User.UserId | string | User ID. |
| AWS.IAMIdentityCenter.User.GroupMemeberships.MembershipId | string | The friendly name that identifies the group. |
| AWS.IAMIdentityCenter.User.GroupMemeberships.GroupId | string | The stable and unique string identifying the group. |
Command example
!aws-iam-identitycenter-list-groups-for-user userName=johndoe
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"GroupsUserNextToken":null,
"User":{
"GroupMemberships":[
{
"GroupId":"a3948882-5051-7090-524c-c8c850bf1919",
"MembershipId":"e374b872-9011-7000-c847-55fdcc299204",
}
],
"UserId":"c3f438a2-e041-7033-75e8-63eb8c64b0e4"
}
}
}
}
Human Readable Output
AWS IAM Identity Center Groups
GroupID MembershipID UserID a3948882-5051-7090-524c-c8c850bf1919 e374b872-9011-7000-c847-55fdcc299204 c3f438a2-e041-7033-75e8-63eb8c64b0e4
aws-iam-identitycenter-add-user-to-group
Adds the specified user to the specified group.
Base Command
aws-iam-identitycenter-add-user-to-group
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| userName | The name of the user to add. | Required |
| groupName | The name of the group to update. | Required |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-add-user-to-group groupName=NewGroup userName=johndoe
Human Readable Output
The membership id 4314c862-b0c1-705e-d5da-ccf59fd045f3 has been successfully created.
aws-iam-identitycenter-get-group
Get AWS IAM Identity Center group Information.
Base Command
aws-iam-identitycenter-get-group
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| displayName | The name of the group to search. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.Group.GroupId | String | The identifier for a group in the identity store. |
| AWS.IAMIdentityCenter.Group.DisplayName | String | The display name of the group. |
| AWS.IAMIdentityCenter.Group.ExternalIds.Issuer | String | The issuer for an external identifier. |
| AWS.IAMIdentityCenter.Group.ExternalIds.Id | String | The identifier issued to this resource by an external identity provider. |
| AWS.IAMIdentityCenter.Group.Description | String | A description of the group. |
| AWS.IAMIdentityCenter.Group.IdentityStoreId | String | The globally unique identifier for the identity store. |
Command example
!aws-iam-identitycenter-get-group displayName=NewGroup
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"Group": {
"Description": "New",
"DisplayName": "NewGroup",
"GroupId": "f3a478d2-50b1-7078-81a4-c97c703007f3",
"IdentityStoreId": "d-9967750fbd"
}
}
}
}
Human Readable Output
AWS IAM Identity Center Groups
DisplayName GroupId NewGroup f3a478d2-50b1-7078-81a4-c97c703007f3
aws-iam-identitycenter-get-user-by-email
Retrieves information about the specified IAM user.
Base Command
aws-iam-identitycenter-get-user-by-email
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| emailAddress | The email of the user. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.User.UserName | string | The friendly name identifying the user. |
| AWS.IAMIdentityCenter.User.UserId | string | The stable and unique string identifying the user. |
| AWS.IAMIdentityCenter.User.ExternalIds.Issuer | String | The issuer for an external identifier. |
| AWS.IAMIdentityCenter.User.ExternalIds.Id | String | The identifier issued to this resource by an external identity provider. |
| AWS.IAMIdentityCenter.User.Name.Formatted | String | Formatted version of the user’s name for display. |
| AWS.IAMIdentityCenter.User.Name.FamilyName | String | The family name of the user. |
| AWS.IAMIdentityCenter.User.Name.GivenName | String | The given name of the user. |
| AWS.IAMIdentityCenter.User.Name.MiddleName | String | The middle name of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificPrefix | String | The honorific prefix of the user. |
| AWS.IAMIdentityCenter.User.Name.HonorificSuffix | String | The honorific suffix of the user. |
| AWS.IAMIdentityCenter.User.DisplayName | String | The name of the user formatted for display when referenced. |
| AWS.IAMIdentityCenter.User.NickName | String | An alternate name for the user. |
| AWS.IAMIdentityCenter.User.ProfileUrl | String | URL associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Value | String | Email address associated with the user. |
| AWS.IAMIdentityCenter.User.Emails.Type | String | Type of email address. |
| AWS.IAMIdentityCenter.User.Emails.Primary | String | Indicates whether this is the primary email address. |
| AWS.IAMIdentityCenter.User.Addresses.StreetAddress | String | Street address. |
| AWS.IAMIdentityCenter.User.Addresses.Locality | String | Address locality. |
| AWS.IAMIdentityCenter.User.Addresses.Region | String | Region of the address. |
| AWS.IAMIdentityCenter.User.Addresses.PostalCode | String | Postal code of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Country | String | Country of the address. |
| AWS.IAMIdentityCenter.User.Addresses.Formatted | String | Formatted version of the address for display. |
| AWS.IAMIdentityCenter.User.Addresses.Type | String | Type of address. |
| AWS.IAMIdentityCenter.User.Addresses.Primary | String | Indicates whether this is the primary address. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Value | String | Phone number associated with the user. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Type | String | Type of phone number. |
| AWS.IAMIdentityCenter.User.PhoneNumbers.Primary | String | Indicates whether this is the primary phone number. |
| AWS.IAMIdentityCenter.User.UserType | String | Type of user. |
| AWS.IAMIdentityCenter.User.Title | String | Title of the user. |
| AWS.IAMIdentityCenter.User.PreferredLanguage | String | Preferred language of the user. |
| AWS.IAMIdentityCenter.User.Locale | String | Geographical region or location of the user. |
| AWS.IAMIdentityCenter.User.Timezone | String | Time zone of the user. |
| AWS.IAMIdentityCenter.User.IdentityStoreId | String | Globally unique identifier for the identity store. |
Command example
!aws-iam-identitycenter-get-user-by-email emailAddress=johnDoe@gmail.com
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"User": {
"DisplayName": "John Doe",
"Emails": [
{
"Primary": true,
"Type": "work",
"Value": "johnDoe@gmail.com"
}
],
"IdentityStoreId": "d-9967750fbd",
"Name": {
"FamilyName": "Doe",
"GivenName": "John"
},
"UserId": "13746842-e011-70fe-14fe-600d496510f0",
"UserName": "johndoe",
}
}
}
}
Human Readable Output
AWS IAM Identity Center Users
DisplayName Emails UserId UserName John Doe johnDoe@gmail.com 13746842-e011-70fe-14fe-600d496510f0 johndoe
aws-iam-identitycenter-list-memberships
Lists the memberships of the group.
Base Command
aws-iam-identitycenter-list-memberships
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| limit | Number of results to return. Default is 50. | Optional |
| nextToken | The pagination token. | Optional |
| groupName | The name of the group to list the memberships. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.GroupMemberships.IdentityStoreId | String | The globally unique identifier for the identity store. |
| AWS.IAMIdentityCenter.Group.GroupMemberships.MembershipId | String | The identifier for a GroupMembership object in an identity store. |
| AWS.IAMIdentityCenter.Group.GroupId | String | The identifier for a group in the identity store. |
| AWS.IAMIdentityCenter.Group.GroupMemberships.UserId | String | Identifier of resources that can be members. |
| AWS.IAMIdentityCenter.GroupMembershipNextToken | String | The pagination token. |
Command example
!aws-iam-identitycenter-list-memberships groupName=NewGroup
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"Group": {
"GroupMemberships":[
{
"MembershipId":"e374b872-9011-7000-c847-55fdcc299204",
"UserId":"c3f438a2-e041-7033-75e8-63eb8c64b0e4"
}
]
},
"GroupMembershipNextToken":null
}
}
}
Human Readable Output
GroupId MembershipId UserId a3948882-5051-7090-524c-c8c850bf1919 e374b872-9011-7000-c847-55fdcc299204 c3f438a2-e041-7033-75e8-63eb8c64b0e4
aws-iam-identitycenter-delete-user
Removes the specified user from the AWS IAM Identity Center.
Base Command
aws-iam-identitycenter-delete-user
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| userName | The name of the user to remove. | Required |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-delete-user userName=johndoe
Human Readable Output
The User 634418e2-20c1-703e-4358-a8312472c85d has been removed.
aws-iam-identitycenter-delete-group
Removes the specified group from the IAM Identity Center.
Base Command
aws-iam-identitycenter-delete-group
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| groupName | The name of the group to remove. | Required |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-delete-group groupName=NewGroup
Human Readable Output
The Group f3a478d2-50b1-7078-81a4-c97c703007f3 has been removed.
aws-iam-identitycenter-create-group
Creates a new IAM Identity Center group for your AWS account.
Base Command
aws-iam-identitycenter-create-group
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| displayName | The name of the group to create. | Required |
| description | The description of the group to create. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AWS.IAMIdentityCenter.Group.GroupId | string | The user ID. |
| AWS.IAMIdentityCenter.Group.IdentityStoreId | string | Identity store ID. |
Command example
!aws-iam-identitycenter-create-group description=New displayName=NewGroup
Context Example
{
"AWS": {
"IAMIdentityCenter": {
"Group": {
"GroupId": "f3a478d2-50b1-7078-81a4-c97c703007f3",
"IdentityStoreId": "d-9967750fbd"
}
}
}
}
Human Readable Output
Group NewGroup has been successfully created with id f3a478d2-50b1-7078-81a4-c97c703007f3
GroupId IdentityStoreId f3a478d2-50b1-7078-81a4-c97c703007f3 d-9967750fbd
aws-iam-identitycenter-update-group
Updates an IAM Identity Center group for your AWS account.
Base Command
aws-iam-identitycenter-update-group
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| displayName | The name of the group to update. | Required |
| description | The description of the group to update. | Required |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-update-group description=changed displayName=NewGroup
Human Readable Output
Group NewGroup has been successfully updated
aws-iam-identitycenter-update-user
Updates an IAM Identity Center user for your AWS account.
Base Command
aws-iam-identitycenter-update-user
Input
| Argument Name | Description | Required |
|---|---|---|
| userName | The username of the user to update. | Required |
| familyName | The family name of the user to update. | Optional |
| givenName | The first name of the user to update. | Optional |
| userEmailAddressPrimary | Is this the primary email address for the associated resource. Possible values are: yes, no. | Optional |
| userEmailAddress | The email address of the user to update. | Optional |
| displayName | The display name of the user to update. | Optional |
| profileUrl | The profile URL of the user to update. | Optional |
| userType | The type of the user to update. | Optional |
| title | The title of the user to update. | Optional |
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-update-user userName=johndoe familyName=changed
Human Readable Output
User johndoe has been successfully updated
aws-iam-identitycenter-delete-group-membership
Deletes a user from all groups if a username is provided, or deletes multiple memberships if a list of memberships is provided.
Base Command
aws-iam-identitycenter-delete-group-membership
Input
| Argument Name | Description | Required |
|---|---|---|
| region | The AWS Region. If not specified, the default region will be used. Possible values are: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-central-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1, eu-north-1, eu-west-3. | Optional |
| roleArn | The Amazon Resource Name. | Optional |
| roleSessionDuration | Role session duration. | Optional |
| roleSessionName | Role session name. | Optional |
| IdentityStoreId | Identity store ID. | Optional |
| userName | The name of the user to delete from all groups. | Optional |
| membershipId | Comma-separated list of membership IDs to delete. | Optional |
Context Output
There is no context output for this command.
Command example
!aws-iam-identitycenter-delete-group-membership userName=johndoe
Human Readable Output
User is not member of any group.
Configuration parameters
roleArn— Role ArnroleArnCredentials—roleSessionName— Role Session NamedefaultRegion— AWS Default Region (required)sessionDuration— Role Session DurationIdentityStoreId— Identity Store IDaccess_key— Access Keysecret_key— Secret Keycredentials— Access Keytimeout— Timeoutretries— Retriessts_regional_endpoint— AWS STS Regional Endpointsinsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (15)
-
aws-iam-identitycenter-add-user-to-groupAdds the specified user to the specified group.
-
aws-iam-identitycenter-create-groupCreates a new IAM Identity Center group for your AWS account.
-
aws-iam-identitycenter-create-userCreates a new IAM Identity Center user for your AWS account.
-
aws-iam-identitycenter-delete-groupRemoves the specified group from the IAM Identity Center.
-
aws-iam-identitycenter-delete-group-membershipDeletes a user from all groups if a username is provided, or deletes multiple memberships if a list of memberships is provided.
-
aws-iam-identitycenter-delete-userRemoves the specified user from the AWS IAM Identity Center.
-
aws-iam-identitycenter-get-groupGet AWS IAM Identity Center group Information.
-
aws-iam-identitycenter-get-userRetrieves information about the specified IAM user.
-
aws-iam-identitycenter-get-user-by-emailRetrieves information about the specified IAM user.
-
aws-iam-identitycenter-list-groupsLists all the IAM groups in the AWS account.
-
aws-iam-identitycenter-list-groups-for-userLists the IAM Identity Center groups that the specified IAM user belongs to.
-
aws-iam-identitycenter-list-membershipsLists the memberships of the group.
-
aws-iam-identitycenter-list-usersLists the IAM users, returns all users in the AWS account.
-
aws-iam-identitycenter-update-groupUpdates an IAM Identity Center group for your AWS account.
-
aws-iam-identitycenter-update-userUpdates an IAM Identity Center user for your AWS account.
import demistomock as demisto # noqa: F401 from AWSApiModule import * from CommonServerPython import * # noqa: F401 """ CONSTANTS """ SERVICE = "identitystore" PREFIX = "AWS.IAMIdentityCenter" PREFIX_USER = "AWS.IAMIdentityCenter.User" PREFIX_GROUP = "AWS.IAMIdentityCenter.Group" """ HELPER FUNCTIONS """ def get_userId_by_username(args: dict, client: Any, IdentityStoreId: str) -> str: """ Retrieve the User ID associated with a given username from the AWS IAM Identity Center using the provided client. Args: args: The command arguments containing the 'userName'. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the user is registered. Returns: str: The User ID associated with the provided username, or None if not found. """ user_name = args.get("userName") response_id = client.get_user_id( IdentityStoreId=IdentityStoreId, AlternateIdentifier={"UniqueAttribute": {"AttributePath": "userName", "AttributeValue": user_name}}, ) return response_id.get("UserId") def get_user_operations_list(args: dict) -> list: """ Generates a list of operations to update user information based on the provided arguments. Args: args: A dictionary containing user information. Returns: list: A list of dictionaries representing the operations to be performed on user attributes. Each dictionary contains 'AttributePath' and 'AttributeValue' corresponding to the attribute path and its updated value respectively. Raises: RuntimeError: If 'userEmailAddressPrimary' is specified without 'userEmailAddress'. """ primary = args.get("userEmailAddressPrimary") user_email_address = args.get("userEmailAddress") if primary and not user_email_address: return_error("Error: When specifying userEmailAddressPrimary, userEmailAddress must also be provided.") if primary: primary = argToBoolean(primary) path_and_value = { "name.familyName": args.get("familyName"), "name.givenName": args.get("givenName"), "emails": [{"value": user_email_address, "primary": primary}], "displayName": args.get("displayName"), "userType": args.get("userType"), "profileUrl": args.get("profileUrl"), "title": args.get("title"), "addresses": [{"region": args.get("region")}], } path_and_value = remove_empty_elements(path_and_value) to_update = [] for path in path_and_value: to_update.append({"AttributePath": path, "AttributeValue": path_and_value[path]}) return to_update def get_limit(args: dict) -> int: """ Get the limit value specified in the arguments. Args: args: A dictionary containing the 'limit' argument. Returns: int: The limit value if specified and less than 50, otherwise returns 50 as the default limit. """ if limit := args.get("limit"): return min(int(limit), 50) return 50 def get_groupId_by_displayName(args: dict, client: Any, IdentityStoreId: str) -> str: """ Retrieve the Group ID associated with a given display name or group name from the AWS IAM Identity Center using the provided client. Args: args: A dictionary containing the display name or group name to search for. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the group is registered. Returns: str: The Group ID associated with the provided display name or group name. """ group_name = args.get("displayName") or args.get("groupName") response_id = client.get_group_id( IdentityStoreId=IdentityStoreId, AlternateIdentifier={"UniqueAttribute": {"AttributePath": "displayName", "AttributeValue": group_name}}, ) return response_id.get("GroupId") def get_group_memberships_for_member(args: dict, client: Any, IdentityStoreId: str) -> list: """ Retrieve group memberships for a member (user) from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the member (user). client: The client object used to interact with the IAM Identity Center service. IdentityStoreId: The ID of the Identity Store where the member is registered. Returns: list: A list containing the membership IDs of groups to which the member belongs. """ memberships_of_member = [] user_id = get_userId_by_username(args, client, IdentityStoreId) kwargs = {"IdentityStoreId": IdentityStoreId, "MemberId": {"UserId": user_id}} kwargs = remove_empty_elements(kwargs) groups_response = client.list_group_memberships_for_member(**kwargs) for group in groups_response.get("GroupMemberships", []): memberships_of_member.append(group.get("MembershipId")) return memberships_of_member def update_groups_and_memberships(last_data, current_data: list, key: str, id_value: Any, new_data: str): """ Update groups and memberships based on the provided parameters. Args: last_data: The previous data containing group memberships. current_data: The current data containing group memberships. key: The key to identify the item in the data (e.g., 'id'). id_value: The value of the key to match against (e.g., user ID). new_data: The key representing the updated data (e.g., 'groups'). Returns: list: The updated list of group memberships. """ updated_list = [] if not isinstance(last_data, list): last_data = [last_data] for item_data in last_data: if item_data.get(key) == id_value: updated_list = item_data.get(new_data, []) break if updated_list: combined_data = updated_list + [g for g in current_data if g not in updated_list] final_data = combined_data else: final_data = current_data return final_data def create_user(args: dict, client: Any, IdentityStoreId: str) -> None: """ Creates a user with the provided arguments. Args: args: The command arguments client: The client object to interact with the API. IdentityStoreId: The ID of the identity store. """ user_name = args.get("userName") family_name = args.get("familyName") given_name = args.get("givenName") user_email = args.get("userEmailAddress") user_display_name = args.get("displayName") user_type = args.get("userType") profile_url = args.get("profileUrl") title = args.get("title") region = args.get("region") primary_email = args.get("userEmailAddressPrimary") if primary_email and not user_email: return_error("Error: When specifying userEmailAddressPrimary, userEmailAddress must also be provided.") if primary_email: primary_email = argToBoolean(primary_email) kwargs = { "IdentityStoreId": IdentityStoreId, "UserName": user_name, "Name": {"FamilyName": family_name, "GivenName": given_name}, "Emails": [{"Value": user_email, "Primary": primary_email}], "DisplayName": user_display_name, "UserType": user_type, "ProfileUrl": profile_url, "Title": title, "Addresses": [ { "Region": region, } ], } kwargs = remove_empty_elements(kwargs) response = client.create_user(**kwargs) user_id = response.get("UserId") response.pop("ResponseMetadata", None) response = remove_empty_elements(response) human_readable = tableToMarkdown(f"User {user_name} has been successfully created with user id {user_id}", response) result = CommandResults(outputs_prefix=PREFIX_USER, readable_output=human_readable, outputs=response) return_results(result) def update_user(args: dict, client: Any, IdentityStoreId: str) -> None: """ Update user information based on the provided arguments. Args: args: A dictionary containing user information to be updated. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the user is registered. """ user_name = args.get("userName") user_id = get_userId_by_username(args, client, IdentityStoreId) operations = get_user_operations_list(args) kwargs = {"IdentityStoreId": IdentityStoreId, "UserId": user_id, "Operations": operations} client.update_user(**kwargs) hr_data = f"User {user_name} has been successfully updated" result = CommandResults(readable_output=hr_data) return_results(result) def delete_user(args: dict, client: Any, IdentityStoreId: str) -> None: """ Delete a user from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the user to be deleted. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the user is registered. """ user_id = get_userId_by_username(args, client, IdentityStoreId) client.delete_user(IdentityStoreId=IdentityStoreId, UserId=user_id) hr_data = f"The User {user_id} has been removed." demisto.debug(hr_data) result = CommandResults(readable_output=hr_data) return_results(result) def get_user(args: dict, client: Any, IdentityStoreId: str) -> None: """ Retrieve user information from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the user to be retrieved. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the user is registered. """ response_id = get_userId_by_username(args, client, IdentityStoreId) response = client.describe_user(IdentityStoreId=IdentityStoreId, UserId=response_id) response.pop("ResponseMetadata", None) hr_data = { "UserId": response.get("UserId"), "UserName": response.get("UserName"), "DisplayName": response.get("DisplayName"), } if response.get("Emails"): emails = [email.get("Value") for email in response.get("Emails")] hr_data["Emails"] = emails human_readable = tableToMarkdown("AWS IAM Identity Center Users", hr_data, removeNull=True) result = CommandResults( outputs_prefix=PREFIX_USER, readable_output=human_readable, outputs_key_field="UserId", outputs=response ) return_results(result) def get_user_by_email(args: dict, client: Any, IdentityStoreId: str) -> None: """ Retrieve user information from the AWS IAM Identity Center based on the provided email address. Args: args: A dictionary containing the email address of the user to be retrieved. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the user is registered. """ email_arg = args.get("emailAddress") response = client.list_users( IdentityStoreId=IdentityStoreId, ) email_exists = False hr_data = {} context_data = {} for user in response.get("Users"): user_emails = user.get("Emails", []) user_emails_values = [email.get("Value") for email in user_emails] if email_arg in user_emails_values: email_exists = True user_details = { "UserName": user.get("UserName"), "UserId": user.get("UserId"), "Emails": user_emails_values, "DisplayName": user.get("DisplayName"), } hr_data = user_details context_data = user break if not email_exists: return_error(f"User with the email {email_arg} was not found.") human_readable = tableToMarkdown("AWS IAM Identity Center Users ", hr_data, removeNull=True) result = CommandResults( outputs_prefix=PREFIX_USER, readable_output=human_readable, outputs_key_field="UserId", outputs=context_data ) return_results(result) def list_users(args: dict, client: Any, IdentityStoreId: str) -> None: """ List users from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing optional parameters such as 'limit' and 'nextToken'. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store from which users are listed. """ context_data = [] hr_data = [] kwargs = {"IdentityStoreId": IdentityStoreId, "MaxResults": get_limit(args), "NextToken": args.get("nextToken")} kwargs = remove_empty_elements(kwargs) response = client.list_users(**kwargs) for user in response.get("Users", []): context_data.append(user) user_details = { "UserId": user.get("UserId"), "UserName": user.get("UserName"), "DisplayName": user.get("DisplayName"), } if user.get("Emails"): emails = [email.get("Value") for email in user.get("Emails")] user_details["Emails"] = emails hr_data.append(user_details) outputs = { f"{PREFIX_USER}(val.UserId === obj.UserId)": context_data, f"{PREFIX}(true)": {"UserNextToken": response.get("NextToken")}, } human_readable = tableToMarkdown("AWS IAM Identity Center Users", hr_data, removeNull=True) result = CommandResults(readable_output=human_readable, outputs_key_field="UserId", outputs=outputs) return_results(result) def list_groups(args: dict, client: Any, IdentityStoreId: str) -> None: """ List groups from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing optional parameters such as 'limit' and 'nextToken'. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store from which groups are listed. """ context_data = [] hr_data = [] kwargs = {"IdentityStoreId": IdentityStoreId, "MaxResults": get_limit(args), "NextToken": args.get("nextToken")} kwargs = remove_empty_elements(kwargs) response = client.list_groups(**kwargs) for group in response.get("Groups", []): group_details = { "DisplayName": group.get("DisplayName"), "GroupId": group.get("GroupId"), "Description": group.get("Description"), } hr_data.append(group_details) context_data.append(group) outputs = { f"{PREFIX_GROUP}(val.GroupId === obj.GroupId)": context_data, f"{PREFIX}(true)": {"GroupNextToken": response.get("NextToken")}, } human_readable = tableToMarkdown("AWS IAM Identity Center Groups", hr_data, removeNull=True) result = CommandResults(readable_output=human_readable, outputs_key_field="GroupId", outputs=outputs) return_results(result) def create_group(args: dict, client: Any, IdentityStoreId: str) -> None: """ Create a group in the Identity Store based on the provided arguments. Args: args: A dictionary containing the group information such as 'displayName' and 'description'. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the group is to be created. """ display_name = args.get("displayName") kwargs = {"IdentityStoreId": IdentityStoreId, "DisplayName": display_name, "Description": args.get("description")} kwargs = remove_empty_elements(kwargs) response = client.create_group(**kwargs) group_id = response.get("GroupId") response.pop("ResponseMetadata", None) human_readable = tableToMarkdown(f"Group {display_name} has been successfully created with id {group_id}", response) result = CommandResults(outputs_prefix=PREFIX_GROUP, readable_output=human_readable, outputs=response) return_results(result) def delete_group(args: dict, client: Any, IdentityStoreId: str) -> None: """ Delete a group from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the group to be deleted. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the group is registered. """ group_id = get_groupId_by_displayName(args, client, IdentityStoreId) client.delete_group(IdentityStoreId=IdentityStoreId, GroupId=group_id) hr_data = f"The Group {group_id} has been removed." demisto.debug(hr_data) result = CommandResults(readable_output=hr_data) return_results(result) def update_group(args: dict, client: Any, IdentityStoreId: str) -> None: """ Update group information in the Identity Store based on the provided arguments. Args: args: A dictionary containing the group information to be updated, such as 'displayName' and 'description'. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the group is registered. """ display_name = args.get("displayName") group_id = get_groupId_by_displayName(args, client, IdentityStoreId) kwargs = { "IdentityStoreId": IdentityStoreId, "GroupId": group_id, "Operations": [{"AttributePath": "description", "AttributeValue": args.get("description")}], } client.update_group(**kwargs) hr_data = f"Group {display_name} has been successfully updated" result = CommandResults(readable_output=hr_data) return_results(result) def get_group(args: dict, client: Any, IdentityStoreId: str) -> None: """ Retrieve group information from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the group to be retrieved. client: The client object used to interact with the Identity Store service. IdentityStoreId: The ID of the Identity Store where the group is registered. """ response_id = get_groupId_by_displayName(args, client, IdentityStoreId) response = client.describe_group(IdentityStoreId=IdentityStoreId, GroupId=response_id) hr_data = {"DisplayName": response.get("DisplayName"), "GroupId": response.get("GroupId")} response.pop("ResponseMetadata", None) human_readable = tableToMarkdown("AWS IAM Identity Center Groups", hr_data, removeNull=True) result = CommandResults( outputs_prefix=PREFIX_GROUP, readable_output=human_readable, outputs_key_field="GroupId", outputs=response ) return_results(result) def list_groups_for_user(args: dict, client: Any, IdentityStoreId: str) -> None: """ List groups associated with a user from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the user and optional parameters such as 'limit' and 'nextToken'. client: The client object used to interact with the IAM Identity Center service. IdentityStoreId: The ID of the Identity Store from which groups are listed for the user. """ hr_data = [] context_data: Dict[str, Any] = {} user_id = get_userId_by_username(args, client, IdentityStoreId) kwargs = { "IdentityStoreId": IdentityStoreId, "MemberId": {"UserId": user_id}, "MaxResults": get_limit(args), "NextToken": args.get("nextToken"), } kwargs = remove_empty_elements(kwargs) response = client.list_group_memberships_for_member(**kwargs) groups: list = [] for group in response.get("GroupMemberships", []): hr_data.append({"UserID": user_id, "GroupID": group.get("GroupId"), "MembershipID": group.get("MembershipId")}) groups.append({"GroupId": group.get("GroupId"), "MembershipId": group.get("MembershipId")}) context_data["UserId"] = user_id context_data["GroupsUserNextToken"] = response.get("NextToken") last_context = demisto.context() last_users = last_context.get("AWS", {}).get("IAMIdentityCenter", {}).get("User", {}) final_groups = update_groups_and_memberships(last_users, groups, "UserId", user_id, "GroupMemberships") context_data["GroupMemberships"] = final_groups human_readable = tableToMarkdown("AWS IAM Identity Center Groups", hr_data, removeNull=True) result = CommandResults( outputs_prefix=PREFIX_USER, readable_output=human_readable, outputs_key_field="UserId", outputs=context_data ) return_results(result) def add_user_to_group(args: dict, client: Any, IdentityStoreId: str) -> None: """ Add a user to a group in the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the user and group. client: The client object used to interact with the IAM Identity Center service. IdentityStoreId: The ID of the Identity Store where the user and group are registered. """ user_id = get_userId_by_username(args, client, IdentityStoreId) Group_id = get_groupId_by_displayName(args, client, IdentityStoreId) response = client.create_group_membership(IdentityStoreId=IdentityStoreId, GroupId=Group_id, MemberId={"UserId": user_id}) membership_id = response.get("MembershipId") hr_data = f"The membership id {membership_id} has been successfully created." result = CommandResults(readable_output=hr_data) return_results(result) def delete_group_membership(args: dict, client: Any, IdentityStoreId: str) -> None: """ Delete group memberships for a user in the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the user or membership(s) to be deleted. client: The client object used to interact with the IAM Identity Center service. IdentityStoreId: The ID of the Identity Store where the user and group memberships are registered. """ memberships_to_delete = [] membership_id = args.get("membershipId") user_name = args.get("userName") if membership_id and user_name: return_error("Please provide only one of userName or membershipId.") elif membership_id: memberships_to_delete = argToList(membership_id) elif user_name: memberships_to_delete = get_group_memberships_for_member(args, client, IdentityStoreId) if not memberships_to_delete: return_error("User is not member of any group.") else: return_error("userName or membershipId must be provided.") for member in memberships_to_delete: client.delete_group_membership(IdentityStoreId=IdentityStoreId, MembershipId=member) hr_data = f"The membership with ids {memberships_to_delete} have been deleted." demisto.debug(hr_data) result = CommandResults(readable_output=hr_data) return_results(result) def list_group_memberships(args: dict, client: Any, IdentityStoreId: str) -> None: """ List memberships of a group from the AWS IAM Identity Center based on the provided arguments. Args: args: A dictionary containing information required to identify the group and optional parameters such as 'limit' and 'nextToken'. client: The client object used to interact with the IAM Identity Center service. IdentityStoreId: The ID of the Identity Store where the group memberships are registered. """ hr_data = [] context_data: Dict[str, Any] = {} group_id = get_groupId_by_displayName(args, client, IdentityStoreId) kwargs = { "IdentityStoreId": IdentityStoreId, "GroupId": group_id, "MaxResults": get_limit(args), "NextToken": args.get("nextToken"), } kwargs = remove_empty_elements(kwargs) response = client.list_group_memberships(**kwargs) memberships = [] for membership in response.get("GroupMemberships", []): member_details = { "MembershipId": membership.get("MembershipId"), "GroupId": group_id, "UserId": membership.get("MemberId", {}).get("UserId"), } hr_data.append(member_details) memberships.append( {"MembershipId": membership.get("MembershipId"), "UserId": membership.get("MemberId", {}).get("UserId")} ) context_data["GroupId"] = group_id context_data["GroupMembershipNextToken"] = response.get("NextToken") last_context = demisto.context() last_groups = last_context.get("AWS", {}).get("IAMIdentityCenter", {}).get("Group", {}) final_memberships = update_groups_and_memberships(last_groups, memberships, "GroupId", group_id, "GroupMemberships") context_data["GroupMemberships"] = final_memberships human_readable = tableToMarkdown("AWS IAM Identity Center Groups", hr_data, removeNull=True) result = CommandResults( outputs_prefix=PREFIX_GROUP, readable_output=human_readable, outputs_key_field="GroupId", outputs=context_data ) return_results(result) def test_module(args: dict, client: Any, IdentityStoreId: str) -> None: # pragma: no cover """Command to test the connection to the API""" if not IdentityStoreId: return_error( "Identity Store ID was not specified - Test failure. The `Identity Store ID` parameter can be left empty " "and included as an argument in every command." ) client.list_users( IdentityStoreId=IdentityStoreId, ) return_results("ok") def main(): # pragma: no cover params = demisto.params() args = demisto.args() IdentityStoreId: str = args.get("IdentityStoreId", "") or params.get("IdentityStoreId", "") aws_default_region = params.get("defaultRegion") aws_role_arn = params.get("roleArnCredentials", {}).get("password") or params.get("roleArn") aws_role_session_name = params.get("roleSessionName") aws_role_session_duration = params.get("sessionDuration") aws_access_key_id = params.get("credentials", {}).get("identifier") or params.get("access_key") aws_secret_access_key = params.get("credentials", {}).get("password") or params.get("secret_key") verify_certificate = not params.get("insecure", True) timeout = params.get("timeout") retries = params.get("retries") or 5 command = demisto.command() try: validate_params(aws_default_region, aws_role_arn, aws_role_session_name, aws_access_key_id, aws_secret_access_key) aws_client = AWSClient( aws_default_region, aws_role_arn, aws_role_session_name, aws_role_session_duration, None, aws_access_key_id, aws_secret_access_key, verify_certificate, timeout, retries, ) client: AWSClient = aws_client.aws_session( service=SERVICE, region=args.get("region"), role_arn=args.get("roleArn"), role_session_name=args.get("roleSessionName"), role_session_duration=args.get("roleSessionDuration"), ) demisto.debug(f"Command being called is {command}") if command == "test-module": test_module(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-create-user": create_user(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-get-user": get_user(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-get-user-by-email": get_user_by_email(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-list-users": list_users(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-list-groups": list_groups(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-get-group": get_group(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-list-groups-for-user": list_groups_for_user(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-add-user-to-group": add_user_to_group(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-delete-user": delete_user(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-create-group": create_group(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-delete-group": delete_group(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-delete-group-membership": delete_group_membership(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-list-memberships": list_group_memberships(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-update-user": update_user(args, client, IdentityStoreId) elif command == "aws-iam-identitycenter-update-group": update_group(args, client, IdentityStoreId) else: raise NotImplementedError(f"Command {command} is not implemented in AWS - IAM Identity Center integration.") # Log exceptions and return errors except Exception as e: demisto.info(str(e)) return_error(f"Failed to execute {command} command.\nError:\n{e!s}") if __name__ in ("__builtin__", "builtins", "__main__"): main()