aws-cdk-lib.aws_route53.CnameRecordProps

interface CnameRecordProps

LanguageType name
.NETAmazon.CDK.AWS.Route53.CnameRecordProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsroute53#CnameRecordProps
Javasoftware.amazon.awscdk.services.route53.CnameRecordProps
Pythonaws_cdk.aws_route53.CnameRecordProps
TypeScript (source)aws-cdk-lib » aws_route53 » CnameRecordProps

Construction properties for a CnameRecord.

Example

import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import * as route53 from 'aws-cdk-lib/aws-route53';

const myDomainName = 'api.example.com';
const certificate = new acm.Certificate(this, 'cert', { domainName: myDomainName });
const schema = new appsync.SchemaFile({ filePath: 'mySchemaFile' })
const api = new appsync.GraphqlApi(this, 'api', {
  name: 'myApi',
  schema,
  domainName: {
    certificate,
    domainName: myDomainName,
  },
});

// hosted zone and route53 features
declare const hostedZoneId: string;
declare const zoneName = 'example.com';

// hosted zone for adding appsync domain
const zone = route53.HostedZone.fromHostedZoneAttributes(this, `HostedZone`, {
  hostedZoneId,
  zoneName,
});

// create a cname to the appsync domain. will map to something like xxxx.cloudfront.net
new route53.CnameRecord(this, `CnameApiRecord`, {
  recordName: 'api',
  zone,
  domainName: api.appSyncDomainName,
});

Properties

NameTypeDescription
domainNamestringThe domain name of the target that this record should point to.
zoneIHostedZoneThe hosted zone in which to define the new record.
comment?stringA comment to add on the record.
deleteExisting?booleanWhether to delete the same record set in the hosted zone if it already exists (dangerous!).
recordName?stringThe subdomain name for this record. This should be relative to the zone root name.
ttl?DurationThe resource record cache time to live (TTL).

domainName

Type: string

The domain name of the target that this record should point to.


zone

Type: IHostedZone

The hosted zone in which to define the new record.


comment?

Type: string (optional, default: no comment)

A comment to add on the record.


deleteExisting?

Type: boolean (optional, default: false)

Whether to delete the same record set in the hosted zone if it already exists (dangerous!).

This allows to deploy a new record set while minimizing the downtime because the new record set will be created immediately after the existing one is deleted. It also avoids "manual" actions to delete existing record sets.

N.B.: this feature is dangerous, use with caution! It can only be used safely when deleteExisting is set to true as soon as the resource is added to the stack. Changing an existing Record Set's deleteExisting property from false -> true after deployment will delete the record!


recordName?

Type: string (optional, default: zone root)

The subdomain name for this record. This should be relative to the zone root name.

For example, if you want to create a record for acme.example.com, specify "acme".

You can also specify the fully qualified domain name which terminates with a ".". For example, "acme.example.com.".


ttl?

Type: Duration (optional, default: Duration.minutes(30))

The resource record cache time to live (TTL).