# FunctionUrlOriginWithOACProps

Properties for configuring a Lambda Functions URLs with OAC.

Extends: [FunctionUrlOriginProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront_origins.FunctionUrlOriginProps.html)
Used as argument in: [FunctionUrlOrigin.withOriginAccessControl](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront_origins.FunctionUrlOrigin.html#withoriginaccesscontrol)

- Source: [`aws-cloudfront-origins/lib/function-url-origin.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudfront-origins/lib/function-url-origin.ts#L55)
- Type last changed: v2.234.0 · 8 Jan 2026

## Example

TypeScript:

```ts
import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const fn: lambda.Function;

const fnUrl = fn.addFunctionUrl({
  authType: lambda.FunctionUrlAuthType.AWS_IAM,
});

// Define a custom OAC
const oac = new cloudfront.FunctionUrlOriginAccessControl(this, 'MyOAC', {
  originAccessControlName: 'CustomLambdaOAC',
  signing: cloudfront.Signing.SIGV4_ALWAYS,
});

// Set up Lambda Function URL with OAC in CloudFront Distribution
new cloudfront.Distribution(this, 'MyDistribution', {
  defaultBehavior: {
    origin: origins.FunctionUrlOrigin.withOriginAccessControl(fnUrl, {
      originAccessControl: oac,
    }),
  },
});
```

Python:

```python
import aws_cdk.aws_lambda as lambda_
# fn: lambda.Function

fn_url = fn.add_function_url(
    auth_type=lambda_.FunctionUrlAuthType.AWS_IAM
)

# Define a custom OAC
oac = cloudfront.FunctionUrlOriginAccessControl(self, "MyOAC",
    origin_access_control_name="CustomLambdaOAC",
    signing=cloudfront.Signing.SIGV4_ALWAYS
)

# Set up Lambda Function URL with OAC in CloudFront Distribution
cloudfront.Distribution(self, "MyDistribution",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.FunctionUrlOrigin.with_origin_access_control(fn_url,
            origin_access_control=oac
        )
    )
)
```

Java:

```java
import software.amazon.awscdk.services.lambda.*;
Function fn;

FunctionUrl fnUrl = fn.addFunctionUrl(FunctionUrlOptions.builder()
        .authType(FunctionUrlAuthType.AWS_IAM)
        .build());

// Define a custom OAC
FunctionUrlOriginAccessControl oac = FunctionUrlOriginAccessControl.Builder.create(this, "MyOAC")
        .originAccessControlName("CustomLambdaOAC")
        .signing(Signing.SIGV4_ALWAYS)
        .build();

// Set up Lambda Function URL with OAC in CloudFront Distribution
// Set up Lambda Function URL with OAC in CloudFront Distribution
Distribution.Builder.create(this, "MyDistribution")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(FunctionUrlOrigin.withOriginAccessControl(fnUrl, FunctionUrlOriginWithOACProps.builder()
                        .originAccessControl(oac)
                        .build()))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;
Function fn;

var fnUrl = fn.AddFunctionUrl(new FunctionUrlOptions {
    AuthType = FunctionUrlAuthType.AWS_IAM
});

// Define a custom OAC
var oac = new FunctionUrlOriginAccessControl(this, "MyOAC", new FunctionUrlOriginAccessControlProps {
    OriginAccessControlName = "CustomLambdaOAC",
    Signing = Signing.SIGV4_ALWAYS
});

// Set up Lambda Function URL with OAC in CloudFront Distribution
// Set up Lambda Function URL with OAC in CloudFront Distribution
new Distribution(this, "MyDistribution", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = FunctionUrlOrigin.WithOriginAccessControl(fnUrl, new FunctionUrlOriginWithOACProps {
            OriginAccessControl = oac
        })
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"
var fn Function

fnUrl := fn.AddFunctionUrl(&FunctionUrlOptions{
	AuthType: lambda.FunctionUrlAuthType_AWS_IAM,
})

// Define a custom OAC
oac := cloudfront.NewFunctionUrlOriginAccessControl(this, jsii.String("MyOAC"), &FunctionUrlOriginAccessControlProps{
	OriginAccessControlName: jsii.String("CustomLambdaOAC"),
	Signing: cloudfront.Signing_SIGV4_ALWAYS(),
})

// Set up Lambda Function URL with OAC in CloudFront Distribution
// Set up Lambda Function URL with OAC in CloudFront Distribution
cloudfront.NewDistribution(this, jsii.String("MyDistribution"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.FunctionUrlOrigin_WithOriginAccessControl(fnUrl, &FunctionUrlOriginWithOACProps{
			OriginAccessControl: oac,
		}),
	},
})
```

## 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.

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

  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.

- `originAccessControl`: [IOriginAccessControlRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_cloudfront.IOriginAccessControlRef.html) — An optional Origin Access Control.

  **Default:** an Origin Access Control will be created.

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

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

  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.
