title: How to use api_gateway_base_path_mapping with terraform?
body: <p>I'm trying to setup a custom domain name for an api in api gateway on aws. I have setup the api fine using terraform. However when I try to setup the custom domain it fails with the following error.</p>
  
  <p>Error applying plan:</p>
  
  <p>1 error(s) occurred:</p>
  
  <ul>
  <li><p>module.BillingMetrics.aws_api_gateway_base_path_mapping.billing: 1 error(s) occurred:</p></li>
  <li><p>aws_api_gateway_base_path_mapping.billing: Error creating Gateway base path mapping: Error creating Gateway base path mapping: BadRequestException: Invalid REST API identifier specified
      status code: 400, request id: b14bbd4c-5823-11e7-a4ea-93525a34b321</p></li>
  </ul>
  
  <p>I can see in the terraform log that it does get the correct api_id. But I don't understand why it's saying the rest api identifier is invalid.</p>
  
  <p>Below is an excerpt of my terraform file showing how I'm configuring the api_gateway_base_path_mapping.</p>
  
  <pre><code>resource "aws_api_gateway_resource" "views_resource" {
    provider = "aws.regional"
    rest_api_id = "${aws_api_gateway_rest_api.billing_api.id}"
    parent_id   = "${aws_api_gateway_rest_api.billing_api.root_resource_id}"
    path_part   = "views"
  }
  
  resource "aws_api_gateway_method" "views-get" {
    provider = "aws.regional"
    rest_api_id   = "${aws_api_gateway_rest_api.billing_api.id}"
    resource_id   = "${aws_api_gateway_resource.views_resource.id}"
    http_method   = "GET"
    authorization = "NONE"
  }
  
  resource "aws_api_gateway_method_response" "views_200" {
    provider = "aws.regional"
    rest_api_id = "${aws_api_gateway_rest_api.billing_api.id}"
    resource_id = "${aws_api_gateway_resource.views_resource.id}"
    http_method = "${aws_api_gateway_method.views-get.http_method}"
    status_code = "200"
  }
  
  resource "aws_api_gateway_integration" "views-integration" {
    provider = "aws.regional"
    rest_api_id             = "${aws_api_gateway_rest_api.billing_api.id}"
    resource_id             = "${aws_api_gateway_resource.views_resource.id}"
    http_method             = "${aws_api_gateway_method.views-get.http_method}"
    type                    = "AWS"
    uri                     = "arn:aws:apigateway:${var.region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${var.region}:${var.account_id}:function:${aws_lambda_function.get_views.function_name}/invocations"
    credentials             = "${var.metrics_role_arn}"
    http_method             = "${aws_api_gateway_method.views-get.http_method}"
    integration_http_method = "POST"
  }
  
  resource "aws_api_gateway_integration_response" "Views_Get_IntegrationResponse" {
    provider = "aws.regional"
    rest_api_id = "${aws_api_gateway_rest_api.billing_api.id}"
    resource_id = "${aws_api_gateway_resource.views_resource.id}"
    http_method = "${aws_api_gateway_method.views-get.http_method}"
    status_code = "${aws_api_gateway_method_response.views_200.status_code}"
   }
  
  /* Deploy api */
  resource "aws_api_gateway_deployment" "metric_deploy" {
    provider = "aws.regional"
    depends_on  = ["aws_api_gateway_integration.metrics-integration", "aws_api_gateway_integration.hours-integration"]
    stage_name  = "beta"
    rest_api_id = "${aws_api_gateway_rest_api.billing_api.id}"
  }
  
  resource "aws_api_gateway_domain_name" "billing" {
    domain_name       = "billing.example.com"
    certificate_arn   = "arn:aws:acm:us-east-1:6--:certificate/5--"
  }
  
  resource "aws_api_gateway_base_path_mapping" "billing" {
    api_id      = "${aws_api_gateway_rest_api.billing_api.id}"
    stage_name  = "${aws_api_gateway_deployment.metric_deploy.stage_name}"
    domain_name = "${aws_api_gateway_domain_name.billing.domain_name}"
  }
  
  resource "aws_route53_record" "billing" {
    zone_id = "Z-------"
  
    name = "${aws_api_gateway_domain_name.billing.domain_name}"
    type = "A"
  
    alias {
      name                   = "${aws_api_gateway_domain_name.billing.cloudfront_domain_name}"
      zone_id                = "${aws_api_gateway_domain_name.billing.cloudfront_zone_id}"
      evaluate_target_health = true
    }
  }
  </code></pre>
  
  <p>Are there any more elements that needed to be configured to have the base_path_mapping apply correctly? Any other hints what I might be doing wrong?</p>
  
  <p>I should also mention I'm on terraform 0.9.7.</p>