BadRequestException: Invalid OpenAPI input
Describe the Bug
Terraform apply fails with the following error
╷
│ Error: error creating API Gateway specification: BadRequestException: Invalid OpenAPI input.
│
│ with aws_api_gateway_rest_api.this[0],
│ on main.tf line 9, in resource "aws_api_gateway_rest_api" "this":
│ 9: resource "aws_api_gateway_rest_api" "this" {
│
╵
Expected Behavior
The OpenApi attribute is not set so it should use the default, empty object {}.
Steps to Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Run '....'
- Enter '....'
- See error
Screenshots
If applicable, add screenshots or logs to help explain your problem.
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas:
- OS: Fedora
- Version 3.6
- Terraform apigw module version:
0.3.1
Additional Context
I am using terragrunt and I am not sure if you are willing to consider this bug report but I will include my config below regardless.
The account-settings module applies fine and returns the role_arn output.
dependency "apigw_account_settings" {
config_path = "${get_terragrunt_dir()}/../apigw-account-settings"
mock_outputs_allowed_terraform_commands = ["plan", "validate"]
mock_outputs = {
role_arn = "fake-role-arn"
}
}
inputs = {
stage = "test"
stage_name = "test"
name = "apigw"
tags = {
ManagedBy = "Terraform"
Owner = "<masked>"
}
role_arn = dependency.apigw_account_settings.outputs.role_arn
metrics_enabled = true
xray_tracing_enabled = true
}
We started out trying to use this module along with the tf resources to define methods and integrations. The hard requirement to provide the open api spec prevents us from doing that.
The details of how to configure the APIGW with the openapi spec in different scenarios are very poorly documented if the goal is to replicate something defined without a template (Chalice is what we're trying to replace with TF). This bug is forcing me to write my own module to get away from the OpenAPI spec file or figure out the exact format spec file needed to replicate.
It would be great if we could get an update to make supplying the template optional.
I also struggled with this problem for a while. The key thing is to keep that openapi version attribute in the JSON (or YAML or whatever you have) to 3.0.1 and not anything else. It will raise a BadRequestException: Invalid OpenAPI input. and even if you add a Terraform trace, it will give you nothing useful debugging wise.