Skip to content

Commit 2a17a47

Browse files
committed
Merge branch 'master' into filter-aws-groups
2 parents 6873714 + b9be762 commit 2a17a47

File tree

30 files changed

+1772
-312
lines changed

30 files changed

+1772
-312
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ ssosync
3434
# Noise from os/editors
3535
.DS_Store
3636
*.swp
37+
*/.DS_Store
38+
cicd/.DS_Store
39+
release.yaml
40+
staging.yaml
41+
*.orig
42+
*.rej
43+
cicd/.DS_Store

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ go-build:
2020
clean:
2121
rm -f $(OUTPUT) $(PACKAGED_TEMPLATE)
2222

23+
build-SSOSyncFunction:
24+
GOOS=linux GOARCH=arm64 go build -o bootstrap main.go
25+
cp ./bootstrap $(ARTIFACTS_DIR)/.
26+
2327
.PHONY: install
2428
install:
2529
go get ./...

README.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,25 @@
1010
1111
SSO Sync will run on any platform that Go can build for. It is available in the [AWS Serverless Application Repository](https://console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync)
1212

13-
> :warning: there are breaking changes for versions `>= 0.02`
13+
> [!CAUTION]
14+
> When using ssosync with an instance or IAM Identity Center integrated with AWS Control Tower. AWS Control Tower creates a number of groups and users (directly via the Identity Store API), when an external identity provider is configured these users and groups are can not be used to log in. However it is important to remember that because ssosync implemements a uni-directional sync it will make the IAM Identity Store match the subset of your Google Workspaces directory you specify, including removing these groups and users created by AWS Control Tower. There is a PFR [#88 - ssosync deletes Control Tower groups](https://github.com/awslabs/ssosync/issues/88) to implement an option to ignore these users and groups, hopefully this will be implemented in version 3.x.
1415
15-
> :warning: `>= 1.0.0-rc.5` groups to do not get deleted in AWS SSO when deleted in the Google Directory, and groups are synced by their email address
16+
> [!WARNING]
17+
> There are breaking changes for versions `>= 0.02`
1618
17-
> :warning: `>= 2.0.0` this makes use of the **Identity Store API** which means:
18-
* if deploying the lambda from the [AWS Serverless Application Repository](https://console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync) then it needs to be deployed into the [IAM Identity Center delegated administration](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html) account. Technically you could deploy in the management account but we would recommend against this.
19-
* if you are running the project as a cli tool, then the environment will need to be using credentials of a user in the [IAM Identity Center delegated administration](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html) account, with appropriate permissions.
19+
> [!WARNING]
20+
> `>= 1.0.0-rc.5` groups to do not get deleted in AWS SSO when deleted in the Google Directory, and groups are synced by their email address
21+
22+
> [!WARNING]
23+
> `>= 2.0.0` this makes use of the **Identity Store API** which means:
24+
> * if deploying the lambda from the [AWS Serverless Application Repository](https://console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync) then it needs to be deployed into the [IAM Identity Center delegated administration](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html) account. Technically you could deploy in the management account but we would recommend against this.
25+
> * if you are running the project as a cli tool, then the environment will need to be using credentials of a user in the [IAM Identity Center delegated administration](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html) account, with appropriate permissions.
26+
27+
> [!WARNING]
28+
> `>= 2.1.0` make use of named IAM resources, so if deploying via CICD or IaC template will require **CAPABILITY_NAMED_IAM** to be specified.
29+
30+
> [!IMPORTANT]
31+
> `>= 2.1.0` switched to using `provided.al2` powered by ARM64 instances.
2032
2133
## Why?
2234

@@ -161,22 +173,49 @@ Flags Notes:
161173
* `--group-match` works for both `--sync-method` values and also in combination with `--ignore-groups` and `--ignore-users`. This is the filter query passed to the [Google Workspace Directory API when search Groups](https://developers.google.com/admin-sdk/directory/v1/guides/search-groups), if the flag is not used, groups are not filtered.
162174
* `--user-match` works for both `--sync-method` values and also in combination with `--ignore-groups` and `--ignore-users`. This is the filter query passed to the [Google Workspace Directory API when search Users](https://developers.google.com/admin-sdk/directory/v1/guides/search-users), if the flag is not used, users are not filtered.
163175

164-
NOTES:
165-
166-
1. Depending on the number of users and groups you have, maybe you can get `AWS SSO SCIM API rate limits errors`, and more frequently happens if you execute the sync many times in a short time.
167-
2. Depending on the number of users and groups you have, `--debug` flag generate too much logs lines in your AWS Lambda function. So test it in locally with the `--debug` flag enabled and disable it when you use a AWS Lambda function.
176+
> [!NOTE]
177+
> 1. Depending on the number of users and groups you have, maybe you can get `AWS SSO SCIM API rate limits errors`, and more frequently happens if you execute the sync many times in a short time.
178+
> 2. Depending on the number of users and groups you have, `--debug` flag generate too much logs lines in your AWS Lambda function. So test it in locally with the `--debug` flag enabled and disable it when you use a AWS Lambda function.
168179
169180
## AWS Lambda Usage
170181

171-
NOTE: Using Lambda may incur costs in your AWS account. Please make sure you have checked
182+
> [!TIP]
183+
> Using Lambda may incur costs in your AWS account. Please make sure you have checked
172184
the pricing for AWS Lambda and CloudWatch before continuing.
173185

174186
Additionally, before choosing to deploy with Lambda, please ensure that the [AWS Lambda SLAs](https://aws.amazon.com/lambda/sla/) are sufficient for your use cases.
175187

176188
Running ssosync once means that any changes to your Google directory will not appear in
177189
AWS SSO. To sync regularly, you can run ssosync via AWS Lambda.
178190

179-
:warning: You find it in the [AWS Serverless Application Repository](https://eu-west-1.console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync).
191+
> [!WARNING]
192+
> You find it in the [AWS Serverless Application Repository](https://eu-west-1.console.aws.amazon.com/lambda/home#/create/app?applicationId=arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync).
193+
194+
> [!TIP]
195+
> ### v2.1 Changes
196+
> * user and group selection fields in the Cloudformation template can now be left empty where not required and will not be added as environment variables to the Lambda function, this provides consistency with CLI use of ssosync.
197+
> * Stronger validation of parameters in the Cloudformation template, to improve likelhood of success for new users.
198+
> * Now supports multiple deployment patterns, defaults are consistent with previous versions.
199+
200+
**App + secrets** This is the default mode and fully backwards compatible with previous versions
201+
202+
**App only** This mode does not create the secrets but expects you to deployed a separate stack using the **Secrets only** mode within the same account
203+
> [!CAUTION]
204+
> If you want to use your own existing secrets then provide them as a comma separated list in the ##CrossStackConfigI## field in the following order:
205+
> __GoogleCredentials ARN__,__GoogleAdminEmail ARN__,__SCIMEndpoint ARN__,__SCIMAccessToken ARN__,__Region ARN__,__IdentityStoreID ARN__
206+
>
207+
**App for cross-account** This mode is used where you have deployed the secrets in a separate account, the arns of the KMS key and secrets need to be passed into the __CrossStackConfig__ field, It is easiest to have created the secrets in the other account using the ** Secrest for cross-account** mode, as the output can simply copied and pasted into the above field.
208+
209+
> [!CAUTION]
210+
> If you want to use your own existing secrets then provide them as a comma separated list in the __CrossStackConfig__ field in the following order:
211+
> __GoogleCredentials ARN__,__GoogleAdminEmail ARN__,__SCIMEndpoint ARN__,__SCIMAccessToken ARN__,__Region ARN__,__IdentityStoreID ARN__,__KMS Key ARN__
212+
213+
> [!IMPORTANT]
214+
> Be sure to allow access to the key and secrets in their respective policies to the role __SSOSyncAppRole__ in the app account.
215+
216+
**Secrets only** This mode creates a set of secrets but does not deploy the app itself, it requires the app is deployed in that same account using the **App only** mode. This allows for decoupling of the secrets and the app.
217+
218+
**Secrets for cross-account** This mode creates a set of secrets and KMS key but does not deploy the app itself, this is for use with an app stack, deployed using the **App for cross-account** mode. This allows for a single set of secrets to be shared with multipl app instance for testing, and improve secrets security.
180219

181220
## SAM
182221

cicd/.DS_Store

-2 KB
Binary file not shown.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
version: 0.2
2+
3+
phases:
4+
5+
build:
6+
commands:
7+
# Create parameters
8+
- export AppVersion="${GitTag#v}-${GitVersionHash}"
9+
10+
# Copy in the executable
11+
- cp ${CODEBUILD_SRC_DIR_Built}/dist/ssosync_linux_amd64_v1/ssosync ./
12+
13+
# Copy in the tests
14+
- cp -r cicd/tests ./
15+
16+
# Copy in the stack and params templates
17+
- mkdir deploy
18+
- cp cicd/account_execution/staging/stack.yml ./deploy/
19+
20+
# Update params with the values for this run for a developer account
21+
- |
22+
jq -n \
23+
--argjson Parameters "{\"AppArn\": \"$AppArn\", \"AppVersion\": \"$AppVersion\", \"GoogleAdminEmailArn\": \"$SecretGoogleAdminEmail\", \"GoogleCredentialsArn\": \"$SecretGoogleCredentials\", \"SCIMEndpointUrlArn\": \"$SecretSCIMEndpoint\", \"SCIMAccessTokenArn\": \"$SecretSCIMAccessToken\", \"RegionArn\": \"$SecretRegion\", \"IdentityStoreIdArn\": \"$SecretIdentityStoreID\", \"GroupMatch\": \"name:AWS*\"}" \
24+
--argjson StackPolicy "{\"Statement\":[{\"Effect\": \"Allow\", \"NotAction\": \"Update:Delete\", \"Principal\": \"*\", \"Resource\": \"*\"}]}" \
25+
'$ARGS.named' > ./deploy/developer.json
26+
- cat ./deploy/developer.json
27+
28+
# Update params with the values for this run for the management account
29+
- |
30+
jq -n \
31+
--argjson Parameters "{\"AppArn\": \"$AppArn\", \"AppVersion\": \"$AppVersion\", \"GoogleAdminEmailArn\": \"$SecretGoogleAdminEmail\", \"GoogleCredentialsArn\": \"$SecretGoogleCredentials\", \"SCIMEndpointUrlArn\": \"$SecretSCIMEndpoint\", \"SCIMAccessTokenArn\": \"$SecretSCIMAccessToken\", \"RegionArn\": \"$SecretRegion\", \"IdentityStoreIdArn\": \"$SecretIdentityStoreID\", \"GroupMatch\": \"name:Man*\"}" \
32+
--argjson StackPolicy "{\"Statement\":[{\"Effect\": \"Allow\", \"NotAction\": \"Update:Delete\", \"Principal\": \"*\", \"Resource\": \"*\"}]}" \
33+
'$ARGS.named' > ./deploy/management.json
34+
- cat ./deploy/management.json
35+
36+
# Update params with the values for this run for the delegated account
37+
- |
38+
jq -n \
39+
--argjson Parameters "{\"AppArn\": \"$AppArn\", \"AppVersion\": \"$AppVersion\", \"GoogleAdminEmailArn\": \"$SecretGoogleAdminEmail\", \"GoogleCredentialsArn\": \"$SecretGoogleCredentials\", \"SCIMEndpointUrlArn\": \"$SecretSCIMEndpoint\", \"SCIMAccessTokenArn\": \"$SecretSCIMAccessToken\", \"RegionArn\": \"$SecretRegion\", \"IdentityStoreIdArn\": \"$SecretIdentityStoreID\", \"GroupMatch\": \"name:Del*\"}" \
40+
--argjson StackPolicy "{\"Statement\":[{\"Effect\": \"Allow\", \"NotAction\": \"Update:Delete\", \"Principal\": \"*\", \"Resource\": \"*\"}]}" \
41+
'$ARGS.named' > ./deploy/delegated.json
42+
- cat ./deploy/delegated.json
43+
44+
# Update params with the values for this run for non-delegated account
45+
- |
46+
jq -n \
47+
--argjson Parameters "{\"AppArn\": \"$AppArn\", \"AppVersion\": \"$AppVersion\", \"GoogleAdminEmailArn\": \"$SecretGoogleAdminEmail\", \"GoogleCredentialsArn\": \"$SecretGoogleCredentials\", \"SCIMEndpointUrlArn\": \"$SecretSCIMEndpoint\", \"SCIMAccessTokenArn\": \"$SecretSCIMAccessToken\", \"RegionArn\": \"$SecretRegion\", \"IdentityStoreIdArn\": \"$SecretIdentityStoreID\", \"GroupMatch\": \"name:Non*\"}" \
48+
--argjson StackPolicy "{\"Statement\":[{\"Effect\": \"Allow\", \"NotAction\": \"Update:Delete\", \"Principal\": \"*\", \"Resource\": \"*\"}]}" \
49+
'$ARGS.named' > ./deploy/nondelegated.json
50+
- cat ./deploy/nondelegated.json
51+
52+
53+
artifacts:
54+
files:
55+
- ssosync
56+
- deploy/**/*
57+
- tests/**/*
File renamed without changes.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: 'AWS::Serverless-2016-10-31'
3+
4+
Description:
5+
This CloudFormation template will deploy an instance of the SSOSync-Staging
6+
candidate releases (via privately shared app in the AWS Serverless Application
7+
Repository (SAR) within the Staging Account.
8+
9+
Parameters:
10+
AppArn:
11+
Description: The candidate release in the SAR
12+
Default: 'arn:aws:serverlessrepo:<AWS::Region>:<AccountId>:applications/<ApplicationName>'
13+
Type: String
14+
AppVersion:
15+
Description: The version of this build in SAR
16+
Default: 'v1.0.0-rc.10'
17+
Type: String
18+
GoogleAdminEmailArn:
19+
Type: String
20+
GoogleCredentialsArn:
21+
Type: String
22+
SCIMEndpointUrlArn:
23+
Type: String
24+
SCIMAccessTokenArn:
25+
Type: String
26+
RegionArn:
27+
Type: String
28+
IdentityStoreIdArn:
29+
Type: String
30+
GroupMatch:
31+
Description: The search string to match Groups in Google Workspace
32+
Default: 'name:AWS*'
33+
Type: String
34+
35+
Resources:
36+
SARApp:
37+
Type: AWS::Serverless::Application
38+
Properties:
39+
Location:
40+
ApplicationId: !Ref AppArn
41+
SemanticVersion: !Ref AppVersion
42+
Parameters:
43+
FunctionName: SSOSyncFunction
44+
GoogleAdminEmail: !Join
45+
- ''
46+
- - '{{resolve:secretsmanager:'
47+
- !Ref GoogleAdminEmailArn
48+
- '}}'
49+
GoogleCredentials: !Join
50+
- ''
51+
- - '{{resolve:secretsmanager:'
52+
- !Ref GoogleCredentialsArn
53+
- '}}'
54+
SCIMEndpointUrl: !Join
55+
- ''
56+
- - '{{resolve:secretsmanager:'
57+
- !Ref SCIMEndpointUrlArn
58+
- '}}'
59+
SCIMEndpointAccessToken: !Join
60+
- ''
61+
- - '{{resolve:secretsmanager:'
62+
- !Ref SCIMAccessTokenArn
63+
- '}}'
64+
Region: !Join
65+
- ''
66+
- - '{{resolve:secretsmanager:'
67+
- !Ref RegionArn
68+
- '}}'
69+
IdentityStoreID: !Join
70+
- ''
71+
- - '{{resolve:secretsmanager:'
72+
- !Ref IdentityStoreIdArn
73+
- '}}'
74+
SyncMethod: groups
75+
GoogleGroupMatch: !Ref GroupMatch
76+
LogLevel: warn
77+
LogFormat: json

cicd/staging/testing/buildspec.yml renamed to cicd/account_execution/testing/buildspec.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: 0.2
33
env:
44
variables:
55
ShareWith: "NOT-SHARED"
6-
pipeline: "SSOSync-Test"
76
interval: 10
87
Success: '"Succeeded"'
98
InProgress: '"InProgress"'

cicd/build/build/buildspec.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@ env:
88
phases:
99
install:
1010
commands:
11+
# Add goreleaser repo
12+
- echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
13+
14+
# Update the repos
15+
- apt -qq --yes update
16+
- apt -qq --yes upgrade
17+
1118
# Install go.lang
1219
- GoVersion=${GOLANG_20_VERSION}
1320

14-
# Install golint
21+
# Install golint - now deprecated
1522
- go install golang.org/x/lint/golint@latest
1623

17-
# Install staticcheck
18-
- go install honnef.co/go/tools/cmd/staticcheck@latest
24+
# Install staticcheck - use static install from tarball
25+
- wget -qO- https://github.com/dominikh/go-tools/releases/download/2023.1.6/staticcheck_linux_386.tar.gz | tar -xvz -C ./
1926

2027
# Install Testify to use common assertions and mocks in tests
21-
- go get -u github.com/stretchr/testify
28+
- go get github.com/stretchr/testify
2229

23-
# Install goreleaser
24-
- go install github.com/goreleaser/goreleaser@latest
30+
# Install goreleaser - go install method broken due to dependancies using apt static binary approach
31+
# - go install github.com/goreleaser/goreleaser@latest
32+
- apt -qq --yes install goreleaser
2533

2634
pre_build:
2735
commands:
@@ -33,7 +41,7 @@ phases:
3341
- go get ./...
3442

3543
# Run staticcheck
36-
- staticcheck ./...
44+
- staticcheck/staticcheck ./...
3745

3846
# Ensure code passes all lint tests
3947
#- golint -set_exit_status ./...
@@ -63,8 +71,8 @@ phases:
6371
# Tweak the .goreleaser.yml so it uses the vairables from .Env
6472
- patch .goreleaser.yml cicd/build/build/goreleaser.patch
6573

66-
# Make main but only for the lambda (linux amd64)
67-
- goreleaser build --snapshot --rm-dist --single-target
74+
# Make main
75+
- goreleaser build --snapshot --clean
6876

6977

7078
# Check we've packaged something useful

cicd/build/build/goreleaser.patch

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
--- .goreleaser.yml 2022-06-15 08:38:24.000000000 +0100
2-
+++ .goreleaser-codebuild.yml 2022-06-21 12:33:43.000000000 +0100
3-
@@ -22,7 +22,7 @@
4-
- goos: windows
5-
goarch: 386
1+
--- .goreleaser.yml.default 2023-10-25 11:30:58
2+
+++ .goreleaser.yml 2023-10-25 11:32:18
3+
@@ -9,20 +9,11 @@
4+
- CGO_ENABLED=0
5+
goos:
6+
- linux
7+
- - darwin
8+
- - windows
9+
goarch:
10+
- - 386
11+
- amd64
12+
- - arm
13+
- arm64
14+
- ignore:
15+
- - goos: darwin
16+
- goarch: 386
17+
- - goos: windows
18+
- goarch: 386
619
ldflags:
720
- - -s -w -X github.com/awslabs/ssosync/cmd.version={{.Version}} -X github.com/awslabs/ssosync/cmd.commit={{.Commit}} -X github.com/awslabs/ssosync/cmd.date={{.Date}} -X github.com/awslabs/ssosync/cmd.builtBy=goreleaser
821
+ - -s -w -X github.com/awslabs/ssosync/cmd.version={{.Env.GitTag}} -X github.com/awslabs/ssosync/cmd.commit={{.Env.GitCommit}} -X github.com/awslabs/ssosync/cmd.date={{.Date}} -X github.com/awslabs/ssosync/cmd.builtBy=goreleaser -X github.com/awslabs/ssosync/cmd.goversion={{.Env.GoVersion}}

0 commit comments

Comments
 (0)