Skip to content

Commit af7f7af

Browse files
committed
Module for github webhook lambda
1 parent a53b347 commit af7f7af

File tree

3 files changed

+70
-47
lines changed

3 files changed

+70
-47
lines changed

README.md

+66-43
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,107 @@
1+
# Terraform module for AWS lambda to receive GitHub App events
2+
3+
This module creates the required infra to handle events of GitHub app via a Lambda connected to API Gateway V2.
4+
5+
## Examples
6+
7+
- _[default](./examples/default/)_ : Example that will create the lambda based on provided config and a zip file.
8+
- _[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.
9+
10+
## Usages
11+
12+
```bash
13+
# build the lambda
14+
cd examples/lambda-nodejs-ts
15+
./build.sh
16+
17+
## create infra
18+
cd ../default
19+
terraform init
20+
terraform apply
21+
```
22+
23+
Terraform will output the webhook endpoint and secret for the GitHub. Go to https://github.com/settings/apps and create your app.
24+
125
## Requirements
226

327
No requirements.
428

529
## Providers
630

731
| Name | Version |
8-
|------|---------|
9-
| aws | n/a |
32+
| ---- | ------- |
33+
| aws | n/a |
1034

1135
## Inputs
1236

13-
| Name | Description | Type | Default | Required |
14-
|------|-------------|------|---------|:--------:|
15-
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
16-
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
17-
| 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 |
18-
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
19-
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
37+
| Name | Description | Type | Default | Required |
38+
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
39+
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
40+
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
41+
| 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 |
42+
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
43+
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
2044

2145
## Outputs
2246

23-
| Name | Description |
24-
|------|-------------|
25-
| gateway | n/a |
47+
| Name | Description |
48+
| ------- | ----------- |
49+
| gateway | n/a |
2650

2751
## Requirements
2852

29-
| Name | Version |
30-
|------|---------|
53+
| Name | Version |
54+
| --------- | ------- |
3155
| terraform | ~> 0.12 |
32-
| aws | ~> 2.50 |
56+
| aws | ~> 2.50 |
3357

3458
## Providers
3559

3660
| Name | Version |
37-
|------|---------|
38-
| aws | ~> 2.50 |
61+
| ---- | ------- |
62+
| aws | ~> 2.50 |
3963

4064
## Inputs
4165

42-
| Name | Description | Type | Default | Required |
43-
|------|-------------|------|---------|:--------:|
44-
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
45-
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
46-
| 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 |
47-
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
48-
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
66+
| Name | Description | Type | Default | Required |
67+
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
68+
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
69+
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
70+
| 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 |
71+
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
72+
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
4973

5074
## Outputs
5175

52-
| Name | Description |
53-
|------|-------------|
54-
| gateway | n/a |
76+
| Name | Description |
77+
| ------- | ----------- |
78+
| gateway | n/a |
5579

5680
## Requirements
5781

58-
| Name | Version |
59-
|------|---------|
82+
| Name | Version |
83+
| --------- | ------- |
6084
| terraform | ~> 0.12 |
61-
| aws | ~> 2.50 |
85+
| aws | ~> 2.50 |
6286

6387
## Providers
6488

6589
| Name | Version |
66-
|------|---------|
67-
| aws | ~> 2.50 |
90+
| ---- | ------- |
91+
| aws | ~> 2.50 |
6892

6993
## Inputs
7094

71-
| Name | Description | Type | Default | Required |
72-
|------|-------------|------|---------|:--------:|
73-
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
74-
| create\_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
75-
| 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 |
76-
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
77-
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
95+
| Name | Description | Type | Default | Required |
96+
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
97+
| environment | Name of the environment will be used to name resources unique. | `string` | n/a | yes |
98+
| create_lambda | Let the module create the lambda, provide the config for the lambda via `lambda_config`. | `bool` | `true` | no |
99+
| 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 |
100+
| lambda | Provide your own lambda resource. Only required if `create_lambda` is set to `false`. | `any` | `null` | no |
101+
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
78102

79103
## Outputs
80104

81-
| Name | Description |
82-
|------|-------------|
83-
| gateway | n/a |
84-
105+
| Name | Description |
106+
| ------- | ----------- |
107+
| gateway | n/a |

examples/default/outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
output "api_gateway_endpoint" {
2-
value = module.lambda.gateway.api_endpoint
1+
output "webhook_endpoint" {
2+
value = "${module.lambda.gateway.api_endpoint}/webhook"
33
}
44

55
output "github_app_secret" {

examples/provide-lambda/outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
output "api_gateway_endpoint" {
2-
value = module.lambda.gateway.api_endpoint
1+
output "webhook_endpoint" {
2+
value = "${module.lambda.gateway.api_endpoint}/webhook"
33
}
44

55
output "github_app_secret" {

0 commit comments

Comments
 (0)