CloudFrontTarget Class
Use a CloudFront Distribution as an alias record target.
Example
ts
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
declare const myZone: route53.HostedZone;
declare const distribution: cloudfront.CloudFrontWebDistribution;
new route53.AaaaRecord(this, 'Alias', {
zone: myZone,
target: route53.RecordTarget.fromAlias(new targets.CloudFrontTarget(distribution)),
});
python
import aws_cdk.aws_cloudfront as cloudfront
# my_zone: route53.HostedZone
# distribution: cloudfront.CloudFrontWebDistribution
route53.AaaaRecord(self, "Alias",
zone=my_zone,
target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(distribution))
)
java
import software.amazon.awscdk.services.cloudfront.*;
HostedZone myZone;
CloudFrontWebDistribution distribution;
AaaaRecord.Builder.create(this, "Alias")
.zone(myZone)
.target(RecordTarget.fromAlias(new CloudFrontTarget(distribution)))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CloudFront;
HostedZone myZone;
CloudFrontWebDistribution distribution;
new AaaaRecord(this, "Alias", new AaaaRecordProps {
Zone = myZone,
Target = RecordTarget.FromAlias(new CloudFrontTarget(distribution))
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cloudfront "github.com/aws/aws-cdk-go/awscdk"
var myZone HostedZone
var distribution CloudFrontWebDistribution
route53.NewAaaaRecord(this, jsii.String("Alias"), &AaaaRecordProps{
Zone: myZone,
Target: route53.RecordTarget_FromAlias(targets.NewCloudFrontTarget(distribution)),
})
Initializer
ts
new CloudFrontTarget(distribution: IDistribution)
python
CloudFrontTarget(distribution: IDistribution)
java
new CloudFrontTarget(IDistribution distribution)
csharp
new CloudFrontTarget(IDistribution distribution)
go
NewCloudFrontTarget(Distribution IDistribution)
Properties
CLOUDFRONT_ZONE_IDstringcloudfront_zone_idstrCLOUDFRONT_ZONE_IDStringCLOUDFRONT_ZONE_IDstringCLOUDFRONT_ZONE_ID*stringrequiredstatic#The hosted zone Id if using an alias record in Route53.
This value never changes.
Methods
bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfigdef bind(self, _record: IRecordSet, _zone: typing.Optional[IHostedZone] = None) -> AliasRecordTargetConfigpublic AliasRecordTargetConfig bind(IRecordSet _record, IHostedZone _zone)public AliasRecordTargetConfig Bind(IRecordSet _record, IHostedZone? _zone = null)func Bind(_record IRecordSet, _zone IHostedZone) AliasRecordTargetConfig#Return hosted zone ID and DNS name, usable for Route53 alias targets.
getHostedZoneId(scope: IConstruct): string@staticmethod def get_hosted_zone_id(scope: IConstruct) -> strpublic static String getHostedZoneId(IConstruct scope)public static string GetHostedZoneId(IConstruct scope)func GetHostedZoneId(Scope IConstruct) *stringstatic#Get the hosted zone id for the current scope.
1 parameter
Parameters
scopescopescopescopeScope— - scope in which this resource is defined.