At work our infrastructure is splitted into multiple .git repository with terraform files.
We have a repo aws-basics that contains every “foundation” of the infrastructure like :
resource "aws_api_gateway_rest_api" "apiMain" {}
then multiple repository for every routes, for instance the repository users contains :
resource "aws_lambda_function" "lambdaUserCreate"{}
it would be cool if every repository could be responsible of its api path. But until now I can’t figure it out how.
I tried to create the aws_api_gateway_stage and the aws_api_gateway_deployment into the aws-basics repository, but since it does not contains any aws_api_gateway_resource it gives me this error from aws :
Error: Error creating API Gateway Deployment: BadRequestException: The REST API doesn't contain any methods
the resources, methods and integration are created into their own repository, with the help of
data "aws_api_gateway_rest_api" "mainAPI" {
name= "mainApi"
}
Do you think it is possible to make it work ? Is there a way to “add” resources to an existing api, into a existing stage ? I could make a new deployment in each repository, but the resource "aws_api_gateway_stage" can not be created by itself in the aws-basics repository since it requires the deployment.id