Skip to content

Latest commit

 

History

History
133 lines (78 loc) · 6.19 KB

API.md

File metadata and controls

133 lines (78 loc) · 6.19 KB

Additional Route53 Targets for AWS CDK

build

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:

Features

  • 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 the aws-cdk doesn't implement a resource interface (ILoadBalancer) or other typical L2 concepts (abstract base class, "imports" using from methods) for constructs the ClassicLoadBalancerTarget requires a LoadBalancer outright. Since LoadBalancer 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.

Examples

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',
  })),
});

API Reference

Structs

LoadBalancerTargetAttributes

Initializer

import { LoadBalancerTargetAttributes } from '@renovosolutions/cdk-library-route53targets'

const loadBalancerTargetAttributes: LoadBalancerTargetAttributes = { ... }

Properties

Name Type Description
dnsName string The DNS name of the load balancer.
hostedZoneId string The hosted zone ID of the load balancer.

dnsNameRequired
public readonly dnsName: string;
  • Type: string

The DNS name of the load balancer.


hostedZoneIdRequired
public readonly hostedZoneId: string;
  • Type: string

The hosted zone ID of the load balancer.


Classes

LoadBalancerTargetFromAttributes

  • Implements: aws-cdk-lib.aws_route53.IAliasRecordTarget

Initializers

import { LoadBalancerTargetFromAttributes } from '@renovosolutions/cdk-library-route53targets'

new LoadBalancerTargetFromAttributes(loadBalancerTargetAttributes: LoadBalancerTargetAttributes)
Name Type Description
loadBalancerTargetAttributes LoadBalancerTargetAttributes No description.

loadBalancerTargetAttributesRequired

Methods

Name Description
bind Return hosted zone ID and DNS name, usable for Route53 alias targets.

bind
public bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfig

Return hosted zone ID and DNS name, usable for Route53 alias targets.

_recordRequired
  • Type: aws-cdk-lib.aws_route53.IRecordSet

_zoneOptional
  • Type: aws-cdk-lib.aws_route53.IHostedZone