title: How to create a stage in API Gateway with enabled cloudwatch metrics using terraform?
body: <p>I want to deploy this in a stage with cloudwatch metrics enabled. For that i need to use <code>aws_api_gateway_method_settings</code> which needs stage name. If don't create a stage using <code>aws_api_gateway_stage</code> it is throwing an error saying stage not exists. When i am trying to create a stage its saying stage already exists. </p>
  
  <p>One solution i tried is creating two stages one using <code>aws_api_gateway_deployment</code> and another using <code>aws_api_gateway_stage</code> with two different names. Is there any other solution for this?</p>
  
  <pre><code>resource "aws_api_gateway_deployment" "test-deploy" {
    depends_on = [ /*something goes here*/]
  
    rest_api_id = "${aws_api_gateway_rest_api.test.id}"
    stage_name  = "${var.stage_name}"
  
    variables = {
      "function" = "${var.lambda_function_name}"
    }
  }
  
  resource "aws_api_gateway_stage" "test" {
    stage_name = "${var.stage_name}"
    rest_api_id = "${aws_api_gateway_rest_api.test.id}"
    deployment_id = "${aws_api_gateway_deployment.test-deploy.id}"
  }
  
  resource "aws_api_gateway_method_settings" "settings" {
    rest_api_id = "${aws_api_gateway_rest_api.test.id}"
    stage_name  = "${aws_api_gateway_stage.test.stage_name}"
    method_path = "*/*"
  
    settings {
      metrics_enabled = true
      logging_level = "INFO"
    }
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>aws_api_gateway_stage.test: Error creating API Gateway Stage: ConflictException: Stage already exists
  </code></pre>