This repository uses AWS Serverless Application Model (AWS SAM) in two ways:
- To deploy
idp-scim-syncprivately from source into your own AWS account. - To publish public versions to the AWS Serverless Application Repository.
The same template.yaml drives both workflows.
- template.yaml defines the Lambda function, EventBridge schedule, Secrets Manager secrets, S3 state bucket, KMS key, IAM role, and CloudWatch log group.
- The template includes
AWS::ServerlessRepo::Applicationmetadata so the application can be published to the AWS Serverless Application Repository. - The Lambda build uses
Metadata: BuildMethod: makefile, sosam buildcalls thebuild-LambdaFunctiontarget from Makefile. - That build target compiles cmd/idpscim/main.go into a
bootstrapbinary for theprovided.al2023runtime onarm64. - Maintainer publishing is automated in .github/workflows/aws-sam.yml.
Before using SAM in this repository, install and configure the following:
- AWS CLI
- AWS SAM CLI
- Go
make- AWS credentials with permission to create CloudFormation, Lambda, EventBridge, IAM, Secrets Manager, S3, CloudWatch Logs, and KMS resources
- Google Workspace service account credentials and delegated user email
- AWS IAM Identity Center SCIM endpoint and access token
Recommended environment variables:
export AWS_PROFILE=<profile-name>
export AWS_REGION=us-east-1For publishing public versions, you also need:
export SAM_APP_BUCKET=<artifact-bucket-name>
export SAM_APP_VERSION=<semantic-version>Use SAM and CloudFormation validation before deploying:
aws cloudformation validate-template \
--template-body file://template.yaml \
--profile "$AWS_PROFILE"
sam validate \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"
GIT_VERSION=dev sam build \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"sam build creates .aws-sam/build/LambdaFunction/bootstrap by invoking the repository Makefile.
For private deployments from source, use sam deploy --guided the first time. It is the safest option because this template includes secret values such as the Google Workspace credential JSON and the SCIM token.
sam deploy --guided \
--stack-name idp-scim-sync \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"During the guided prompts, provide at least these required values:
| Parameter | Purpose |
|---|---|
GWSServiceAccountFile |
Full contents of the Google Workspace service account JSON |
GWSUserEmail |
Delegated Google Workspace administrator or service user email |
SCIMEndpoint |
AWS IAM Identity Center SCIM endpoint URL |
SCIMAccessToken |
AWS IAM Identity Center SCIM bearer token |
Common optional parameters you will usually adjust:
| Parameter | Purpose | Default |
|---|---|---|
GWSGroupsFilter |
Restrict which Google Workspace groups are synchronized | empty |
SyncUserFields |
Comma-separated optional user attributes to sync | empty = all supported fields |
ScheduleExpression |
EventBridge execution schedule | rate(15 minutes) |
BucketNamePrefix |
Prefix for the state bucket name | idp-scim-sync-state |
BucketKey |
S3 object key for the state file | data/state.json |
MemorySize |
Lambda memory | 256 |
Timeout |
Lambda timeout in seconds | 300 |
LogLevel |
Application log level | info |
LogFormat |
Lambda log format | json |
After the first guided deploy, SAM stores the deployment configuration. Subsequent updates are usually just:
GIT_VERSION=dev sam build \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"
sam deploy \
--stack-name idp-scim-sync \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"This project is also published to the public AWS Serverless Application Repository:
The important AWS behavior to remember is this:
- When you deploy an application from the AWS Serverless Application Repository, AWS creates a CloudFormation stack whose actual name is prefixed with
serverlessrepo-. - When you update that application later, you must reuse the original application name or stack name that you entered when you first deployed it.
- Do not enter the generated
serverlessrepo-...stack name during the update flow.
Example:
- Original name you entered:
idp-scim-sync - Actual CloudFormation stack created by AWS:
serverlessrepo-idp-scim-sync - Name to use for future updates:
idp-scim-sync
For most users, the console update flow is the clearest option:
- Open the published application page in the AWS Serverless Application Repository.
- Choose
Deployagain for the same application. - Enter the same application name you used the first time, without the
serverlessrepo-prefix. - Select the newer published application version.
- Keep the existing parameter values or change them as needed.
- Acknowledge IAM capabilities if prompted.
- Deploy the update.
Use this flow when you want to move to a new published version without building from source locally.
If you automate updates, the AWS Serverless Application Repository docs use a CloudFormation change set flow:
- Inspect the application and required capabilities.
- Create a CloudFormation change set for the same original stack name.
- Execute that change set.
Example skeleton:
export AWS_REGION=us-east-1
export APPLICATION_ID=arn:aws:serverlessrepo:us-east-1:889836709304:applications/idp-scim-sync
aws serverlessrepo get-application \
--application-id "$APPLICATION_ID" \
--region "$AWS_REGION"
CHANGE_SET_ID=$(aws serverlessrepo create-cloud-formation-change-set \
--application-id "$APPLICATION_ID" \
--stack-name idp-scim-sync \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--region "$AWS_REGION" \
--query ChangeSetId \
--output text)
aws cloudformation execute-change-set \
--change-set-name "$CHANGE_SET_ID" \
--region "$AWS_REGION"If your deployment requires explicit parameter overrides, include them when creating the change set. Reuse the same stack name you originally deployed with, not the generated serverlessrepo-... name.
This section is only for project maintainers who publish new versions of the application.
Package the application artifacts:
sam package \
--output-template-file packaged.yaml \
--s3-bucket "$SAM_APP_BUCKET" \
--profile "$AWS_PROFILE" \
--region "$AWS_REGION"Publish the packaged template as a new semantic version:
sam publish \
--semantic-version "$SAM_APP_VERSION" \
--template packaged.yaml \
--region us-east-1 \
--profile "$AWS_PROFILE"Then make the published application deployable by other AWS accounts:
AWS_SAM_APP_ARN=$(aws serverlessrepo list-applications \
--max-items 100 \
--region us-east-1 \
--profile "$AWS_PROFILE" \
| jq -c '.Applications[] | select(.ApplicationId | contains("idp-scim-sync"))' \
| jq -r '.ApplicationId')
aws serverlessrepo put-application-policy \
--application-id "$AWS_SAM_APP_ARN" \
--statements Principals='*',Actions='Deploy' \
--region us-east-1 \
--profile "$AWS_PROFILE"The repository CI workflow in .github/workflows/aws-sam.yml already automates this process for tagged releases.
If you need to delete the published application from the AWS Serverless Application Repository:
AWS_SAM_APP_ARN=$(aws serverlessrepo list-applications \
--max-items 100 \
--region us-east-1 \
--profile "$AWS_PROFILE" \
| jq -c '.Applications[] | select(.ApplicationId | contains("idp-scim-sync"))' \
| jq -r '.ApplicationId')
aws serverlessrepo delete-application \
--application-id "$AWS_SAM_APP_ARN" \
--region us-east-1 \
--profile "$AWS_PROFILE"