The Process
- Authenticate with GitHub via GitHub App credentials (env vars).
- Query the organisation members via GraphQL using
github-api-toolkit. - Build username↔email mappings and username→id mapping.
- Write three JSON files to the configured S3 bucket under
AddressBook/. - Log progress and errors; failures surface in CloudWatch.
See Configuration for required environment variables.
Detailed Steps
- Initialise logging and read required environment variables.
- Establish GitHub App authentication and create GraphQL requests (via
github-api-toolkit). - Retrieve organisation members and their verified organisation email addresses and account IDs, using pagination.
- Build three dictionaries:
- username → list of verified org emails
- email → username
- username → GitHub account ID
- Convert the dictionaries to JSON.
- Write JSON files to S3 under the
AddressBook/prefix.
Key Components
src/lambda_function.py: Orchestrates the run and calls downstream helpers.src/github_services.py: Handles GitHub GraphQL interactions viagithub-api-toolkit.src/s3writer.py: Writes JSON outputs to S3.src/logger.py: Provides structured logging.
Error Handling & Observability
- All major steps are logged; inspect CloudWatch Logs for failures or anomalies.
- Ensure the Lambda role has
s3:PutObjectto the target bucket/prefix; access issues will surface during S3 writes. - Verify GitHub App installation and credentials if API calls fail.
Outputs
- Files are written to S3 under the
AddressBook/prefix: addressBookUsernameKey.jsonaddressBookEmailKey.jsonaddressBookIDKey.json
Return to the overview: Overview or dive deeper into configuration: Configuration.