infra/template.yaml) defines all AWS resources required to run the pipeline. It deploys with a single command:
The project uses a
scripts/deploy.sh wrapper around sam build && sam deploy — invoke it with pnpm run deploy:dev / deploy:staging / deploy from the mergewatch.ai repo. You only need to invoke SAM directly if you are customizing deployment flags.Parameters
The template accepts four parameters that control the deployment:| Parameter | Type | Default | Description |
|---|---|---|---|
Stage | String | prod | Deployment stage (dev, staging, prod). Scopes all resource names so multiple environments can coexist in the same AWS account. |
DefaultBedrockModelId | String | us.anthropic.claude-sonnet-4-20250514-v1:0 | Default Bedrock model used by all agents. Can be overridden per-repo via .mergewatch.yml. |
DeploymentMode | String | self-hosted | Deployment mode. Set to saas to enable Stripe billing enforcement in the ReviewAgent and deploy the BillingHandler Lambda. self-hosted skips all billing checks. |
DashboardBaseUrl | String | https://mergewatch.ai | Base URL used in PR comment links that point back to the MergeWatch dashboard. |
Resources created
The template creates the following AWS resources:| Resource | Type | Details |
|---|---|---|
| WebhookApi | AWS::ApiGateway::RestApi | REST API endpoint that receives GitHub webhook POST requests |
| WebhookHandlerFunction | AWS::Lambda::Function | Node.js 20, ARM64, 512 MB, 30s timeout. Validates HMAC signature and invokes ReviewAgent asynchronously. |
| ReviewAgentFunction | AWS::Lambda::Function | Node.js 20, ARM64, 1024 MB, 300s timeout. Runs the multi-agent review pipeline. |
| InstallationsTable | AWS::DynamoDB::Table | On-demand table for GitHub App installation records. GSI on accountId. |
| ReviewsTable | AWS::DynamoDB::Table | On-demand table for review history. 90-day TTL. GSI on createdAt. |
| LambdaExecutionRole | AWS::IAM::Role | Shared execution role for both Lambda functions with least-privilege permissions. |
| SSM Parameters | AWS::SSM::Parameter | Three SecureString parameters under /mergewatch/{stage}/ for GitHub App credentials. |
Outputs
After deployment, the stack exports these values:| Output | Description |
|---|---|
WebhookUrl | The URL to set as your GitHub App webhook endpoint (e.g. https://abc123.execute-api.us-east-1.amazonaws.com/prod) |
WebhookHandlerArn | ARN of the WebhookHandler Lambda function |
ReviewAgentArn | ARN of the ReviewAgent Lambda function |
InstallationsTableName | Name of the DynamoDB installations table |
ReviewsTableName | Name of the DynamoDB reviews table |
IAM permissions
The Lambda execution role follows least-privilege principles. It includes the following permissions:CloudWatch Logs
CloudWatch Logs
logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEventsAllows both Lambda functions to write execution logs to CloudWatch.DynamoDB
DynamoDB
dynamodb:GetItem, dynamodb:PutItem, dynamodb:UpdateItem, dynamodb:QueryScoped to the two MergeWatch tables only. No Scan or DeleteItem permissions are granted.Amazon Bedrock
Amazon Bedrock
bedrock:InvokeModelScoped to the model ID specified in the DefaultBedrockModelId parameter. The ReviewAgent uses this to call the multi-agent pipeline.SSM Parameter Store
SSM Parameter Store
ssm:GetParameterScoped to /mergewatch/{stage}/*. Allows Lambda to decrypt and read GitHub App credentials at runtime.Lambda Invoke
Lambda Invoke
lambda:InvokeFunctionScoped to the ReviewAgent function ARN. WebhookHandler uses this to invoke ReviewAgent asynchronously (InvocationType.Event).Customization
You can override template parameters in two ways:For the full list of
sam deploy options, see the AWS SAM CLI reference.Next steps
Architecture Overview
Understand how the components connect end-to-end.
Self-Hosted Install
Deploy MergeWatch on your own infrastructure with Docker.