Skip to content
v2.278.0

RecordTarget Class ​

Type union for a record that accepts multiple types of target.

Example ​

ts
declare const instance: ec2.Instance;

const elasticIp = new ec2.CfnEIP(this, 'EIP', {
  domain: 'vpc',
  instanceId: instance.instanceId,
});

declare const myZone: route53.HostedZone;
new route53.ARecord(this, 'ARecord', {
  zone: myZone,
  target: route53.RecordTarget.fromIpAddresses(elasticIp.ref),
});
python
# instance: ec2.Instance

# my_zone: route53.HostedZone


elastic_ip = ec2.CfnEIP(self, "EIP",
    domain="vpc",
    instance_id=instance.instance_id
)
route53.ARecord(self, "ARecord",
    zone=my_zone,
    target=route53.RecordTarget.from_ip_addresses(elastic_ip.ref)
)
java
Instance instance;

HostedZone myZone;


CfnEIP elasticIp = CfnEIP.Builder.create(this, "EIP")
        .domain("vpc")
        .instanceId(instance.getInstanceId())
        .build();
ARecord.Builder.create(this, "ARecord")
        .zone(myZone)
        .target(RecordTarget.fromIpAddresses(elasticIp.getRef()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
Instance instance;

HostedZone myZone;


var elasticIp = new CfnEIP(this, "EIP", new CfnEIPProps {
    Domain = "vpc",
    InstanceId = instance.InstanceId
});
new ARecord(this, "ARecord", new ARecordProps {
    Zone = myZone,
    Target = RecordTarget.FromIpAddresses(elasticIp.Ref)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var instance Instance

var myZone HostedZone


elasticIp := ec2.NewCfnEIP(this, jsii.String("EIP"), &CfnEIPProps{
	Domain: jsii.String("vpc"),
	InstanceId: instance.InstanceId,
})
route53.NewARecord(this, jsii.String("ARecord"), &ARecordProps{
	Zone: myZone,
	Target: route53.RecordTarget_FromIpAddresses(elasticIp.ref),
})

Properties ​

aliasTargetmay be undefinedIAliasRecordTargetalias_targetmay be undefinedIAliasRecordTargetaliasTargetmay be undefinedIAliasRecordTargetAliasTargetmay be undefinedIAliasRecordTargetAliasTargetmay be undefinedIAliasRecordTarget #
alias for targets such as CloudFront distribution to route traffic to.
valuesmay be undefinedstring[]valuesmay be undefinedtyping.List[str]valuesmay be undefinedList<String>Valuesmay be undefinedstring[]Valuesmay be undefined*[]*string #
correspond with the chosen record type (e.g. for 'A' Type, specify one or more IP addresses).

Methods ​

fromAlias(aliasTarget: IAliasRecordTarget): RecordTarget // chainable@staticmethod def from_alias(alias_target: IAliasRecordTarget) -> RecordTargetpublic static RecordTarget fromAlias(IAliasRecordTarget aliasTarget)public static RecordTarget FromAlias(IAliasRecordTarget aliasTarget)func FromAlias(AliasTarget IAliasRecordTarget) RecordTarget static #
Use an alias as target.
fromIpAddresses(...ipAddresses: string[]): RecordTarget // chainable@staticmethod def from_ip_addresses(ip_addresses: str) -> RecordTargetpublic static RecordTarget fromIpAddresses(String ipAddresses)public static RecordTarget FromIpAddresses(string ipAddresses)func FromIpAddresses(IpAddresses *string) RecordTarget static #
Use ip addresses as target.
fromValues(...values: string[]): RecordTarget // chainable@staticmethod def from_values(values: str) -> RecordTargetpublic static RecordTarget fromValues(String values)public static RecordTarget FromValues(string values)func FromValues(Values *string) RecordTarget static #
Use string values as target.