# LoadBalancerV2OriginProps

Properties for an Origin backed by a v2 load balancer.

Extends: [HttpOriginProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront_origins.HttpOriginProps.html)
Used as props by: [LoadBalancerV2Origin](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront_origins.LoadBalancerV2Origin.html)

- Source: [`aws-cloudfront-origins/lib/load-balancer-origin.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudfront-origins/lib/load-balancer-origin.ts#L8)

## Example

TypeScript:

```ts
declare const loadBalancer: elbv2.ApplicationLoadBalancer;
const origin = new origins.LoadBalancerV2Origin(loadBalancer, {
  connectionAttempts: 3,
  connectionTimeout: Duration.seconds(5),
  readTimeout: Duration.seconds(45),
  responseCompletionTimeout: Duration.seconds(120),
  keepaliveTimeout: Duration.seconds(45),
  protocolPolicy: cloudfront.OriginProtocolPolicy.MATCH_VIEWER,
});
```

Python:

```python
# load_balancer: elbv2.ApplicationLoadBalancer

origin = origins.LoadBalancerV2Origin(load_balancer,
    connection_attempts=3,
    connection_timeout=Duration.seconds(5),
    read_timeout=Duration.seconds(45),
    response_completion_timeout=Duration.seconds(120),
    keepalive_timeout=Duration.seconds(45),
    protocol_policy=cloudfront.OriginProtocolPolicy.MATCH_VIEWER
)
```

Java:

```java
ApplicationLoadBalancer loadBalancer;

LoadBalancerV2Origin origin = LoadBalancerV2Origin.Builder.create(loadBalancer)
        .connectionAttempts(3)
        .connectionTimeout(Duration.seconds(5))
        .readTimeout(Duration.seconds(45))
        .responseCompletionTimeout(Duration.seconds(120))
        .keepaliveTimeout(Duration.seconds(45))
        .protocolPolicy(OriginProtocolPolicy.MATCH_VIEWER)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
ApplicationLoadBalancer loadBalancer;

var origin = new LoadBalancerV2Origin(loadBalancer, new LoadBalancerV2OriginProps {
    ConnectionAttempts = 3,
    ConnectionTimeout = Duration.Seconds(5),
    ReadTimeout = Duration.Seconds(45),
    ResponseCompletionTimeout = Duration.Seconds(120),
    KeepaliveTimeout = Duration.Seconds(45),
    ProtocolPolicy = OriginProtocolPolicy.MATCH_VIEWER
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var loadBalancer ApplicationLoadBalancer

origin := origins.NewLoadBalancerV2Origin(loadBalancer, &LoadBalancerV2OriginProps{
	ConnectionAttempts: jsii.Number(3),
	ConnectionTimeout: awscdk.Duration_Seconds(jsii.Number(5)),
	ReadTimeout: awscdk.Duration_*Seconds(jsii.Number(45)),
	ResponseCompletionTimeout: awscdk.Duration_*Seconds(jsii.Number(120)),
	KeepaliveTimeout: awscdk.Duration_*Seconds(jsii.Number(45)),
	ProtocolPolicy: cloudfront.OriginProtocolPolicy_MATCH_VIEWER,
})
```

## Properties

- `connectionAttempts`: number = 3 — The number of times that CloudFront attempts to connect to the origin;

  valid values are 1, 2, or 3 attempts.

- `connectionTimeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(10) — The number of seconds that CloudFront waits when trying to establish a connection to the origin.

  Valid values are 1-10 seconds, inclusive.

- `customHeaders`: { [key: string]: string } = {} — A list of HTTP header names and values that CloudFront adds to requests it sends to the origin.

- `httpPort`: number = 80 — The HTTP port that CloudFront uses to connect to the origin.

- `httpsPort`: number = 443 — The HTTPS port that CloudFront uses to connect to the origin.

- `ipAddressType`: [OriginIpAddressType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.OriginIpAddressType.html) — Specifies which IP protocol CloudFront uses when connecting to your origin.

  **Default:** undefined - AWS Cloudfront default is IPv4

  If your origin uses both IPv4 and IPv6 protocols, you can choose dualstack to help optimize reliability.

- `keepaliveTimeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(5) — Specifies how long, in seconds, CloudFront persists its connection to the origin.

  The minimum is 1 second. The maximum is governed by the keep-alive timeout per origin quota,
  which is adjustable, so the effective maximum depends on the target account.

  The default quota allows up to 300 seconds; higher values require an approved limit increase
  in the target account, and otherwise produce an error at deploy time.

- `originAccessControlId`: string — The unique identifier of an origin access control for this origin.

  **Default:** no origin access control

- `originId`: string — A unique identifier for the origin.

  **Default:** an originid will be generated for you

  This value must be unique within the distribution.

- `originPath`: string = '/' — An optional path that CloudFront appends to the origin domain name when CloudFront requests content from the origin.

  Must begin, but not end, with '/' (e.g., '/production/images').

- `originShieldEnabled`: boolean = true — Origin Shield is enabled by setting originShieldRegion to a valid region, after this to disable Origin Shield again you must set this flag to false.

- `originShieldRegion`: string — When you enable Origin Shield in the AWS Region that has the lowest latency to your origin, you can get better network performance.

  **Default:** origin shield not enabled

- `originSslProtocols`: [OriginSslPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.OriginSslPolicy.html)[] = OriginSslPolicy.TLS_V1_2 — The SSL versions to use when interacting with the origin.

- `protocolPolicy`: [OriginProtocolPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.OriginProtocolPolicy.html) = OriginProtocolPolicy.HTTPS_ONLY — Specifies the protocol (HTTP or HTTPS) that CloudFront uses to connect to the origin.

- `readTimeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(30) — Specifies how long, in seconds, CloudFront waits for a response from the origin, also known as the origin response timeout.

  The minimum is 1 second. The maximum is governed by the origin response timeout quota, which is
  adjustable, so the effective maximum depends on the target account.

  The default quota allows up to 120 seconds; higher values require an approved limit increase
  in the target account, and otherwise produce an error at deploy time.

- `responseCompletionTimeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The time that a request from CloudFront to the origin can stay open and wait for a response.

  **Default:** undefined - AWS CloudFront default is not enforcing a maximum value

  If the complete response isn't received from the origin by this time, CloudFront ends the connection.

  Valid values are 1-3600 seconds, inclusive.
