aws-solutions-constructs.aws-route53-apigateway


Nameaws-solutions-constructs.aws-route53-apigateway JSON
Version 2.74.0 PyPI version JSON
download
home_pagehttps://github.com/awslabs/aws-solutions-constructs.git
SummaryCDK constructs for connecting an Amazon Route53 domain to an API Gateway.
upload_time2024-10-22 18:10:03
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aws-route53-apigateway module

<!--BEGIN STABILITY BANNER-->---


![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)

> 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](https://semver.org/) 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.

---
<!--END STABILITY BANNER-->

| **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
|:-------------|:-------------|

<div style="height:8px"></div>

| **Language**     | **Package**        |
|:-------------|-----------------|
|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_route53_apigateway`|
|![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-route53-apigateway`|
|![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) 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:

Typescript

```python
import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import * as route53 from "aws-cdk-lib/aws-route53";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
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;

// domainName must match existing hosted zone in your account and the existing certificate
const ourHostedZone = route53.HostedZone.fromLookup(this, 'HostedZone', {
    domainName: "example.com",
});

const certificate = acm.Certificate.fromCertificateArn(
    this,
    "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', {
    existingApiGatewayInterface: existingRestApi,
    existingHostedZoneInterface: ourHostedZone,
    publicApi: true,
    existingCertificateInterface: certificate
});
```

Python

```python
from aws_solutions_constructs.aws_route53_apigateway import Route53ToApiGateway
from aws_cdk import (
    aws_route53 as route53,
    aws_certificatemanager as acm,
    Stack
)
from constructs import Construct

# 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
existingRestApi = previouslyCreatedApigatewayToLambdaConstruct.apiGateway

# domain_name must match existing hosted zone in your account and the existing certificate
ourHostedZone = route53.HostedZone.from_lookup(self, 'HostedZone',
                                                domain_name="example.com",
                                                )

# Obtain a pre-existing certificate from your account
certificate = acm.Certificate.from_certificate_arn(
    self,
    'existing-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.
Route53ToApiGateway(self, 'Route53ToApigatewayPattern',
                    existing_api_gateway_interface=existingRestApi,
                    existing_hosted_zone_interface=ourHostedZone,
                    public_api=True,
                    existing_certificate_interface=certificate
                    )

```

Java

```java
import software.constructs.Construct;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.route53.*;
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awscdk.services.certificatemanager.*;
import software.amazon.awsconstructs.services.route53apigateway.*;

// 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
final IRestApi existingRestApi = previouslyCreatedApigatewayToLambdaConstruct.getApiGateway();

// domainName must match existing hosted zone in your account and the existing certificate
final IHostedZone ourHostedZone = HostedZone.fromLookup(this, "HostedZone",
        new HostedZoneProviderProps.Builder()
                .domainName("example.com")
                .build());

// Obtain a pre-existing certificate from your account
final ICertificate certificate = Certificate.fromCertificateArn(
        this,
        "existing-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",
        new Route53ToApiGatewayProps.Builder()
                .existingApiGatewayInterface(existingRestApi)
                .existingHostedZoneInterface(ourHostedZone)
                .publicApi(true)
                .existingCertificateInterface(certificate)
                .build());
```

## 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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.PrivateHostedZoneProps.html) | 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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IHostedZone.html) | 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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) | An existing VPC in which to deploy the construct.|
|existingApiGatewayInterface|[api.IRestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IRestApi.html)|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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_certificatemanager.ICertificate.html)| An existing AWS Certificate Manager certificate for your custom domain name.|

## Pattern Properties

| **Name**     | **Type**        | **Description** |
|:-------------|:----------------|-----------------|
|hostedZone|[route53.IHostedZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IHostedZone.html)|The hosted zone used by the construct (whether created by the construct or provided by the client) |
| vpc? | [ec2.IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) | The VPC used by the construct. |
|apiGateway|[api.RestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
|certificate|[certificatemanager.ICertificate](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_certificatemanager.ICertificate.html)| 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

![Architecture Diagram](architecture.png)

---


© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/awslabs/aws-solutions-constructs.git",
    "name": "aws-solutions-constructs.aws-route53-apigateway",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/58/f8/96910b0b98f6ad4f7c0ecd290258db21def0c114d53f7e02f80769180393/aws_solutions_constructs_aws_route53_apigateway-2.74.0.tar.gz",
    "platform": null,
    "description": "# aws-route53-apigateway module\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)\n\n> All classes are under active development and subject to non-backward compatible changes or removal in any\n> future version. These are not subject to the [Semantic Versioning](https://semver.org/) model.\n> 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.\n\n---\n<!--END STABILITY BANNER-->\n\n| **Reference Documentation**:| <span style=\"font-weight: normal\">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|\n|:-------------|:-------------|\n\n<div style=\"height:8px\"></div>\n\n| **Language**     | **Package**        |\n|:-------------|-----------------|\n|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_route53_apigateway`|\n|![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-route53-apigateway`|\n|![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.route53apigateway`|\n\n## Overview\n\nThis AWS Solutions Construct implements an Amazon Route 53 connected to a configured Amazon API Gateway REST API.\n\nHere is a minimal deployable pattern definition:\n\nTypescript\n\n```python\nimport { Construct } from 'constructs';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport * as route53 from \"aws-cdk-lib/aws-route53\";\nimport * as acm from \"aws-cdk-lib/aws-certificatemanager\";\nimport { Route53ToApiGateway } from '@aws-solutions-constructs/aws-route53-apigateway';\n\n// The construct requires an existing REST API, this can be created in raw CDK or extracted\n// from a previously instantiated construct that created an API Gateway REST API\nconst existingRestApi = previouslyCreatedApigatewayToLambdaConstruct.apiGateway;\n\n// domainName must match existing hosted zone in your account and the existing certificate\nconst ourHostedZone = route53.HostedZone.fromLookup(this, 'HostedZone', {\n    domainName: \"example.com\",\n});\n\nconst certificate = acm.Certificate.fromCertificateArn(\n    this,\n    \"fake-cert\",\n    \"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012\"\n);\n\n// This construct can only be attached to a configured API Gateway.\nnew Route53ToApiGateway(this, 'Route53ToApiGatewayPattern', {\n    existingApiGatewayInterface: existingRestApi,\n    existingHostedZoneInterface: ourHostedZone,\n    publicApi: true,\n    existingCertificateInterface: certificate\n});\n```\n\nPython\n\n```python\nfrom aws_solutions_constructs.aws_route53_apigateway import Route53ToApiGateway\nfrom aws_cdk import (\n    aws_route53 as route53,\n    aws_certificatemanager as acm,\n    Stack\n)\nfrom constructs import Construct\n\n# The construct requires an existing REST API, this can be created in raw CDK or extracted\n# from a previously instantiated construct that created an API Gateway REST API\nexistingRestApi = previouslyCreatedApigatewayToLambdaConstruct.apiGateway\n\n# domain_name must match existing hosted zone in your account and the existing certificate\nourHostedZone = route53.HostedZone.from_lookup(self, 'HostedZone',\n                                                domain_name=\"example.com\",\n                                                )\n\n# Obtain a pre-existing certificate from your account\ncertificate = acm.Certificate.from_certificate_arn(\n    self,\n    'existing-cert',\n    \"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012\"\n)\n\n# This construct can only be attached to a configured API Gateway.\nRoute53ToApiGateway(self, 'Route53ToApigatewayPattern',\n                    existing_api_gateway_interface=existingRestApi,\n                    existing_hosted_zone_interface=ourHostedZone,\n                    public_api=True,\n                    existing_certificate_interface=certificate\n                    )\n\n```\n\nJava\n\n```java\nimport software.constructs.Construct;\n\nimport software.amazon.awscdk.Stack;\nimport software.amazon.awscdk.StackProps;\nimport software.amazon.awscdk.services.route53.*;\nimport software.amazon.awscdk.services.apigateway.*;\nimport software.amazon.awscdk.services.certificatemanager.*;\nimport software.amazon.awsconstructs.services.route53apigateway.*;\n\n// The construct requires an existing REST API, this can be created in raw CDK\n// or extracted from a previously instantiated construct that created an API\n// Gateway REST API\nfinal IRestApi existingRestApi = previouslyCreatedApigatewayToLambdaConstruct.getApiGateway();\n\n// domainName must match existing hosted zone in your account and the existing certificate\nfinal IHostedZone ourHostedZone = HostedZone.fromLookup(this, \"HostedZone\",\n        new HostedZoneProviderProps.Builder()\n                .domainName(\"example.com\")\n                .build());\n\n// Obtain a pre-existing certificate from your account\nfinal ICertificate certificate = Certificate.fromCertificateArn(\n        this,\n        \"existing-cert\",\n        \"arn:aws:acm:us-east-1:123456789012:certificate/11112222-3333-1234-1234-123456789012\");\n\n// This construct can only be attached to a configured API Gateway.\nnew Route53ToApiGateway(this, \"Route53ToApiGatewayPattern\",\n        new Route53ToApiGatewayProps.Builder()\n                .existingApiGatewayInterface(existingRestApi)\n                .existingHostedZoneInterface(ourHostedZone)\n                .publicApi(true)\n                .existingCertificateInterface(certificate)\n                .build());\n```\n\n## Pattern Construct Props\n\nThis 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.\n\nThis 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.\n\n| **Name**     | **Type**        | **Description** |\n|:-------------|:----------------|-----------------|\n| publicApi | boolean | Whether the construct is deploying a private or public API. This has implications for the Hosted Zone and VPC. |\n| privateHostedZoneProps? | [route53.PrivateHostedZoneProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.PrivateHostedZoneProps.html) | 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. |\n| existingHostedZoneInterface? | [route53.IHostedZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IHostedZone.html) | 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.|\n| existingVpc? | [ec2.IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) | An existing VPC in which to deploy the construct.|\n|existingApiGatewayInterface|[api.IRestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.IRestApi.html)|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.*|\n| existingCertificateInterface |[certificatemanager.ICertificate](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_certificatemanager.ICertificate.html)| An existing AWS Certificate Manager certificate for your custom domain name.|\n\n## Pattern Properties\n\n| **Name**     | **Type**        | **Description** |\n|:-------------|:----------------|-----------------|\n|hostedZone|[route53.IHostedZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IHostedZone.html)|The hosted zone used by the construct (whether created by the construct or provided by the client) |\n| vpc? | [ec2.IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) | The VPC used by the construct. |\n|apiGateway|[api.RestApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|\n|certificate|[certificatemanager.ICertificate](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_certificatemanager.ICertificate.html)| THe certificate used by the construct (whether create by the construct or provided by the client)\n\n## Default settings\n\nOut of the box implementation of the Construct without any override will set the following defaults:\n\n### Amazon Route53\n\n* Adds an ALIAS record to the new or provided Hosted Zone that routes to the construct's API Gateway\n\n### Amazon API Gateway\n\n* User provided API Gateway object is used as-is\n* Sets up custom domain name mapping to API\n\n## Architecture\n\n![Architecture Diagram](architecture.png)\n\n---\n\n\n\u00a9 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CDK constructs for connecting an Amazon Route53 domain to an API Gateway.",
    "version": "2.74.0",
    "project_urls": {
        "Homepage": "https://github.com/awslabs/aws-solutions-constructs.git",
        "Source": "https://github.com/awslabs/aws-solutions-constructs.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b0fa410b002f18f6d9ea7855cebfdf718088e8aa4a5aa48e020bfb3e3b7a5d1",
                "md5": "2cac0b262feb62d8f42d41da5934033f",
                "sha256": "1c6df1adf69b0bc2f7f6f61aa4cfb12d57ebcec4de0a6a72a5ccc385903b240e"
            },
            "downloads": -1,
            "filename": "aws_solutions_constructs.aws_route53_apigateway-2.74.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2cac0b262feb62d8f42d41da5934033f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 132646,
            "upload_time": "2024-10-22T18:08:38",
            "upload_time_iso_8601": "2024-10-22T18:08:38.692912Z",
            "url": "https://files.pythonhosted.org/packages/0b/0f/a410b002f18f6d9ea7855cebfdf718088e8aa4a5aa48e020bfb3e3b7a5d1/aws_solutions_constructs.aws_route53_apigateway-2.74.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "58f896910b0b98f6ad4f7c0ecd290258db21def0c114d53f7e02f80769180393",
                "md5": "cb8874421b0b1bed79308bdac474457f",
                "sha256": "7335dd6ae53fbdae14b358091582b6a4e07bf81bfd71fc491243c6859625d28f"
            },
            "downloads": -1,
            "filename": "aws_solutions_constructs_aws_route53_apigateway-2.74.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cb8874421b0b1bed79308bdac474457f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 134099,
            "upload_time": "2024-10-22T18:10:03",
            "upload_time_iso_8601": "2024-10-22T18:10:03.082427Z",
            "url": "https://files.pythonhosted.org/packages/58/f8/96910b0b98f6ad4f7c0ecd290258db21def0c114d53f7e02f80769180393/aws_solutions_constructs_aws_route53_apigateway-2.74.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 18:10:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "awslabs",
    "github_project": "aws-solutions-constructs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-solutions-constructs.aws-route53-apigateway"
}
        
Elapsed time: 0.62713s