This repo's intention is to add additional avenues for defining Route53 targets or adding targets that might not be available otherwise. See the (limited) feature list below:
- Add a load balancer target using the load balancers attributes instead of the resource class
LoadBalancer
. This is useful in cases where you need to add a Classic Load Balancer as a target, but the load balancer wasn't created in the same CDK app. Since the ELBv2 package in theaws-cdk
doesn't implement a resource interface (ILoadBalancer
) or other typical L2 concepts (abstract base class, "imports" usingfrom
methods) for constructs theClassicLoadBalancerTarget
requires aLoadBalancer
outright. SinceLoadBalancer
is a concrete resource class we can't redefine something we want to target from another CDK app. So, this feature allows us to use data we know about the load balancer to set it as a target more directly.
const zone = new r53.HostedZone(stack, 'HostedZone', {
zoneName: 'example.com',
});
new r53.ARecord(stack, 'AliasRecord', {
zone,
recordName: 'publiclb.example.com',
target: r53.RecordTarget.fromAlias(new LoadBalancerTargetFromAttributes({
dnsName: 'publiclb-1234567890.us-east-1.elb.amazonaws.com',
hostedZoneId: 'A1AAAA0A79A41A',
})),
});