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

(experimental) Custom domain resource for the API.

Stability:

experimental

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) – (experimental) The custom domain name.

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

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

  • certificate_name (Optional[str]) – (experimental) 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]) – (experimental) The type of endpoint for this DomainName. Default: EndpointType.REGIONAL

  • ownership_certificate (Optional[ICertificate]) – (experimental) 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]) – (experimental) The Transport Layer Security (TLS) version + cipher suite for this domain name. Default: SecurityPolicy.TLS_1_2

Stability:

experimental

Methods

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

(experimental) Adds an endpoint to a domain name.

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

  • certificate_name (Optional[str]) – (experimental) 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]) – (experimental) The type of endpoint for this DomainName. Default: EndpointType.REGIONAL

  • ownership_certificate (Optional[ICertificate]) – (experimental) 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]) – (experimental) The Transport Layer Security (TLS) version + cipher suite for this domain name. Default: SecurityPolicy.TLS_1_2

Stability:

experimental

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

(experimental) The custom domain name.

Stability:

experimental

node

The construct tree node associated with this construct.

regional_domain_name

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

Stability:

experimental

regional_hosted_zone_id

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

Stability:

experimental

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)

(experimental) Import from attributes.

Parameters:
  • scope (Construct)

  • id (str)

  • name (str) – (experimental) domain name string.

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

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

Stability:

experimental

Return type:

IDomainName

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters:

x (Any)

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct)

Return type:

bool