README
¶
AWS Lambda Deployment
This command runs github-ops-app as an AWS Lambda function. It serves the same routes as the HTTP server; see the main README for the configuration and the other ways to run it. The terraform-aws-github-ops-app module deploys everything below.
Events
- API Gateway HTTP API (payload format 2.0) requests carry GitHub webhooks, Slack slash commands, and admin requests. They are converted to HTTP requests, with their query string, headers, cookies, and base64 bodies, and served by the same router as the server.
- EventBridge events run a scheduled action named in their detail. AWS authorizes these invocations, so they don't need the admin token.
- Jobs started by the slash command run in an asynchronous invocation of
the function itself, since Slack waits only three seconds for an answer
and an invocation ends when it answers. The event is
{"github_ops_app_job": {"action": "okta-sync", ...}}. A failed job replies to who asked and is logged, but doesn't fail the invocation, so Lambda doesn't retry it.
The configuration loads on the first invocation. If it fails, such as when an SSM parameter is unavailable, it is retried on the next invocation instead of leaving the container broken until it is recycled.
Build
# from the repository root; GOARCH=arm64 for arm64 functions
make build-lambda
cd dist && zip ../bootstrap.zip bootstrap
Releases attach github-ops-app_lambda_amd64.zip and
github-ops-app_lambda_arm64.zip.
Deploy
Function
| Setting | Value |
|---|---|
| Runtime | provided.al2023 |
| Handler | bootstrap |
| Architecture | x86_64 or arm64, matching the build |
| Memory | 256 MB |
| Timeout | 5 minutes or more, so a full Okta sync can finish |
| Role | AWSLambdaBasicExecutionRole, plus ssm:GetParameter |
Set the configuration as environment variables. Keep secrets in SSM Parameter Store and set their variables to the parameter ARNs, so they don't appear in the function's configuration.
Some features need more of the role:
| Feature | Permission |
|---|---|
| Slash command | lambda:InvokeFunction on the function itself |
APP_REPORT_REPEAT=daily |
ssm:GetParameter, ssm:PutParameter on the prefix |
| Installer or Slack setup | ssm:PutParameter on AWS_SSM_PARAMETER_PREFIX |
Daily reports need APP_STATE_SSM_PREFIX, such as /github-ops-app/state/,
since memory doesn't last between invocations.
API Gateway
- Create an HTTP API with a Lambda proxy integration.
- Add the route
ANY /{proxy+}, or at leastPOST /webhooks, andPOST /slack/commandsfor the slash command. - If the stage is not
$default, setAPP_BASE_PATHto/<stage>. - Set the GitHub App's webhook URL to
https://<api-url>/<stage>/webhooks.
EventBridge
Add a schedule rule per scheduled feature, with the Lambda function as the target and an input whose detail names the action:
{
"source": "aws.events",
"detail-type": "Scheduled Event",
"detail": { "action": "okta-sync" }
}
| Action | Suggested schedule |
|---|---|
okta-sync |
rate(1 hour) |
security-alerts |
cron(0 13 ? * MON *), or rate(1 hour) daily |
With APP_REPORT_REPEAT=daily, run both hourly: each report posts when it
changes, and otherwise once a day.
A failed action fails the invocation, so EventBridge retries it and it shows in the function's error metrics.
Installer
The installer works in
Lambda with STORAGE_MODE=aws-ssm:
- Set
GITHUB_APP_INSTALLER_ENABLED=true,STORAGE_MODE=aws-ssm, andAWS_SSM_PARAMETER_PREFIX, such as/github-ops-app/. - Set
APP_GITHUB_APP_ID,APP_GITHUB_APP_PRIVATE_KEY, andAPP_GITHUB_WEBHOOK_SECRETto the ARNs of the parameters the installer will create, such asarn:aws:ssm:us-east-1:123456789012:parameter/github-ops-app/APP_GITHUB_APP_ID. - Grant the role
ssm:GetParameterandssm:PutParameter(andssm:AddTagsToResourcewithAWS_SSM_TAGS) on the prefix. - Visit
https://<api-url>/<stage>/setupand create the app.
The next invocation after the app is created loads its credentials. When
APP_BASE_PATH is set, the installer's "disable" button posts to a path
without the stage; set GITHUB_APP_INSTALLER_ENABLED=false instead.
The Slack setup works the
same way with APP_SLACK_SETUP_ENABLED=true: set APP_SLACK_TOKEN and
APP_SLACK_SIGNING_SECRET to the ARNs of <prefix>APP_SLACK_TOKEN and
<prefix>APP_SLACK_SIGNING_SECRET, and visit
https://<api-url>/<stage>/slack/setup. The invocation that finishes the
install loads the token; redeploy afterwards so every instance does.
Troubleshooting
401on webhooks: checkAPP_GITHUB_WEBHOOK_SECRET, and that API Gateway uses a proxy integration, which passes the body unchanged.503 service not configured: the configuration did not load; the logs list every problem.404on every route:APP_BASE_PATHdoesn't match the stage.- Timeouts: raise the timeout; a sync of many large groups takes minutes.
- The slash command answers but nothing runs: the role can't invoke the function; the logs show the failed dispatch.
Documentation
¶
Overview ¶
Command lambda runs github-ops-app as an AWS Lambda function. It handles API Gateway HTTP API (payload format 2.0) requests, which carry GitHub webhooks, Slack commands, and admin requests; EventBridge events, which run scheduled actions; and its own asynchronous invocations, which run jobs started from Slack.