# CloudFrontTarget

Use a CloudFront Distribution as an alias record target.

Implements: [IAliasRecordTarget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53.IAliasRecordTarget.html)

- Source: [`aws-route53-targets/lib/cloudfront-target.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-route53-targets/lib/cloudfront-target.ts#L9)

## Example

TypeScript:

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

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

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

C# / .NET:

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

Golang:

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

TypeScript:

```ts
new CloudFrontTarget(distribution: IDistribution)
```

Python:

```python
CloudFrontTarget(distribution: IDistribution)
```

Java:

```java
new CloudFrontTarget(IDistribution distribution)
```

C# / .NET:

```csharp
new CloudFrontTarget(IDistribution distribution)
```

Golang:

```go
NewCloudFrontTarget(Distribution IDistribution)
```

## Properties

- `CLOUDFRONT_ZONE_ID`: string (static) — The hosted zone Id if using an alias record in Route53.

  This value never changes.

## Methods

- `bind(_record: IRecordSet, _zone?: IHostedZone): AliasRecordTargetConfig` — Return hosted zone ID and DNS name, usable for Route53 alias targets.

- `getHostedZoneId(scope: IConstruct): string` (static) — Get the hosted zone id for the current scope.

  **Parameters**

  - `scope` — - scope in which this resource is defined.
