Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit fcd9fba

Browse files
feat: Add option to enable access log for API gateway (#2387)
Co-authored-by: Yuto Nakamura <[email protected]>
1 parent 5f28350 commit fcd9fba

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ In case the setup does not work as intended follow the trace of events:
481481
| <a name="input_userdata_pre_install"></a> [userdata\_pre\_install](#input\_userdata\_pre\_install) | Script to be ran before the GitHub Actions runner is installed on the EC2 instances | `string` | `""` | no |
482482
| <a name="input_userdata_template"></a> [userdata\_template](#input\_userdata\_template) | Alternative user-data template, replacing the default template. By providing your own user\_data you have to take care of installing all required software, including the action runner. Variables userdata\_pre/post\_install are ignored. | `string` | `null` | no |
483483
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC for security groups of the action runners. | `string` | n/a | yes |
484+
| <a name="input_webhook_lambda_apigateway_access_log_settings"></a> [webhook\_lambda\_apigateway\_access\_log\_settings](#input\_webhook\_lambda\_apigateway\_access\_log\_settings) | n/a | <pre>object({<br> destination_arn = string<br> format = string<br> })</pre> | `null` | no |
484485
| <a name="input_webhook_lambda_s3_key"></a> [webhook\_lambda\_s3\_key](#input\_webhook\_lambda\_s3\_key) | S3 key for webhook lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
485486
| <a name="input_webhook_lambda_s3_object_version"></a> [webhook\_lambda\_s3\_object\_version](#input\_webhook\_lambda\_s3\_object\_version) | S3 object version for webhook lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
486487
| <a name="input_webhook_lambda_timeout"></a> [webhook\_lambda\_timeout](#input\_webhook\_lambda\_timeout) | Time out of the webhook lambda in seconds. | `number` | `10` | no |

Diff for: main.tf

+10-9
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ module "webhook" {
100100
sqs_build_queue_fifo = var.fifo_build_queue
101101
github_app_webhook_secret_arn = module.ssm.parameters.github_app_webhook_secret.arn
102102

103-
lambda_s3_bucket = var.lambda_s3_bucket
104-
webhook_lambda_s3_key = var.webhook_lambda_s3_key
105-
webhook_lambda_s3_object_version = var.webhook_lambda_s3_object_version
106-
lambda_runtime = var.lambda_runtime
107-
lambda_architecture = var.lambda_architecture
108-
lambda_zip = var.webhook_lambda_zip
109-
lambda_timeout = var.webhook_lambda_timeout
110-
logging_retention_in_days = var.logging_retention_in_days
111-
logging_kms_key_id = var.logging_kms_key_id
103+
lambda_s3_bucket = var.lambda_s3_bucket
104+
webhook_lambda_s3_key = var.webhook_lambda_s3_key
105+
webhook_lambda_s3_object_version = var.webhook_lambda_s3_object_version
106+
webhook_lambda_apigateway_access_log_settings = var.webhook_lambda_apigateway_access_log_settings
107+
lambda_runtime = var.lambda_runtime
108+
lambda_architecture = var.lambda_architecture
109+
lambda_zip = var.webhook_lambda_zip
110+
lambda_timeout = var.webhook_lambda_timeout
111+
logging_retention_in_days = var.logging_retention_in_days
112+
logging_kms_key_id = var.logging_kms_key_id
112113

113114
# labels
114115
enable_workflow_job_labels_check = var.runner_enable_workflow_job_labels_check

Diff for: modules/webhook/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ No modules.
9595
| <a name="input_sqs_build_queue"></a> [sqs\_build\_queue](#input\_sqs\_build\_queue) | SQS queue to publish accepted build events. | <pre>object({<br> id = string<br> arn = string<br> })</pre> | n/a | yes |
9696
| <a name="input_sqs_build_queue_fifo"></a> [sqs\_build\_queue\_fifo](#input\_sqs\_build\_queue\_fifo) | Enable a FIFO queue to remain the order of events received by the webhook. Suggest to set to true for repo level runners. | `bool` | `false` | no |
9797
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
98+
| <a name="input_webhook_lambda_apigateway_access_log_settings"></a> [webhook\_lambda\_apigateway\_access\_log\_settings](#input\_webhook\_lambda\_apigateway\_access\_log\_settings) | Access log settings for webhook API gateway. | <pre>object({<br> destination_arn = string<br> format = string<br> })</pre> | `null` | no |
9899
| <a name="input_webhook_lambda_s3_key"></a> [webhook\_lambda\_s3\_key](#input\_webhook\_lambda\_s3\_key) | S3 key for webhook lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
99100
| <a name="input_webhook_lambda_s3_object_version"></a> [webhook\_lambda\_s3\_object\_version](#input\_webhook\_lambda\_s3\_object\_version) | S3 object version for webhook lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
100101
| <a name="input_workflow_job_labels_check_all"></a> [workflow\_job\_labels\_check\_all](#input\_workflow\_job\_labels\_check\_all) | If set to true all labels in the workflow job must match the GitHub labels (os, architecture and `self-hosted`). When false if __any__ label matches it will trigger the webhook. `enable_workflow_job_labels_check` must be true for this to take effect. | `bool` | `true` | no |

Diff for: modules/webhook/main.tf

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ resource "aws_apigatewayv2_stage" "webhook" {
2929
api_id = aws_apigatewayv2_api.webhook.id
3030
name = "$default"
3131
auto_deploy = true
32-
tags = var.tags
32+
dynamic "access_log_settings" {
33+
for_each = var.webhook_lambda_apigateway_access_log_settings[*]
34+
content {
35+
destination_arn = access_log_settings.value.destination_arn
36+
format = access_log_settings.value.format
37+
}
38+
}
39+
tags = var.tags
3340
}
3441

3542
resource "aws_apigatewayv2_integration" "webhook" {

Diff for: modules/webhook/variables.tf

+9
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ variable "webhook_lambda_s3_object_version" {
8989
default = null
9090
}
9191

92+
variable "webhook_lambda_apigateway_access_log_settings" {
93+
description = "Access log settings for webhook API gateway."
94+
type = object({
95+
destination_arn = string
96+
format = string
97+
})
98+
default = null
99+
}
100+
92101
variable "repository_white_list" {
93102
description = "List of repositories allowed to use the github app"
94103
type = list(string)

Diff for: variables.tf

+8
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ variable "webhook_lambda_s3_object_version" {
302302
default = null
303303
}
304304

305+
variable "webhook_lambda_apigateway_access_log_settings" {
306+
type = object({
307+
destination_arn = string
308+
format = string
309+
})
310+
default = null
311+
}
312+
305313
variable "runners_lambda_s3_key" {
306314
description = "S3 key for runners lambda function. Required if using S3 bucket to specify lambdas."
307315
default = null

0 commit comments

Comments
 (0)