class DomainName (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.APIGatewayv2.DomainName |
![]() | software.amazon.awscdk.services.apigatewayv2.DomainName |
![]() | aws_cdk.aws_apigatewayv2.DomainName |
![]() | @aws-cdk/aws-apigatewayv2 ยป DomainName |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IDomain
Custom domain resource for the API.
Example
import * as acm from '@aws-cdk/aws-certificatemanager';
import { HttpLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate';
const domainName = 'example.com';
const dn = new apigwv2.DomainName(this, 'DN', {
domainName,
certificate: acm.Certificate.fromCertificateArn(this, 'cert', certArn),
});
declare const handler: lambda.Function;
const api = new apigwv2.HttpApi(this, 'HttpProxyProdApi', {
defaultIntegration: new HttpLambdaIntegration('DefaultIntegration', handler),
// https://${dn.domainName}/foo goes to prodApi $default stage
defaultDomainMapping: {
domainName: dn,
mappingKey: 'foo',
},
});
Initializer
new DomainName(scope: Construct, id: string, props: DomainNameProps)
Parameters
- scope
Construct
- id
string
- props
Domain
Name Props
Construct Props
Name | Type | Description |
---|---|---|
certificate | ICertificate | The ACM certificate for this domain name. |
domain | string | The custom domain name. |
certificate | string | The user-friendly name of the certificate that will be used by the endpoint for this domain name. |
endpoint | Endpoint | The type of endpoint for this DomainName. |
mtls? | MTLSConfig | The mutual TLS authentication configuration for a custom domain name. |
ownership | ICertificate | A public certificate issued by ACM to validate that you own a custom domain. |
security | Security | The Transport Layer Security (TLS) version + cipher suite for this domain name. |
certificate
Type:
ICertificate
The ACM certificate for this domain name.
Certificate can be both ACM issued or imported.
domainName
Type:
string
The custom domain name.
certificateName?
Type:
string
(optional, default: No friendly certificate name)
The user-friendly name of the certificate that will be used by the endpoint for this domain name.
endpointType?
Type:
Endpoint
(optional, default: EndpointType.REGIONAL)
The type of endpoint for this DomainName.
mtls?
Type:
MTLSConfig
(optional, default: mTLS is not configured.)
The mutual TLS authentication configuration for a custom domain name.
ownershipCertificate?
Type:
ICertificate
(optional, default: only required when configuring mTLS)
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.
securityPolicy?
Type:
Security
(optional, default: SecurityPolicy.TLS_1_2)
The Transport Layer Security (TLS) version + cipher suite for this domain name.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
name | string | The custom domain name. |
node | Construct | The construct tree node associated with this construct. |
regional | string | The domain name associated with the regional endpoint for this custom domain name. |
regional | string | The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
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
Type:
string
The custom domain name.
node
Type:
Construct
The construct tree node associated with this construct.
regionalDomainName
Type:
string
The domain name associated with the regional endpoint for this custom domain name.
regionalHostedZoneId
Type:
string
The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | Adds an endpoint to a domain name. |
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Import from attributes. |
addEndpoint(options)
public addEndpoint(options: EndpointOptions): void
Parameters
- options
Endpoint
โ domain name endpoint properties to be set.Options
Adds an endpoint to a domain name.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromDomainNameAttributes(scope, id, attrs)
public static fromDomainNameAttributes(scope: Construct, id: string, attrs: DomainNameAttributes): IDomainName
Parameters
- scope
Construct
- id
string
- attrs
Domain
Name Attributes
Returns
Import from attributes.