SSO Sync
repository·master·Indexed 20 days ago
https://github.com/awslabs/ssosyncA CLI tool and AWS Lambda function for synchronizing Google Workspace users and groups into AWS IAM Identity Center. It provides uni-directional identity provisioning using the SCIM protocol, featuring advanced filtering via Google API query parameters, dry-run mode, and integration with AWS Secrets Manager. Deployment options include the AWS Serverless Application Repository, AWS SAM, or as a Go binary.
What's inside ssosync
- SSO Sync is a CLI tool and AWS Lambda function designed to automatically provision Google Workspace (formerly G Suite) users and groups into AWS IAM Identity Center (formerly AWS SSO). It provides a uni-directional synchronization mechanism to ensure your AWS identity store matches your Google Workspace directory based on specific filters.
Important Deployment Considerations for SSO Sync
masterWhen deploying or running SSO Sync, be aware of the following critical requirements and behaviors:
IAM Identity Center Delegation
- Lambda Deployment: If deploying via the AWS Serverless Application Repository, the Lambda must be deployed into the IAM Identity Center delegated administration account.
- CLI Usage: If running as a CLI tool, your environment must use credentials from a user in the IAM Identity Center delegated administration account with appropriate permissions.
AWS Control Tower Warning
- Caution: If using IAM Identity Center integrated with AWS Control Tower,
ssosyncwill attempt to make the IAM Identity Store match your Google Workspace directory. This includes removing groups and users created by AWS Control Tower. A feature to ignore these manually created entities is planned for v3.x.
Version-Specific Notes
- v2.1.0+: Uses named IAM resources. If deploying via CI/CD or IaC, you must specify
CAPABILITY_NAMED_IAMin your CloudFormation stack. - v2.1.0+: Uses
provided.al2powered by ARM64 instances. - v2.2.0+: Supports multiple query patterns for Group and User matching by separating queries with a comma (e.g.,
query1,query2). Use*for full sync.
Filter Google Users and Groups using `--user-match` and `--group-match`
masterSSO Sync uses query strings to filter which users and groups are synchronized.
Group Filtering
Use
--group-matchwith patterns:name:AWS*(Prefix match)name:Admin*,email:aws-*(Multiple patterns)name=Administrators(Exact match)*(All groups)
User Filtering
The
--user-matchparameter supports the following fields and operators:Field Prefix ( :)Exact ( =)name✓ ✓ email✓ ✓ manager— ✓ managerId✓ ✓ orgName✓ ✓ orgDepartment✓ ✓ orgCostCenter✓ ✓ Syntax Rules:
- Use
:for prefix/wildcard matching (e.g.,name:John*). - Use
=for exact matching (e.g.,email=john@company.com). - Use
"for exact values containing spaces (e.g.,orgName="My Department"). - Combine multiple patterns with
,or a space. - Use
*to sync all users.
# Sync users by department and cost center --user-match "orgDepartment:Sales*,orgCostCenter=CC-1234" # Sync users managed by a specific person --user-match "manager=boss@company.com"Key Features of SSO Sync
masterSSO Sync provides several capabilities for identity management:
- Uni-directional Sync: Supports
groupsandusers_groupssync methods. - Advanced Filtering: Uses Google API query parameters to filter users and groups.
- Dry-Run Mode: Allows testing synchronization logic without applying changes to AWS.
- High Performance: Built with AWS SDK v2 and includes user caching to handle large directories efficiently.
- Deployment Flexibility: Can be deployed as a CLI binary, an AWS Lambda function, or via AWS SAM.
- Security: Integrates with AWS Secrets Manager for secure credential management.
- Scalability: Supports large directories through pagination and caching.
- Uni-directional Sync: Supports
Prerequisites for SSO Sync
masterBefore configuring SSO Sync, you must enable AWS Single Sign-On (AWS SSO) within your AWS Organizations account. You can follow the official AWS documentation to complete this step.Set up the Development Environment
masterTo contribute to or build SSO Sync locally, ensure you have Go 1.24+, Make, and the AWS CLI installed.
# Clone repository git clone https://github.com/awslabs/ssosync.git cd ssosync/ # Install development dependencies make setup # Run tests make test # Build locally make go-build # Run with development configuration make devmake setup make test make go-build make devDeploy SSO Sync Pipelines for Development
masterFor local development and testing, you can deploy a simplified set of CloudFormation templates. This setup provides the necessary secrets for credentials and a pipeline for building and testing code before submitting a pull request.
Required templates:
secrets.yaml: Creates the secrets used to store credentials for your test GSuite and IAM Identity Center instances.developer.yaml: Creates the pipeline to build and test the application prior to raising a pull request.
Configure Google Workspace for SSO Sync
masterTo allow SSO Sync to read your directory data, you must set up a Google Service Account with domain-wide delegation.
- Enable Admin SDK API: In the Google Cloud Console, enable the Admin SDK API.
- Create Service Account: Create a service account and download the JSON credentials file (save as
credentials.json). - Grant Domain-Wide Delegation: Configure the service account with the following scopes:
https://www.googleapis.com/auth/admin.directory.group.readonlyhttps://www.googleapis.com/auth/admin.directory.group.member.readonlyhttps://www.googleapis.com/auth/admin.directory.user.readonly
- Identify Admin: Note the email address of a Google Workspace administrator to use as the
--google-admin.
Configure AWS IAM Identity Center for SSO Sync
masterSSO Sync uses the SCIM protocol to provision users and groups to AWS IAM Identity Center.
- Enable Automatic Provisioning: In the AWS IAM Identity Center console, go to Settings and enable automatic provisioning.
- Retrieve SCIM Credentials: Copy the SCIM Endpoint URL and the Access Token provided by the console.
- AWS Permissions: Ensure the executing identity (e.g., your local CLI user or a Lambda IAM role) has
sso:ListInstancespermissions to allow the tool to auto-detect the Identity Store ID.
Install SSO Sync via CLI or Go
masterFor local testing, CI/CD, or custom Lambda deployments, you can install the CLI binary or use Go modules.
go get github.com/awslabs/ssosyncDeploy SSO Sync Pipelines for Production and Staging
masterA production-ready environment requires two AWS accounts: a production account and a staging account. This setup involves a multi-step deployment process across management, delegated, and non-delegated accounts.
1. Prepare the Management Account
- Set up AWS Organizations.
- Create two linked accounts: one delegated and one non-delegated.
- Set up IAM Identity Center.
- Delegate administration to the delegated account.
2. Deploy to Staging Accounts
Deploy the following stacks into each staging account (the management account, the delegated IAM Identity Center admin account, and the non-delegated account). Note the output values from these deployments.
secrets.yaml: Creates secrets for GSuite and IAM Identity Center credentials.testing.yaml: Creates the pipeline to deploy and test the application prior to raising a pull request.
3. Setup the Production Account
- Manually create your AWS CodeStar connection.
- Deploy
release.yaml: This creates the pipeline that builds the application, triggers the test pipeline in the staging environment, and publishes the app where appropriate.
Use the SSO Sync CLI
masterThe SSO Sync CLI allows you to run synchronization tasks from your terminal. You can provide configuration via command-line flags or environment variables prefixed with
SSOSYNC_.Basic Usage
Run a basic sync by providing the required Google and AWS credentials:
./ssosync \ --google-admin admin@company.com \ --google-credentials ./credentials.json \ --endpoint https://scim.us-east-1.amazonaws.com/... \ --access-token AQoDYXdzE... \ --group-match "name:AWS*"Advanced Sync Patterns
Dry Run with Debugging: Test your filters without making changes to AWS:
./ssosync \ --group-match "name:Engineering*,email:aws-*" \ --sync-method groups \ --dry-run \ --log-level debugFull Sync (Users and Groups):
./ssosync \ --user-match "*" \ --group-match "*" \ --sync-method users_groupsExcluding Specific Entities:
./ssosync \ --group-match "*" \ --ignore-users "service@company.com,bot@company.com" \ --ignore-groups "temp-group@company.com"