How to create a stage in API Gateway with enabled cloudwatch metrics using terraform?


I want to deploy this in a stage with cloudwatch metrics enabled. For that i need to use aws_api_gateway_method_settings which needs stage name. If don’t create a stage using aws_api_gateway_stage it is throwing an error saying stage not exists. When i am trying to create a stage its saying stage already exists.

One solution i tried is creating two stages one using aws_api_gateway_deployment and another using aws_api_gateway_stage with two different names. Is there any other solution for this?



I figured out that we don’t need to create a stage explicitly. aws_api_gateway_deployment creates a stage, but need to set depends_on. I tried this earlier without depends_on which throws an error saying stage not exists.

Leave a Reply