Skip to content

Commit 51e2734

Browse files
authored
Upgrade to AWS SDK v2 for go1.24 (#255)
* Upgrade SDK to SDK for Go * Update buildspec.yml * feat: upgrade to AWS SDK v2 and remove default secret values - Migrated from AWS SDK Go v1 to v2 - Updated all AWS service clients to use v2 APIs - Replaced old session-based approach with config-based approach - Updated Identity Store API calls to use v2 types and methods - Implemented secret caching with AWS Secrets Manager caching library - Created new interfaces package for type definitions - Added constants package for shared constants - Updated build system to work with new dependencies - Maintained backward compatibility for CLI usage - Added comprehensive steering documentation Configuration changes: - Removed default values for all secrets in Lambda configuration - Removed SSM parameter store integration - All secrets now require explicit environment variable configuration - Simplified configuration to rely only on environment variables Breaking changes: - Internal API structure changed to use interfaces - Lambda configuration now requires explicit environment variables - Removed old mock implementations (will need regeneration) Improvements: - Better performance with secret caching - More robust error handling - Cleaner separation of concerns - Enhanced logging and debugging capabilities - More secure configuration without default fallbacks * feat: complete AWS SDK v2 migration and modernize CI/CD pipeline - Complete AWS SDK v2 migration with comprehensive test suite and mock implementations - Add extensive test coverage including integration tests and dry-run testing - Modernize CI/CD pipeline with improved buildspec.yml using Makefile targets - Enhance build system with proper caching, verbose flags, and cross-platform support - Update GoReleaser configuration and patches for better release management - Add regional settings and SAR compatibility improvements - Improve CloudFormation templates with additional IAM permissions (DescribeSecret) - Update documentation with Go 1.24+ requirement and comprehensive README - Fix dry-run implementation for AWS SDK v2 compatibility - Initialize Members slice in NewGroup function to prevent nil pointer issues - Add mockery configuration and proper mock generation setup - Enhance error handling and logging throughout the application - Improve build performance with increased vCPU allocation and optimized caching
1 parent 7ce70a4 commit 51e2734

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2827
-4386
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,22 @@ jobs:
1515
test:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- name: Check out code into the Go module directory
19-
uses: actions/checkout@v3
18+
- name: Check out code
19+
uses: actions/checkout@v4
2020

21-
- name: Setup go
21+
- name: Setup Go
2222
uses: actions/setup-go@v5
2323
with:
24-
go-version: '1.23.x'
24+
go-version: '1.24.x'
2525

26-
- name: Install staticcheck
27-
run: go install honnef.co/go/tools/cmd/staticcheck@latest
28-
29-
- name: Run staticcheck
30-
run: staticcheck ./...
26+
- name: Cache development tools
27+
uses: actions/cache@v4
28+
with:
29+
path: .bin
30+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
31+
restore-keys: |
32+
${{ runner.os }}-tools-
3133
32-
- name: Install golint
33-
run: go install golang.org/x/lint/golint@latest
34+
- name: Run tests and linters
35+
run: make ci
3436

35-
- name: Run golint
36-
run: golint ./...
37-
38-
- name: Run Tests
39-
run: go test -cover -p 1 -race -v ./...

.github/workflows/release.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,31 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Check out code into the Go module directory
13+
- name: Check out code
1414
uses: actions/checkout@v4
1515

16-
- name: Setup go
16+
- name: Setup Go
1717
uses: actions/setup-go@v5
1818
with:
19-
go-version: '1.23.x'
19+
go-version: '1.24.x'
2020

21-
- name: Install staticcheck
22-
run: go install honnef.co/go/tools/cmd/staticcheck@latest
23-
24-
- name: Run staticcheck
25-
run: staticcheck ./...
21+
- name: Cache development tools
22+
uses: actions/cache@v4
23+
with:
24+
path: .bin
25+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
26+
restore-keys: |
27+
${{ runner.os }}-tools-
2628
27-
- name: Run Tests
28-
run: go test -p 1 -cover -race -v ./...
29+
- name: Run CI pipeline
30+
run: make test-coverage
31+
32+
- name: Upload coverage HTML report
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: coverage-report
36+
path: coverage.html
37+
retention-days: 30
2938

3039
release:
3140
runs-on: ubuntu-latest
@@ -40,12 +49,17 @@ jobs:
4049
- name: Set up Go
4150
uses: actions/setup-go@v5
4251
with:
43-
go-version: '1.23.x'
44-
45-
- name: Run GoReleaser
46-
uses: goreleaser/goreleaser-action@v4
52+
go-version: '1.24.x'
53+
54+
- name: Cache development tools
55+
uses: actions/cache@v4
4756
with:
48-
version: latest
49-
args: release --clean
57+
path: .bin
58+
key: ${{ runner.os }}-tools-${{ hashFiles('Makefile') }}
59+
restore-keys: |
60+
${{ runner.os }}-tools-
61+
62+
- name: Create release
63+
run: make release
5064
env:
5165
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ ssosync
3434
# Noise from os/editors
3535
.DS_Store
3636
*.swp
37-
*/.DS_Store
38-
cicd/.DS_Store
3937
release.yaml
4038
staging.yaml
4139
*.orig
4240
*.rej
4341
cicd/.DS_Store
4442
*.swo
4543
cicd/.DS_Store
44+
mocks_*.go
45+
.bin/
46+
out/
47+
dist/
48+
bin/
49+
node_modules/
50+
coverage/
51+
coverage.out
52+
.pnpm-store
53+
.secrets.json
54+
google-service-account.json

.goreleaser.yml

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,61 @@
1-
# .goreleaser.yml
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
22
project_name: ssosync
3+
version: 2
34

45
before:
56
hooks:
67
- go mod download
8+
gomod:
9+
env:
10+
- GOPROXY=direct
711
builds:
8-
- env:
9-
- CGO_ENABLED=0
10-
goos:
11-
- linux
12-
- darwin
13-
- windows
14-
goarch:
15-
- 386
16-
- amd64
17-
- arm
18-
- arm64
19-
ignore:
20-
- goos: darwin
21-
goarch: 386
22-
- goos: windows
23-
goarch: 386
24-
ldflags:
25-
- -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
12+
- id: ssosync
13+
env:
14+
- CGO_ENABLED=0
15+
goos:
16+
- linux
17+
- darwin
18+
- windows
19+
goarch:
20+
- "386"
21+
- amd64
22+
- arm
23+
- arm64
24+
goarm64:
25+
- v8.0
26+
goamd64:
27+
- v1
28+
goarm:
29+
- "6"
30+
ignore:
31+
- goos: darwin
32+
goarch: "386"
33+
- goos: windows
34+
goarch: "386"
35+
flags:
36+
- -trimpath
37+
ldflags:
38+
- -s -w -X github.com/awslabs/ssosync/cmd.version={{.Version}} -X github.com/awslabs/ssosync/cmd.commit={{.FullCommit}} -X github.com/awslabs/ssosync/cmd.date={{.Date}} -X github.com/awslabs/ssosync/cmd.builtBy=goreleaser
39+
40+
upx:
41+
- enabled: true
42+
ids: [ssosync]
43+
goos: [linux]
44+
goarch: [arm, arm64, amd64]
45+
compress: best
46+
lzma: true
47+
binary: .bin/upx
48+
2649
checksum:
27-
name_template: '{{ .ProjectName }}_checksums.txt'
50+
name_template: "{{ .ProjectName }}_checksums.txt"
2851
changelog:
2952
sort: asc
3053
filters:
3154
exclude:
32-
- '^docs:'
33-
- '^test:'
34-
- Merge pull request
35-
- Merge branch
55+
- "^docs:"
56+
- "^test:"
57+
- Merge pull request
58+
- Merge branch
3659
archives:
3760
- name_template: >-
3861
{{- .ProjectName }}_
@@ -42,6 +65,8 @@ archives:
4265
{{- else }}{{ .Arch }}{{ end }}
4366
{{- if .Arm }}v{{ .Arm }}{{ end -}}
4467
format_overrides:
45-
- goos: windows
46-
format: zip
47-
68+
- goos: windows
69+
formats:
70+
- zip
71+
snapshot:
72+
version_template: "{{ incpatch .Version }}-{{ .ShortCommit }}"

.kiro/steering/product.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Product Overview
2+
3+
SSO Sync is a CLI tool and AWS Lambda function that synchronizes Google Workspace (formerly G Suite) users and groups to AWS IAM Identity Center (formerly AWS SSO).
4+
5+
## Purpose
6+
- Enables automatic provisioning of Google Workspace users and groups into AWS SSO
7+
- Provides uni-directional sync from Google Workspace to AWS
8+
- Supports both CLI execution and serverless Lambda deployment
9+
- Handles user lifecycle management (create, update, delete, suspend)
10+
11+
## Key Features
12+
- Two sync methods: `groups` (default) and `users_groups`
13+
- Flexible filtering with Google API query parameters
14+
- Support for ignoring specific users/groups
15+
- Dry-run capability for testing
16+
- Cross-account deployment patterns
17+
- Integration with AWS CodePipeline
18+
- Comprehensive logging and error handling
19+
20+
## Deployment Options
21+
- Local CLI execution
22+
- AWS Lambda via Serverless Application Repository
23+
- AWS SAM deployment
24+
- Multiple CloudFormation deployment patterns (app+secrets, app-only, cross-account)
25+
26+
## Target Users
27+
Organizations using Google Workspace as their identity provider who want to centrally manage AWS access through IAM Identity Center.

.kiro/steering/structure.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Project Structure
2+
3+
## Root Level
4+
- `main.go` - Application entry point
5+
- `go.mod/go.sum` - Go module dependencies
6+
- `Makefile` - Build automation and common tasks
7+
- `template.yaml` - AWS SAM CloudFormation template
8+
- `.goreleaser.yml` - Cross-platform build configuration
9+
10+
## Core Application (`cmd/`)
11+
- `cmd/root.go` - Cobra CLI setup, Lambda handler, and configuration initialization
12+
- Contains version information and command-line flag definitions
13+
14+
## Internal Packages (`internal/`)
15+
16+
### `internal/aws/`
17+
- AWS-specific client implementations
18+
- `client.go` - SCIM API client for AWS SSO
19+
- `client_dry.go` - Dry-run implementation for testing
20+
- `users.go`, `groups.go` - User and group management logic
21+
- `schema.go` - SCIM schema definitions
22+
- `mock/` - Mock implementations for testing
23+
24+
### `internal/config/`
25+
- `config.go` - Configuration structure and defaults
26+
- `secrets.go` - AWS Secrets Manager integration
27+
28+
### `internal/google/`
29+
- `client.go` - Google Workspace Directory API client
30+
31+
### `internal/mocks/`
32+
- Generated mock interfaces for testing
33+
34+
### Root `internal/`
35+
- `sync.go` - Core synchronization logic and orchestration
36+
- `sync_test.go` - Synchronization tests
37+
38+
## CI/CD (`cicd/`)
39+
- `build/` - Build pipeline configurations
40+
- `cloudformation/` - Infrastructure templates
41+
- `deploy_patterns/` - Different deployment configurations
42+
- `release/` - Release automation
43+
- `tests/` - Integration and end-to-end tests
44+
45+
## Conventions
46+
47+
### Package Organization
48+
- `internal/` for private packages not intended for external use
49+
- Service-specific packages (`aws/`, `google/`) for API integrations
50+
- Separate test files alongside implementation files
51+
52+
### Naming Patterns
53+
- Interface types end with `Client` or `API`
54+
- Mock implementations prefixed with `Mock`
55+
- Test files use `_test.go` suffix
56+
- Dry-run implementations use `_dry.go` suffix
57+
58+
### Configuration
59+
- Environment variables use `SSOSYNC_` prefix
60+
- Configuration struct in `internal/config/config.go`
61+
- Secrets handled separately from regular config
62+
63+
### Error Handling
64+
- Custom error types in service packages
65+
- Structured logging with contextual fields
66+
- Graceful degradation for non-critical failures

.kiro/steering/tech.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Technology Stack
2+
3+
## Language & Runtime
4+
- **Go 1.17+** - Primary programming language
5+
- **AWS Lambda Runtime**: `provided.al2` on ARM64 architecture
6+
- Cross-platform support (Linux, macOS, Windows)
7+
8+
## Key Dependencies
9+
- **AWS SDK Go v2** - AWS service interactions
10+
- **Google Admin SDK** - Google Workspace API access
11+
- **Cobra** - CLI framework and command handling
12+
- **Viper** - Configuration management
13+
- **Logrus** - Structured logging
14+
- **GoMock** - Testing and mocking
15+
16+
## AWS Services
17+
- **IAM Identity Center** (Identity Store API) - User/group management
18+
- **AWS Lambda** - Serverless execution
19+
- **AWS Secrets Manager** - Credential storage
20+
- **AWS KMS** - Secret encryption
21+
- **CloudWatch Events** - Scheduled execution
22+
23+
## Build System & Tools
24+
- **Make** - Build automation
25+
- **GoReleaser** - Cross-platform binary releases
26+
- **AWS SAM** - Serverless application deployment
27+
- **CloudFormation** - Infrastructure as Code
28+
29+
## Common Commands
30+
31+
### Development
32+
```bash
33+
# Install dependencies
34+
make install
35+
36+
# Build locally
37+
make go-build
38+
39+
# Run tests
40+
make test
41+
42+
# Clean build artifacts
43+
make clean
44+
```
45+
46+
### Lambda Development
47+
```bash
48+
# Build for Lambda
49+
make lambda
50+
51+
# Package for deployment
52+
make package
53+
54+
# Deploy with SAM
55+
sam build
56+
sam deploy --guided
57+
```
58+
59+
### Release
60+
```bash
61+
# Create release binaries
62+
goreleaser build --snapshot --rm-dist
63+
64+
# Validate CloudFormation template
65+
aws cloudformation validate-template --template-body file://template.yaml
66+
```
67+
68+
## Configuration
69+
- Environment variables with `SSOSYNC_` prefix
70+
- AWS credentials via standard AWS credential chain
71+
- Google service account JSON credentials
72+
- Supports both file-based and AWS Secrets Manager configuration

0 commit comments

Comments
 (0)