github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/r/api_gateway_domain_name.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_api_gateway_domain_name"
     4  sidebar_current: "docs-aws-resource-api-gateway-domain-name"
     5  description: |-
     6    Registers a custom domain name for use with AWS API Gateway.
     7  ---
     8  
     9  # aws\_api\_gateway\_domain\_name
    10  
    11  Registers a custom domain name for use with AWS API Gateway.
    12  
    13  This resource just establishes ownership of and the TLS settings for
    14  a particular domain name. An API can be attached to a particular path
    15  under the registered domain name using
    16  [the `aws_api_gateway_base_path_mapping` resource](api_gateway_base_path_mapping.html).
    17  
    18  Internally API Gateway creates a CloudFront distribution to
    19  route requests on the given hostname. In addition to this resource
    20  it's necessary to create a DNS record corresponding to the
    21  given domain name which is an alias (either Route53 alias or
    22  traditional CNAME) to the Cloudfront domain name exported in the
    23  `cloudfront_domain_name` attribute.
    24  
    25  ~> **Note:** All arguments including the private key will be stored in the raw state as plain-text.
    26  [Read more about sensitive data in state](/docs/state/sensitive-data.html).
    27  
    28  ## Example Usage
    29  
    30  ```hcl
    31  resource "aws_api_gateway_domain_name" "example" {
    32    domain_name = "api.example.com"
    33  
    34    certificate_name        = "example-api"
    35    certificate_body        = "${file("${path.module}/example.com/example.crt")}"
    36    certificate_chain       = "${file("${path.module}/example.com/ca.crt")}"
    37    certificate_private_key = "${file("${path.module}/example.com/example.key")}"
    38  }
    39  
    40  # Example DNS record using Route53.
    41  # Route53 is not specifically required; any DNS host can be used.
    42  resource "aws_route53_record" "example" {
    43    zone_id = "${aws_route53_zone.example.id}" # See aws_route53_zone for how to create this
    44  
    45    name = "${aws_api_gateway_domain_name.example.domain_name}"
    46    type = "A"
    47  
    48    alias {
    49      name                   = "${aws_api_gateway_domain_name.example.cloudfront_domain_name}"
    50      zone_id                = "${aws_api_gateway_domain_name.example.cloudfront_zone_id}"
    51      evaluate_target_health = true
    52    }
    53  }
    54  ```
    55  
    56  ## Argument Reference
    57  
    58  The following arguments are supported:
    59  
    60  * `domain_name` - (Required) The fully-qualified domain name to register
    61  * `certificate_name` - (Optional) The unique name to use when registering this
    62    cert as an IAM server certificate. Conflicts with `certificate_arn`.
    63  * `certificate_body` - (Optional) The certificate issued for the domain name
    64    being registered, in PEM format. Conflicts with `certificate_arn`.
    65  * `certificate_chain` - (Optional) The certificate for the CA that issued the
    66    certificate, along with any intermediate CA certificates required to
    67    create an unbroken chain to a certificate trusted by the intended API clients. Conflicts with `certificate_arn`.
    68  * `certificate_private_key` - (Optional) The private key associated with the
    69    domain certificate given in `certificate_body`. Conflicts with `certificate_arn`.
    70  * `certificate_arn` - (Optional) The ARN for an AWS-managed certificate. Conflicts with `certificate_name`, `certificate_body`, `certificate_chain` and `certificate_private_key`.
    71  
    72  ## Attributes Reference
    73  
    74  The following attributes are exported:
    75  
    76  * `id` - The internal id assigned to this domain name by API Gateway.
    77  * `certificate_upload_date` - The upload date associated with the domain certificate.
    78  * `cloudfront_domain_name` - The hostname created by Cloudfront to represent
    79    the distribution that implements this domain name mapping.
    80  * `cloudfront_zone_id` - For convenience, the hosted zone id (`Z2FDTNDATAQYW2`)
    81    that can be used to create a Route53 alias record for the distribution.