github.com/simonswine/terraform@v0.9.0-beta2/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 ## Example Usage 26 27 ``` 28 resource "aws_api_gateway_domain_name" "example" { 29 domain_name = "api.example.com" 30 31 certificate_name = "example-api" 32 certificate_body = "${file("${path.module}/example.com/example.crt")}" 33 certificate_chain = "${file("${path.module}/example.com/ca.crt")}" 34 certificate_private_key = "${file("${path.module}/example.com/example.key")}" 35 } 36 37 # Example DNS record using Route53. 38 # Route53 is not specifically required; any DNS host can be used. 39 resource "aws_route53_record" "example" { 40 zone_id = "${aws_route53_zone.example.id}" # See aws_route53_zone for how to create this 41 42 name = "${aws_api_gateway_domain_name.example.domain_name}" 43 type = "A" 44 45 alias { 46 name = "${aws_api_gateway_domain_name.example.cloudfront_domain_name}" 47 zone_id = "${aws_api_gateway_domain_name.example.cloudfront_zone_id}" 48 evaluate_target_health = true 49 } 50 } 51 ``` 52 53 ## Argument Reference 54 55 The following arguments are supported: 56 57 * `domain_name` - (Required) The fully-qualified domain name to register 58 * `certificate_name` - (Required) The unique name to use when registering this 59 cert as an IAM server certificate 60 * `certificate_body` - (Required) The certificate issued for the domain name 61 being registered, in PEM format 62 * `certificate_chain` - (Required) The certificate for the CA that issued the 63 certificate, along with any intermediate CA certificates required to 64 create an unbroken chain to a certificate trusted by the intended API clients. 65 * `certificate_private_key` - (Required) The private key associated with the 66 domain certificate given in `certificate_body`. 67 68 ## Attributes Reference 69 70 The following attributes are exported: 71 72 * `id` - The internal id assigned to this domain name by API Gateway. 73 * `certificate_upload_date` - The upload date associated with the domain certificate. 74 * `cloudfront_domain_name` - The hostname created by Cloudfront to represent 75 the distribution that implements this domain name mapping. 76 * `cloudfront_zone_id` - For convenience, the hosted zone id (`Z2FDTNDATAQYW2`) 77 that can be used to create a Route53 alias record for the distribution.