# DomainName

L2 construct · Stable

Custom domain resource for the API.

Extends: [Construct](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Construct.html) › [Resource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Resource.html) › DomainName
Implements: [IResource](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResource.html), [IDomainName](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IDomainName.html), [IEnvironmentAware](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.IEnvironmentAware.html), [IDomainNameRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_apigatewayv2.IDomainNameRef.html), IConstruct, IDependable

- CloudFormation: [`AWS::ApiGatewayV2::DomainName`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-apigatewayv2-domainname.html)
- L1 type: [`CfnDomainName`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDomainName.html)
- Source: [`aws-apigatewayv2/lib/common/domain-name.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/common/domain-name.ts#L173)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

TypeScript:

```ts
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as acm from 'aws-cdk-lib/aws-certificatemanager';

const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate';
const domainName = 'example.com';
declare const bucket: s3.Bucket;

new apigwv2.DomainName(this, 'DomainName', {
  domainName,
  certificate: acm.Certificate.fromCertificateArn(this, 'cert', certArn),
  mtls: {
    bucket,
    key: 'someca.pem',
    version: 'version',
  },
});
```

Python:

```python
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_certificatemanager as acm
# bucket: s3.Bucket

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

apigwv2.DomainName(self, "DomainName",
    domain_name=domain_name,
    certificate=acm.Certificate.from_certificate_arn(self, "cert", cert_arn),
    mtls=apigwv2.MTLSConfig(
        bucket=bucket,
        key="someca.pem",
        version="version"
    )
)
```

Java:

```java
import software.amazon.awscdk.services.s3.*;
import software.amazon.awscdk.services.certificatemanager.*;
Bucket bucket;

String certArn = "arn:aws:acm:us-east-1:111111111111:certificate";
String domainName = "example.com";

DomainName.Builder.create(this, "DomainName")
        .domainName(domainName)
        .certificate(Certificate.fromCertificateArn(this, "cert", certArn))
        .mtls(MTLSConfig.builder()
                .bucket(bucket)
                .key("someca.pem")
                .version("version")
                .build())
        .build();
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.S3;
using Amazon.CDK.AWS.CertificateManager;
Bucket bucket;

var certArn = "arn:aws:acm:us-east-1:111111111111:certificate";
var domainName = "example.com";

new DomainName(this, "DomainName", new DomainNameProps {
    DomainName = domainName,
    Certificate = Certificate.FromCertificateArn(this, "cert", certArn),
    Mtls = new MTLSConfig {
        Bucket = bucket,
        Key = "someca.pem",
        Version = "version"
    }
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import s3 "github.com/aws/aws-cdk-go/awscdk"
import acm "github.com/aws/aws-cdk-go/awscdk"
var bucket Bucket

certArn := "arn:aws:acm:us-east-1:111111111111:certificate"
domainName := "example.com"

apigwv2.NewDomainName(this, jsii.String("DomainName"), &DomainNameProps{
	DomainName: jsii.String(DomainName),
	Certificate: acm.Certificate_FromCertificateArn(this, jsii.String("cert"), certArn),
	Mtls: &MTLSConfig{
		Bucket: *Bucket,
		Key: jsii.String("someca.pem"),
		Version: jsii.String("version"),
	},
})
```

## Initializer

TypeScript:

```ts
new DomainName(scope: Construct, id: string, props: DomainNameProps)
```

Python:

```python
DomainName(scope: Construct, id: str, props: DomainNameProps)
```

Java:

```java
new DomainName(Construct scope, String id, DomainNameProps props)
```

C#:

```csharp
new DomainName(Construct scope, string id, DomainNameProps props)
```

Go:

```go
NewDomainName(Scope Construct, Id *string, Props DomainNameProps)
```

## Construct Props

- `certificate`: [ICertificateRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_certificatemanager.ICertificateRef.html) (required) — The ACM certificate for this domain name.

  Certificate can be both ACM issued or imported.

- `certificateName`: string — The user-friendly name of the certificate that will be used by the endpoint for this domain name.

  **Default:** No friendly certificate name

- `domainName`: string (required) — The custom domain name.

- `endpointType`: [EndpointType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.EndpointType.html) = EndpointType.REGIONAL — The type of endpoint for this DomainName.

- `ipAddressType`: [IpAddressType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IpAddressType.html) — The IP address types that can invoke the API.

  **Default:** undefined - AWS default is IPV4

- `mtls`: [MTLSConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.MTLSConfig.html) — The mutual TLS authentication configuration for a custom domain name.

  **Default:** mTLS is not configured.

- `ownershipCertificate`: [ICertificateRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_certificatemanager.ICertificateRef.html) — A public certificate issued by ACM to validate that you own a custom domain.

  **Default:** only required when configuring mTLS

  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.

- `securityPolicy`: [SecurityPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.SecurityPolicy.html) = SecurityPolicy.TLS_1_2 — The Transport Layer Security (TLS) version + cipher suite for this domain name.

## Properties

- `domainNameRef`: [DomainNameReference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_apigatewayv2.DomainNameReference.html) — A reference to a DomainName resource.

- `env`: [ResourceEnvironment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `name`: string — The custom domain name.

- `node`: [Node](https://docs.aws.amazon.com/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `regionalDomainName`: string — The domain name associated with the regional endpoint for this custom domain name.

- `regionalHostedZoneId`: string — The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint.

- `stack`: [Stack](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addEndpoint(options: EndpointOptions): void` — Adds an endpoint to a domain name.

  **Parameters**

  - `options` — domain name endpoint properties to be set.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — 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`).

- `fromDomainNameAttributes(scope: Construct, id: string, attrs: DomainNameAttributes): IDomainName` (static) — Import from attributes.

- `isConstruct(x: any): boolean` (static) — 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 object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
