website: Docs for AWS API Gateway domain name and base path mapping
This commit is contained in:
parent
848f612169
commit
c4255f195b
|
@ -0,0 +1,47 @@
|
||||||
|
---
|
||||||
|
layout: "aws"
|
||||||
|
page_title: "AWS: aws_api_gateway_base_path_mapping"
|
||||||
|
sidebar_current: "docs-aws-resource-api-gateway-base-path-mapping"
|
||||||
|
description: |-
|
||||||
|
Connects a custom domain with a deployed API
|
||||||
|
---
|
||||||
|
|
||||||
|
# aws\_api\_gateway\_base\_path\_mapping
|
||||||
|
|
||||||
|
Connects a custom domain name registered via `aws_api_gateway_domain_name`
|
||||||
|
with a deployed API so that its methods can be called via the
|
||||||
|
custom domain name.
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
resource "aws_api_gateway_deployment" "example" {
|
||||||
|
# See aws_api_gateway_rest_api_docs for how to create this
|
||||||
|
rest_api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
|
||||||
|
stage_name = "live"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_api_gateway_domain_name" "example" {
|
||||||
|
domain_name = "example.com"
|
||||||
|
|
||||||
|
certificate_name = "example-api"
|
||||||
|
certificate_body = "${file("${path.module}/example.com/example.crt")}"
|
||||||
|
certificate_chain = "${file("${path.module}/example.com/ca.crt")}"
|
||||||
|
certificate_private_key = "${file("${path.module}/example.com/example.key")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_api_gateway_base_path_mapping" "test" {
|
||||||
|
api_id = "${aws_api_gateway_rest_api.MyDemoAPI.id}"
|
||||||
|
stage = "${aws_api_gateway_deployment.example.stage_name}"
|
||||||
|
domain_name = "${aws_api_gateway_domain_name.example.domain_name}"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Argument Reference
|
||||||
|
|
||||||
|
The following arguments are supported:
|
||||||
|
|
||||||
|
* `domain_name` - (Required) The already-registered domain name to connect the API to.
|
||||||
|
* `api_id` - (Required) The id of the API to connect.
|
||||||
|
* `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.
|
||||||
|
* `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.
|
|
@ -0,0 +1,75 @@
|
||||||
|
---
|
||||||
|
layout: "aws"
|
||||||
|
page_title: "AWS: aws_api_gateway_domain_name"
|
||||||
|
sidebar_current: "docs-aws-resource-api-gateway-domain-name"
|
||||||
|
description: |-
|
||||||
|
Registers a custom domain name for use with AWS API Gateway.
|
||||||
|
---
|
||||||
|
|
||||||
|
# aws\_api\_gateway\_domain\_name
|
||||||
|
|
||||||
|
Registers a custom domain name for use with AWS API Gateway.
|
||||||
|
|
||||||
|
This resource just establishes ownership of and the TLS settings for
|
||||||
|
a particular domain name. An API can be attached to a particular path
|
||||||
|
under the registered domain name using
|
||||||
|
[the `aws_api_gateway_base_path_mapping` resource](api_gateway_base_path_mapping.html).
|
||||||
|
|
||||||
|
Internally API Gateway creates a CloudFront distribution to
|
||||||
|
route requests on the given hostname. In addition to this resource
|
||||||
|
it's necessary to create a DNS record corresponding to the
|
||||||
|
given domain name which is an alias (either Route53 alias or
|
||||||
|
traditional CNAME) to the Cloudfront domain name exported in the
|
||||||
|
`cloudfront_domain_name` attribute.
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
resource "aws_api_gateway_domain_name" "example" {
|
||||||
|
domain_name = "api.example.com"
|
||||||
|
|
||||||
|
certificate_name = "example-api"
|
||||||
|
certificate_body = "${file("${path.module}/example.com/example.crt")}"
|
||||||
|
certificate_chain = "${file("${path.module}/example.com/ca.crt")}"
|
||||||
|
certificate_private_key = "${file("${path.module}/example.com/example.key")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Example DNS record using Route53.
|
||||||
|
# Route53 is not specifically required; any DNS host can be used.
|
||||||
|
resource "aws_route53_record" "example" {
|
||||||
|
zone_id = "${aws_route53_zone.example.id}" # See aws_route53_zone for how to create this
|
||||||
|
|
||||||
|
name = "${aws_api_gateway_domain_name.example.domain_name}"
|
||||||
|
type = "A"
|
||||||
|
|
||||||
|
alias {
|
||||||
|
name = "${aws_api_gateway_domain_name.example.cloudfront_domain_name}"
|
||||||
|
zone_id = "${aws_api_gateway_domain_name.example.cloudfront_zone_id}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Argument Reference
|
||||||
|
|
||||||
|
The following arguments are supported:
|
||||||
|
|
||||||
|
* `domain_name` - (Required) The fully-qualified domain name to register
|
||||||
|
* `certificate_name` - (Required) The unique name to use when registering this
|
||||||
|
cert as an IAM server certificate
|
||||||
|
* `certificate_body` - (Required) The certificate issued for the domain name
|
||||||
|
being registered, in PEM format
|
||||||
|
* `certificate_chain` - (Required) The certificate for the CA that issued the
|
||||||
|
certificate, along with any intermediate CA certificates required to
|
||||||
|
create an unbroken chain to a certificate trusted by the intended API clients.
|
||||||
|
* `certificate_private_key` - (Required) The private key associated with the
|
||||||
|
domain certificate given in `certificate_body`.
|
||||||
|
|
||||||
|
## Attributes Reference
|
||||||
|
|
||||||
|
The following attributes are exported:
|
||||||
|
|
||||||
|
* `id` - The internal id assigned to this domain name by API Gateway.
|
||||||
|
* `cloudfront_domain_name` - The hostname created by Cloudfront to represent
|
||||||
|
the distribution that implements this domain name mapping.
|
||||||
|
* `cloudfront_zone_id` - For convenience, the hosted zone id (`Z2FDTNDATAQYW2`)
|
||||||
|
that can be used to create a Route53 alias record for the distribution.
|
|
@ -56,9 +56,15 @@
|
||||||
<li<%= sidebar_current("docs-aws-resource-api-gateway-authorizer") %>>
|
<li<%= sidebar_current("docs-aws-resource-api-gateway-authorizer") %>>
|
||||||
<a href="/docs/providers/aws/r/api_gateway_authorizer.html">aws_api_gateway_authorizer</a>
|
<a href="/docs/providers/aws/r/api_gateway_authorizer.html">aws_api_gateway_authorizer</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li<%= sidebar_current("docs-aws-resource-api-gateway-base-path-mapping") %>>
|
||||||
|
<a href="/docs/providers/aws/r/api_gateway_base_path_mapping.html">aws_api_gateway_base_path_mapping</a>
|
||||||
|
</li>
|
||||||
<li<%= sidebar_current("docs-aws-resource-api-gateway-deployment") %>>
|
<li<%= sidebar_current("docs-aws-resource-api-gateway-deployment") %>>
|
||||||
<a href="/docs/providers/aws/r/api_gateway_deployment.html">aws_api_gateway_deployment</a>
|
<a href="/docs/providers/aws/r/api_gateway_deployment.html">aws_api_gateway_deployment</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li<%= sidebar_current("docs-aws-resource-api-gateway-domain-name") %>>
|
||||||
|
<a href="/docs/providers/aws/r/api_gateway_domain_name.html">aws_api_gateway_domain_name</a>
|
||||||
|
</li>
|
||||||
<li<%= sidebar_current("docs-aws-resource-api-gateway-integration") %>>
|
<li<%= sidebar_current("docs-aws-resource-api-gateway-integration") %>>
|
||||||
<a href="/docs/providers/aws/r/api_gateway_integration.html">aws_api_gateway_integration</a>
|
<a href="/docs/providers/aws/r/api_gateway_integration.html">aws_api_gateway_integration</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue