AWS IAM Identity Center Permission Management at Scale Part 3
Tags: security, aws, iam
Published: 2024-04-26 14:04:08

<div>

Identity management is the easiest when you can manage identities in one place and use them across accounts and applications. AWS IAM Identity Center streamlines identity management by enabling you to connect to your identity provider (IdP), such as Active Directory, and use the IdP's identity information for access and collaboration within applications. You can do this, for example, by using an AD Connector and connecting it to your on-premises or Azure AD. An AD Connector is a directory gateway that allows you to route directory requests to your on-premises Microsoft Active Directory without storing information in the cloud cache.

If you have a large Active Directory with several thousand groups and users, you may not want to explicitly select the identities you want to synchronise with AWS Identity Center.  

In this blog post, we will show you a solution that allows you to specify different prefixes for Active Directory groups that will be automatically synced to your AWS Identity Center.

The solution workflow includes the following steps:

1.  Synchronization of Active Directory Groups
2.  Automated Documentation & Notification

### Prerequisite:

*   [Identity Center must be enabled in your Organization](https://docs.aws.amazon.com/singlesignon/latest/userguide/get-started-enable-identity-center.html)
*   Connection to local or Azure Active Directory
*   Active Directory User who has read access

## Solution overview

The following architecture shows the solution of the automated sync of Active Directory Groups to AWS Identity Center .

![Blog Content](https://globaldatanet.com/images/cms/1df979d6613d571c3bc1b0f14a674e525626a52a-1197x792.webp)

[🔗 Here you can find the Solution on Github](https://github.com/kirnberger1980/sso-setup-automation/blob/main/CDK/GroupSync/README.md)

In our CDK based project several resources will be provisioned due deployment.

The Stack contains:

*   Amazon EventBridge rule that runs on a schedule
*   [CDK Sops Secrets Construct](https://github.com/dbsystel/cdk-sops-secrets)
    *   Secret which holds the Active Directory Credentials
*   Lambda Function to create the Synchronisation Filter in AWS IAM Identity Center
*   all necessary IAM Roles and Permissions for the Lambda Function

### Synchronization of Active Directory Groups

With Active Directory group synchronisation, you use IAM Identity Center to assign users and groups from Active Directory access to AWS accounts and to AWS-managed or customer-managed applications. All Active Directory Groups with specified prefixes will be automatically synchronised to your AWS IAM Identity Center.

#### How the automation with the lambda function works

The Sync LambdaFunction is triggered by Eventbridge Scheduled event to ensure that the Groups you want sync from your active directory are always uptodate in your AWS Identity Center.

The workflow of our Sync LambdaFunction is the following:

1.  Retrieve Active Directory credentials from AWS Secrets Manager
2.  Log on to Active Directory using LDAP(s) using the credentials just retrieved
3.  Search and retrieve Active Directory group names based on specified prefixes
4.  Retrieve current Filters of Groups which are sync scope from AWS Identity Center
5.  Add missing Active Directory groups as synchronisation filters in AWS Identity Center  

    1.  ℹ Synchronisation to AWS Identity Center will start after a short amount of time.
6.  Generating of automated documentation
7.  Sending notification to MS Teams

#### Deployment

The deployment of the solution is done via a cdk stack which is part of the solution's repository. All the required Parameters will be configured in a typescript file - an example file is also included in the repository.

**What you have to configure:**

<div class="scroll-bar-table-mobile">

<table class="table-custom">

<tbody>

<tr>

<th>Property</th>

<th>Description</th>

</tr>

<tr>

<td>Produkt</td>

<td>will be used to generate StackName</td>

</tr>

<tr>

<td>Stage</td>

<td>will be used to generate StackName</td>

</tr>

<tr>

<td>Prefix</td>

<td>will be used to generate StackName</td>

</tr>

<tr>

<td>s3_DOKUBUCKET</td>

<td>Name of the S3 Bucket for the generated documentation</td>

</tr>

<tr>

<td>WebhookUrlTeams</td>

<td>URL of your MS Teams Webhook</td>

</tr>

<tr>

<td>DocuWebsite</td>

<td>Link to the Website where the generated HTML snippet has been published used for a button in the Team Nofitication</td>

</tr>

<tr>

<td>LambdaSchedule</td>

<td>Duration how often your Lambda should be trigger from Eventbridge. Rates may be defined with any unit of time, but when converted into minutes, the duration must be a positive whole number of minutes.</td>

</tr>

<tr>

<td>rootCaCertificateString*</td>

<td>the Root CA Certificate in PEM format which issues the server certificates Active Directory</td>

</tr>

<tr>

<td>vpcId</td>

<td>Id of your VPC where the lambda will be deployed to</td>

</tr>

<tr>

<td>subnetIds</td>

<td>Ids of subnets where the lambda will be deployed to</td>

</tr>

<tr>

<td>ad_DomainName</td>

<td>Name of your Active Directory</td>

</tr>

<tr>

<td>BasePath</td>

<td>Path in your Active Directory where the Lambda can find the Users you want to Sync</td>

</tr>

<tr>

<td>GroupPrefixes</td>

<td>Array of prefixes of groups you want to synchronise into your AWS Identity Center</td>

</tr>

<tr>

<td>SecretFile</td>

<td>Path to your Sops secrets file, which should contain the Active Directory user credentials.</td>

</tr>

<tr>

<td>Url</td>

<td>LDAP Url to your Active Directory. The LDAP URL format is ldap:// hostname</td>

</tr>

<tr>

<td>Port</td>

<td>Port of your LDAP - LDAP default is 389, LDAPs = 636</td>

</tr>

<tr>

<td>IdentityStoreId</td>

<td>Identity Store Id of your AWS Identity Center</td>

</tr>

<tr>

<td>Endpoint</td>

<td>

<div>AWS hidden API Endpoint- should be identity-sync.<aws-region>.amazonaws.com</aws-region></div>

</td>

</tr>

</tbody>

</table>

</div>

### Automated Documentation & Notification

After each execution of the Synchronisation Lambda, we aim to notify our team about the actions taken during the previous run. Therefore, we have implemented a Teams notification that includes a status update and a link to an automatically generated dashboard.

ℹ️ Notifications are only sent when groups are added or deleted, or when an automation error occurs, to avoid a flood of notifications.

The following screenshot illustrates an example of a Teams notification.

![Blog Content](https://globaldatanet.com/images/cms/a8de04d085041443629b7e3d19ba8e8c6941d954-625x144.webp)

#### Documentation

Our Active Directory Synchronization Status Dashboard is a simple HTML file which will be generated trough a Lambda Function, saved in S3 and will be distributed trough a CloudFront. You can integrate this Dashboards in your Confluence or any other internal Wiki. This Dashboard is secured via CloudFormation Function - additionally you can also add a [Firewall](https://globaldatanet.com/solutions/web-application-firewalls-at-scale) to restrict the access to an specific CIDR or Geographic region and prevent access from third parties. The screenshot below provides an example of a dashboard.

![Blog Content](https://globaldatanet.com/images/cms/20c6847fbe0ef93a490c7a85026f124881141877-954x457.webp)

### Conclusion

In this blog post, we showed you how to improve your security posture by automatically and regularly synchronising Active Directory groups that match a specific pattern with AWS Identity Center. This simplifies access management and increases security by automatically revoking access in AWS Identity Center when group objects are deleted or created in Active Directory. Furthermore, the automatically generated documentation facilitates an overview of the synchronised group objects.

[🔗 Here you can find the Solution on Github](https://github.com/kirnberger1980/sso-setup-automation/blob/main/CDK/GroupSync/README.md)

</div>