terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
144 stars 188 forks source link

feat: Add support for OpenAPI definition #27

Closed ls-jason-rossiter closed 3 years ago

ls-jason-rossiter commented 3 years ago

Description

Add support for OpenAPI body definitions for

Definition: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html#cfn-apigatewayv2-api-body

Motivation and Context

The project I'm working on uses a single OpenAPI definition file for code generation as well as API Gateway resources. The OpenAPI file has template placeholders that point to Lambda function ARNs which need to be filled in during TF deploys.

We use this like so:

module "api_gateway" {
  source = "github.com/ls-jason-rossiter/terraform-aws-apigateway-v2"

  # Creates aws_apigatewayv2_integration and aws_apigatewayv2_route resources.
  body = templatefile("${path.module}/../../api.yaml", {
    my_function_arn = aws_lambda_function.main["my_function"].arn
  })
}

The above creates integration and route resources and populates the OpenAPI file with relevant data.

Breaking Changes

No breaking changes.

How Has This Been Tested?

This has been tested in-house with deploys to ephemeral environments using an OpenAPI definition file.

antonbabenko commented 3 years ago

Thanks for the addition. Could you please update an example code in examples folder?

ls-jason-rossiter commented 3 years ago

Thanks for the addition. Could you please update an example code in examples folder?

Done!

antonbabenko commented 3 years ago

Thanks, @ls-jason-rossiter ! I have simplified your example to what is just necessary.

v0.14.0 has been just released.

github-actions[bot] commented 1 year ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.