1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- locals {
- webhook_endpoint = "webhook"
- role_path = var.role_path == null ? "/${var.prefix}/" : var.role_path
- lambda_zip = var.lambda_zip == null ? "${path.module}/lambdas/webhook/webhook.zip" : var.lambda_zip
- }
- resource "aws_apigatewayv2_api" "webhook" {
- name = "${var.prefix}-github-action-webhook"
- protocol_type = "HTTP"
- tags = var.tags
- }
- resource "aws_apigatewayv2_route" "webhook" {
- api_id = aws_apigatewayv2_api.webhook.id
- route_key = "POST /${local.webhook_endpoint}"
- target = "integrations/${aws_apigatewayv2_integration.webhook.id}"
- }
- resource "aws_apigatewayv2_stage" "webhook" {
- lifecycle {
- ignore_changes = [
- // see bug https://github.com/terraform-providers/terraform-provider-aws/issues/12893
- default_route_settings,
- // not terraform managed
- deployment_id
- ]
- }
- api_id = aws_apigatewayv2_api.webhook.id
- name = "$default"
- auto_deploy = true
- tags = var.tags
- }
- resource "aws_apigatewayv2_integration" "webhook" {
- lifecycle {
- ignore_changes = [
- // not terraform managed
- passthrough_behavior
- ]
- }
- api_id = aws_apigatewayv2_api.webhook.id
- integration_type = "AWS_PROXY"
- connection_type = "INTERNET"
- description = "GitHub App webhook for receiving build events."
- integration_method = "POST"
- integration_uri = aws_lambda_function.webhook.invoke_arn
- }
|