Skip to content

Commit c4255f1

Browse files
website: Docs for AWS API Gateway domain name and base path mapping
1 parent 848f612 commit c4255f1

3 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
layout: "aws"
3+
page_title: "AWS: aws_api_gateway_base_path_mapping"
4+
sidebar_current: "docs-aws-resource-api-gateway-base-path-mapping"
5+
description: |-
6+
Connects a custom domain with a deployed API
7+
---
8+
9+
# aws\_api\_gateway\_base\_path\_mapping
10+
11+
Connects a custom domain name registered via `aws_api_gateway_domain_name`
12+
with a deployed API so that its methods can be called via the
13+
custom domain name.
14+
15+
## Example Usage
16+
17+
```
18+
resource "aws_api_gateway_deployment" "example" {
19+
# See aws_api_gateway_rest_api_docs for how to create this
20+
rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
21+
stage_name = "live"
22+
}
23+
24+
resource "aws_api_gateway_domain_name" "example" {
25+
domain_name = "example.com"
26+
27+
certificate_name = "example-api"
28+
certificate_body = "${file("${path.module}/example.com/example.crt")}"
29+
certificate_chain = "${file("${path.module}/example.com/ca.crt")}"
30+
certificate_private_key = "${file("${path.module}/example.com/example.key")}"
31+
}
32+
33+
resource "aws_api_gateway_base_path_mapping" "test" {
34+
api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
35+
stage = "${aws_api_gateway_deployment.example.stage_name}"
36+
domain_name = "${aws_api_gateway_domain_name.example.domain_name}"
37+
}
38+
```
39+
40+
## Argument Reference
41+
42+
The following arguments are supported:
43+
44+
* `domain_name` - (Required) The already-registered domain name to connect the API to.
45+
* `api_id` - (Required) The id of the API to connect.
46+
* `stage` - (Optional) The name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.
47+
* `base_path` - (Optional) Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
}
49+
}
50+
```
51+
52+
## Argument Reference
53+
54+
The following arguments are supported:
55+
56+
* `domain_name` - (Required) The fully-qualified domain name to register
57+
* `certificate_name` - (Required) The unique name to use when registering this
58+
cert as an IAM server certificate
59+
* `certificate_body` - (Required) The certificate issued for the domain name
60+
being registered, in PEM format
61+
* `certificate_chain` - (Required) The certificate for the CA that issued the
62+
certificate, along with any intermediate CA certificates required to
63+
create an unbroken chain to a certificate trusted by the intended API clients.
64+
* `certificate_private_key` - (Required) The private key associated with the
65+
domain certificate given in `certificate_body`.
66+
67+
## Attributes Reference
68+
69+
The following attributes are exported:
70+
71+
* `id` - The internal id assigned to this domain name by API Gateway.
72+
* `cloudfront_domain_name` - The hostname created by Cloudfront to represent
73+
the distribution that implements this domain name mapping.
74+
* `cloudfront_zone_id` - For convenience, the hosted zone id (`Z2FDTNDATAQYW2`)
75+
that can be used to create a Route53 alias record for the distribution.

website/source/layouts/aws.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@
5656
<li<%= sidebar_current("docs-aws-resource-api-gateway-authorizer") %>>
5757
<a href="/docs/providers/aws/r/api_gateway_authorizer.html">aws_api_gateway_authorizer</a>
5858
</li>
59+
<li<%= sidebar_current("docs-aws-resource-api-gateway-base-path-mapping") %>>
60+
<a href="/docs/providers/aws/r/api_gateway_base_path_mapping.html">aws_api_gateway_base_path_mapping</a>
61+
</li>
5962
<li<%= sidebar_current("docs-aws-resource-api-gateway-deployment") %>>
6063
<a href="/docs/providers/aws/r/api_gateway_deployment.html">aws_api_gateway_deployment</a>
6164
</li>
65+
<li<%= sidebar_current("docs-aws-resource-api-gateway-domain-name") %>>
66+
<a href="/docs/providers/aws/r/api_gateway_domain_name.html">aws_api_gateway_domain_name</a>
67+
</li>
6268
<li<%= sidebar_current("docs-aws-resource-api-gateway-integration") %>>
6369
<a href="/docs/providers/aws/r/api_gateway_integration.html">aws_api_gateway_integration</a>
6470
</li>

0 commit comments

Comments
 (0)