Skip to content

Commit

Permalink
Module for github webhook lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed May 1, 2020
1 parent a53b347 commit af7f7af
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 47 deletions.
109 changes: 66 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,107 @@
# Terraform module for AWS lambda to receive GitHub App events

This module creates the required infra to handle events of GitHub app via a Lambda connected to API Gateway V2.

## Examples

- _[default](./examples/default/)_ : Example that will create the lambda based on provided config and a zip file.
- _[provided-](./examples/provide-lambda/)_ : Example that will let you create the lambda resource and pass the resource to the module. The module will create the API gateway for you.

## Usages

```bash
# build the lambda
cd examples/lambda-nodejs-ts
./build.sh

## create infra
cd ../default
terraform init
terraform apply
```

Terraform will output the webhook endpoint and secret for the GitHub. Go to https://github.com/settings/apps and create your app.

## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| aws | n/a |
| ---- | ------- |
| aws | n/a |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda\_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
| Name | Description | Type | Default | Required |
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| gateway | n/a |
| Name | Description |
| ------- | ----------- |
| gateway | n/a |

## Requirements

| Name | Version |
|------|---------|
| Name | Version |
| --------- | ------- |
| terraform | ~> 0.12 |
| aws | ~> 2.50 |
| aws | ~> 2.50 |

## Providers

| Name | Version |
|------|---------|
| aws | ~> 2.50 |
| ---- | ------- |
| aws | ~> 2.50 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda\_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
| Name | Description | Type | Default | Required |
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| gateway | n/a |
| Name | Description |
| ------- | ----------- |
| gateway | n/a |

## Requirements

| Name | Version |
|------|---------|
| Name | Version |
| --------- | ------- |
| terraform | ~> 0.12 |
| aws | ~> 2.50 |
| aws | ~> 2.50 |

## Providers

| Name | Version |
|------|---------|
| aws | ~> 2.50 |
| ---- | ------- |
| aws | ~> 2.50 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda\_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
| Name | Description | Type | Default | Required |
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
| labmda_config | Configuration for the lambda. Only required if `create_lambda` is set to `true`. | <pre>object({<br> filename = string<br> handler = string<br> runtime = string<br> variables = map(string)<br> })</pre> | `null` | no |
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| gateway | n/a |

| Name | Description |
| ------- | ----------- |
| gateway | n/a |
4 changes: 2 additions & 2 deletions examples/default/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "api_gateway_endpoint" {
value = module.lambda.gateway.api_endpoint
output "webhook_endpoint" {
value = "${module.lambda.gateway.api_endpoint}/webhook"
}

output "github_app_secret" {
Expand Down
4 changes: 2 additions & 2 deletions examples/provide-lambda/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "api_gateway_endpoint" {
value = module.lambda.gateway.api_endpoint
output "webhook_endpoint" {
value = "${module.lambda.gateway.api_endpoint}/webhook"
}

output "github_app_secret" {
Expand Down

0 comments on commit af7f7af

Please sign in to comment.