# RecordTarget

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

Obtainable from: RecordTarget.fromAlias, RecordTarget.fromIpAddresses, RecordTarget.fromValues

- Source: [`aws-route53/lib/record-set.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-route53/lib/record-set.ts#L332)

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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)
});
```

Golang:

```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

- `aliasTarget`: [IAliasRecordTarget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IAliasRecordTarget.html) — alias for targets such as CloudFront distribution to route traffic to.

- `values`: string[] — correspond with the chosen record type (e.g. for 'A' Type, specify one or more IP addresses).

## Methods

- `fromAlias(aliasTarget: IAliasRecordTarget): RecordTarget // chainable` (static) — Use an alias as target.

- `fromIpAddresses(...ipAddresses: string[]): RecordTarget // chainable` (static) — Use ip addresses as target.

- `fromValues(...values: string[]): RecordTarget // chainable` (static) — Use string values as target.
