lambda

command
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
  1. Create an HTTP API with a Lambda proxy integration.
  2. Add the route ANY /{proxy+}, or at least POST /webhooks, and POST /slack/commands for the slash command.
  3. If the stage is not $default, set APP_BASE_PATH to /<stage>.
  4. 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:

  1. Set GITHUB_APP_INSTALLER_ENABLED=true, STORAGE_MODE=aws-ssm, and AWS_SSM_PARAMETER_PREFIX, such as /github-ops-app/.
  2. Set APP_GITHUB_APP_ID, APP_GITHUB_APP_PRIVATE_KEY, and APP_GITHUB_WEBHOOK_SECRET to the ARNs of the parameters the installer will create, such as arn:aws:ssm:us-east-1:123456789012:parameter/github-ops-app/APP_GITHUB_APP_ID.
  3. Grant the role ssm:GetParameter and ssm:PutParameter (and ssm:AddTagsToResource with AWS_SSM_TAGS) on the prefix.
  4. Visit https://<api-url>/<stage>/setup and 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

  • 401 on webhooks: check APP_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.
  • 404 on every route: APP_BASE_PATH doesn'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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL