https://github.com/skorfmann/github-webhook
https://github.com/skorfmann/github-webhook
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/skorfmann/github-webhook
- Owner: skorfmann
- Created: 2021-06-18T08:55:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-21T12:09:30.000Z (over 4 years ago)
- Last Synced: 2025-02-14T03:51:08.798Z (8 months ago)
- Language: TypeScript
- Size: 137 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## API Gateway (HTTP)
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html
### EventBridge Integration
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/apigatewayv2_integration
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-aws-services.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-aws-services-reference.html#EventBridge-PutEvents
- https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html## Github Webhook
Secure the Webhook: https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks
We don't have access to the request body within the custom authorizer Lambda - see here https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html - So, we can't use Github's request signature to check for the event validity. A potential workaround could be, to put Cloudfront with Lambda@edge in fron of the API Gateway. However, for the sake of simplicity we'll just us a path parameter as a unique token (something like this http://apigwurl.aws.com/hooks/github/${token})
## Usage
- cdktf deploy
get output of API Gateway
build url `https:////hooks/github/`
Submit a test event
```
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST -is https://66pw9lps6l.execute-api.eu-central-1.amazonaws.com/production/hooks/github/12345
```## Debug EventBridge
```ts
const stack = new MyStack(app, 'stream');Node.of(stack).applyAspect(new SnoopEvents())
``````
export AWS_PROFILE=
export AWS_DEFAULT_REGION=
aws logs tail --follow "/aws/lambda/snoop-events"
```