DomainName

class aws_cdk.aws_apigatewayv2.DomainName(scope, id, *, domain_name, mtls=None, certificate, certificate_name=None, endpoint_type=None, ownership_certificate=None, security_policy=None)

Bases: Resource

Custom domain resource for the API.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_certificatemanager as acm
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration

# handler: lambda.Function


cert_arn = "arn:aws:acm:us-east-1:111111111111:certificate"
domain_name = "example.com"

dn = apigwv2.DomainName(self, "DN",
    domain_name=domain_name,
    certificate=acm.Certificate.from_certificate_arn(self, "cert", cert_arn)
)
api = apigwv2.HttpApi(self, "HttpProxyProdApi",
    default_integration=HttpLambdaIntegration("DefaultIntegration", handler),
    # https://${dn.domainName}/foo goes to prodApi $default stage
    default_domain_mapping=apigwv2.DomainMappingOptions(
        domain_name=dn,
        mapping_key="foo"
    )
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • domain_name (str) – The custom domain name.

  • mtls (Union[MTLSConfig, Dict[str, Any], None]) – The mutual TLS authentication configuration for a custom domain name. Default: - mTLS is not configured.

  • certificate (ICertificate) – The ACM certificate for this domain name. Certificate can be both ACM issued or imported.

  • certificate_name (Optional[str]) – The user-friendly name of the certificate that will be used by the endpoint for this domain name. Default: - No friendly certificate name

  • endpoint_type (Optional[EndpointType]) – The type of endpoint for this DomainName. Default: EndpointType.REGIONAL

  • ownership_certificate (Optional[ICertificate]) – A public certificate issued by ACM to validate that you own a custom domain. This parameter is required only when you configure mutual TLS authentication and you specify an ACM imported or private CA certificate for certificate. The ownership certificate validates that you have permissions to use the domain name. Default: - only required when configuring mTLS

  • security_policy (Optional[SecurityPolicy]) – The Transport Layer Security (TLS) version + cipher suite for this domain name. Default: SecurityPolicy.TLS_1_2

Methods

add_endpoint(*, certificate, certificate_name=None, endpoint_type=None, ownership_certificate=None, security_policy=None)

Adds an endpoint to a domain name.

Parameters:
  • certificate (ICertificate) – The ACM certificate for this domain name. Certificate can be both ACM issued or imported.

  • certificate_name (Optional[str]) – The user-friendly name of the certificate that will be used by the endpoint for this domain name. Default: - No friendly certificate name

  • endpoint_type (Optional[EndpointType]) – The type of endpoint for this DomainName. Default: EndpointType.REGIONAL

  • ownership_certificate (Optional[ICertificate]) – A public certificate issued by ACM to validate that you own a custom domain. This parameter is required only when you configure mutual TLS authentication and you specify an ACM imported or private CA certificate for certificate. The ownership certificate validates that you have permissions to use the domain name. Default: - only required when configuring mTLS

  • security_policy (Optional[SecurityPolicy]) – The Transport Layer Security (TLS) version + cipher suite for this domain name. Default: SecurityPolicy.TLS_1_2

Return type:

None

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

name

The custom domain name.

node

The tree node.

regional_domain_name

The domain name associated with the regional endpoint for this custom domain name.

regional_hosted_zone_id

The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_domain_name_attributes(scope, id, *, name, regional_domain_name, regional_hosted_zone_id)

Import from attributes.

Parameters:
  • scope (Construct) –

  • id (str) –

  • name (str) – domain name string.

  • regional_domain_name (str) – The domain name associated with the regional endpoint for this custom domain name.

  • regional_hosted_zone_id (str) – The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint.

Return type:

IDomainName

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool