• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

pristineio/lambda-webhook: AWS Lambda function to receive GitHub webhooks from A ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

pristineio/lambda-webhook

开源软件地址:

https://github.com/pristineio/lambda-webhook

开源编程语言:

Python 100.0%

开源软件介绍:

lambda-webhook

An AWS Lambda function to receive GitHub webhooks from API gateway and relay them to an EC2 instance.

Usage

  1. Create a Security Group for the Lambda function
  • Inbound: None
  • Outbound: Only allow HTTPS/HTTP to the receiving instance
  1. Create a Lambda function:
  • Runtime: Python 2.7
  • Handler: hook.lambda_handler
  • Role: Basic With VPC
  • Memory: 128MB
  • Timeout: 30sec
  • VPC: The VPC of the receiving instance
  • Subnets: At least 2 private subnets within the VPC
  • Security Groups: The Security Group configured previously
  1. Install dependencies locally:

$ pip install -r requirements.txt -t lambdawebhook/lib/

  1. Create a ZIP archive of the lambdawebhook directory:

$ cd lambdawebhook $ zip -r lambdawebhook.zip *

  1. Upload the zipped code to the Lambda function created previously

  2. Create an API in API gateway

  3. Create a resource for /github

  4. Create a POST method for /github

  • Integration type: Lambda Function
  • Lambda Region: The region of the Lamba function created previously
  • Lambda Function: The Lambda function created previously
  1. Integration Request -> Mapping Templates:
  • Content-Type: application/json

  • Mapping Template (replace secret and jenkins_url as appropriate for your configuration):

      {
          "x_github_delivery": "$util.escapeJavaScript($input.params().header.get('X-GitHub-Delivery'))",
          "x_github_event": "$util.escapeJavaScript($input.params().header.get('X-GitHub-Event'))",
          "x_hub_signature": "$util.escapeJavaScript($input.params().header.get('X-Hub-Signature'))",
          "secret": "some_secret",
          "jenkins_url": "https://jenkins/github-webhook/",
          "payload": "$util.base64Encode($input.body)"
      }
    
  1. Method Response:
  • HTTP Status: 400
  1. Integration Response -> Add integration response:
  • Lambda Error Regex: 400 Client Error: Bad Request
  • Method response status: 400
  • Mapping Templates:
    • Content-Type: application/json

    • Template:

        {
            "message": $input.json('$.errorMessage')
        }
      
  1. Deploy API

  2. Configure the webhook and secret for the GitHub repository using the API URL provided in the previous step, and secret set above.

  3. Test by pushing some code to the repository.

Development

Linting (flake8) and testing (unittest) are executed using tox in the root directory of this repository:

$ pip install tox
$ tox



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
99x/github-manager: Manage GitHub repositories with ease发布时间:2022-06-13
下一篇:
apicloudcom/apicloudcom.github.io发布时间:2022-06-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap