CDK constructs for connecting an Amazon Route53 domain to an API Gateway.
Project description
aws-route53-apigateway module
---All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
Reference Documentation: | https://docs.aws.amazon.com/solutions/latest/constructs/ |
---|
Language | Package |
---|---|
Python | aws_solutions_constructs.aws_route53_apigateway |
Typescript | @aws-solutions-constructs/aws-route53-apigateway |
Java | software.amazon.awsconstructs.services.route53apigateway |
Overview
This AWS Solutions Construct implements an Amazon Route 53 connected to a configured Amazon API Gateway REST API.
Here is a minimal deployable pattern definition in Typescript:
import * as api from '@aws-cdk/aws-apigateway';
import * as lambda from "@aws-cdk/aws-lambda";
import * as route53 from "@aws-cdk/aws-route53";
import { Route53ToApigateway } from '@aws-solutions-constructs/aws-route53-apigateway';
// The construct requires an existing REST API, this can be created in raw CDK or extracted
// from a previously instantiated construct that created an API Gateway REST API
const existingRestApi = previouslyCreatedApigatewayToLambdaConstruct.apiGateway;
const ourHostedZone = route53.HostedZone.fromLookup(this, 'HostedZone', {
domainName: "example.com",
});
const certificate = acm.Certificate.fromCertificateArn(
stack,
"fake-cert",
"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012"
);
// This construct can only be attached to a configured API Gateway.
new Route53ToApigateway(this, 'Route53ToApigatewayPattern', {
existingApiGatewayObj: existingRestApi,
existingHostedZoneInterface: ourHostedZone,
publicApi: true,
existingCertificateInterface: certificate
});
Initializer
new Route53ToApigateway(scope: Construct, id: string, props: Route53ToApigatewayProps);
Parameters
- scope
Construct
- id
string
- props
Route53ToApigatewayProps
Pattern Construct Props
This construct cannot create a new Public Hosted Zone, if you are creating a public API you must supply an existing Public Hosted Zone that will be reconfigured with a new Alias record. Public Hosted Zones are configured with public domain names and are not well suited to be launched and torn down dynamically, so this construct will only reconfigure existing Public Hosted Zones.
This construct can create Private Hosted Zones. If you want a Private Hosted Zone, then you can either provide an existing Private Hosted Zone or a privateHostedZoneProps value with at least the Domain Name defined. If you are using privateHostedZoneProps, an existing wildcard certificate (*.example.com) must be issued from a previous domain to be used in the newly created Private Hosted Zone. New certificate creation and validation do not take place in this construct. A private Rest API already exists in a VPC, so that VPC must be provided in the existingVpc prop. There is no scenario where this construct can create a new VPC (since it can't create a new API), so the vpcProps property is not supported on this construct.
Name | Type | Description |
---|---|---|
publicApi | boolean | Whether the construct is deploying a private or public API. This has implications for the Hosted Zone and VPC. |
privateHostedZoneProps? | route53.PrivateHostedZoneProps | Optional custom properties for a new Private Hosted Zone. Cannot be specified for a public API. Cannot specify a VPC, it will use the VPC in existingVpc or the VPC created by the construct. Providing both this and existingHostedZoneInterface is an error. |
existingHostedZoneInterface? | route53.IHostedZone | Existing Public or Private Hosted Zone (type must match publicApi setting). Specifying both this and privateHostedZoneProps is an error. If this is a Private Hosted Zone, the associated VPC must be provided as the existingVpc property. |
existingVpc? | ec2.IVpc | An existing VPC in which to deploy the construct. |
existingApiGatewayInterface | api.IRestApi | The existing API Gateway instance that will be connected to the Route 53 hosted zone. Note that Route 53 can only be connected to a configured API Gateway, so this construct only accepts an existing IRestApi and does not accept apiGatewayProps. |
existingCertificateInterface | certificatemanager.ICertificate | An existing AWS Certificate Manager certificate for your custom domain name. |
Pattern Properties
Name | Type | Description |
---|---|---|
hostedZone | route53.IHostedZone | The hosted zone used by the construct (whether created by the construct or provided by the client) |
vpc? | ec2.IVpc | The VPC used by the construct. |
apiGateway | api.RestApi | Returns an instance of the API Gateway REST API created by the pattern. |
certificate | certificatemanager.ICertificate | THe certificate used by the construct (whether create by the construct or provided by the client) |
Default settings
Out of the box implementation of the Construct without any override will set the following defaults:
Amazon Route53
- Adds an ALIAS record to the new or provided Hosted Zone that routes to the construct's API Gateway
Amazon API Gateway
- User provided API Gateway object is used as-is
- Sets up custom domain name mapping to API
Architecture
© Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-solutions-constructs.aws-route53-apigateway-1.138.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e72c793bde1d572f8c290f456cecb494cc80fd64876613d1b91dcb2a2116435 |
|
MD5 | 095fb2c422a58f7745efa00f8c75573d |
|
BLAKE2b-256 | 3557504ee4c3e9ad180988037572dee5754e8d4a9dda55b2b439668ff6fc19b9 |
Hashes for aws_solutions_constructs.aws_route53_apigateway-1.138.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 968e85a27299719fb876a1552c66bddf820124942d9261cc26ecffe3de66b2d9 |
|
MD5 | dbba62fca4bee2d58ad3eb4d66e13f21 |
|
BLAKE2b-256 | 1e719b689994ce2c1940ec9aa833d2809b67a93d93d21dc399dfe045eafb552d |