SSO Sync

repository·master·Indexed 20 days ago

https://github.com/awslabs/ssosync

A 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.

Tokens
7.4K
Snippets
16
Records
38
Agent score
71%

What's inside ssosync

  1. Overview of SSO Sync

    master
    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.
  2. Important Deployment Considerations for SSO Sync

    master

    When 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, ssosync will 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_IAM in your CloudFormation stack.
    • v2.1.0+: Uses provided.al2 powered 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.
  3. Filter Google Users and Groups using `--user-match` and `--group-match`

    master

    SSO Sync uses query strings to filter which users and groups are synchronized.

    Group Filtering

    Use --group-match with patterns:

    • name:AWS* (Prefix match)
    • name:Admin*,email:aws-* (Multiple patterns)
    • name=Administrators (Exact match)
    • * (All groups)

    User Filtering

    The --user-match parameter supports the following fields and operators:

    FieldPrefix (:)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"
  4. Key Features of SSO Sync

    master

    SSO Sync provides several capabilities for identity management:

    • Uni-directional Sync: Supports groups and users_groups sync 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.
  5. Prerequisites for SSO Sync

    master
    Before 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.
  6. Set up the Development Environment

    master

    To 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 dev
    make setup
    make test
    make go-build
    make dev
  7. Deploy SSO Sync Pipelines for Development

    master

    For 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.
  8. Configure Google Workspace for SSO Sync

    master

    To allow SSO Sync to read your directory data, you must set up a Google Service Account with domain-wide delegation.

    1. Enable Admin SDK API: In the Google Cloud Console, enable the Admin SDK API.
    2. Create Service Account: Create a service account and download the JSON credentials file (save as credentials.json).
    3. Grant Domain-Wide Delegation: Configure the service account with the following scopes:
      • https://www.googleapis.com/auth/admin.directory.group.readonly
      • https://www.googleapis.com/auth/admin.directory.group.member.readonly
      • https://www.googleapis.com/auth/admin.directory.user.readonly
    4. Identify Admin: Note the email address of a Google Workspace administrator to use as the --google-admin.
  9. Configure AWS IAM Identity Center for SSO Sync

    master

    SSO Sync uses the SCIM protocol to provision users and groups to AWS IAM Identity Center.

    1. Enable Automatic Provisioning: In the AWS IAM Identity Center console, go to Settings and enable automatic provisioning.
    2. Retrieve SCIM Credentials: Copy the SCIM Endpoint URL and the Access Token provided by the console.
    3. AWS Permissions: Ensure the executing identity (e.g., your local CLI user or a Lambda IAM role) has sso:ListInstances permissions to allow the tool to auto-detect the Identity Store ID.
  10. Deploy SSO Sync Pipelines for Production and Staging

    master

    A 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.
  11. Use the SSO Sync CLI

    master

    The 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 debug

    Full Sync (Users and Groups):

    ./ssosync \
      --user-match "*" \
      --group-match "*" \
      --sync-method users_groups

    Excluding Specific Entities:

    ./ssosync \
      --group-match "*" \
      --ignore-users "service@company.com,bot@company.com" \
      --ignore-groups "temp-group@company.com"