Is it possible to create and AWS API gateway resources with subdirectories from the root with Terraform?
When doing
resource "aws_api_gateway_resource" "MyDemoResource" {
rest_api_id = aws_api_gateway_rest_api.MyDemoAPI.id
parent_id = aws_api_gateway_rest_api.MyDemoAPI.root_resource_id
path_part = "/will/this/work"
}
I get the error:
aws_api_gateway_resource.MyDemoResource: 1 error occurred: aws_api_gateway_resource.MyDemoResource: Error creating API Gateway Resource: BadRequestException: Resource's path part only allow a-zA-Z0-9._-: or a valid greedy path variable and curly braces at the beginning and the end."
I've found this GitHub ticket and a few others like it. I'm not sure if this is a bug or by design with a workaround.
Additionally, If I create this manually in the AWS console and then import it, the full path appears in the attribute path
properly but not in the input path_part
.
"aws_api_gateway_resource.MyDemoResource": {
"type": "aws_api_gateway_resource",
"depends_on": [],
"primary": {
"id": "foo",
"attributes": {
"id": "foo",
"parent_id": "foo",
**"path": "/will/this/work"**,
**"path_part": "work"**,
"rest_api_id": "foo"
}