Reputation: 126
I'm creating AWS API Gateway via Terraform via importing an Open API yaml file. The import works fine but the issue I'm trying to resolve is that my required fields are not being enforced.
If I was creating the API entirely via Terraform I would set the request_validator_id attribute on a aws_api_gateway_method resource and be all set, but how do I do what when the aws_api_gateway_method resource was created automatically via the aws_api_gateway_rest_api resource?
Visually what I'm trying to do is select 'Validate Body' for a POST request.
My Terraform resource to create the api;
resource "aws_api_gateway_rest_api" "api" {
name = "Users API - ${var.Environment}"
body = file("../api/${var.Environment}.test.org.yaml")
endpoint_configuration {
types = ["REGIONAL"]
}
}
Upvotes: 0
Views: 939
Reputation: 592
You can do something like this in your open-api docs in body:
"x-amazon-apigateway-request-validator": "Validate Body"
This will add the validation for your request for POST method. This syntax is for json, yaml would be same as per formatting provide.
Upvotes: 1