aws-cdk-lib.aws_cloudfront.OriginRequestHeaderBehavior

class OriginRequestHeaderBehavior

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.OriginRequestHeaderBehavior
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#OriginRequestHeaderBehavior
Javasoftware.amazon.awscdk.services.cloudfront.OriginRequestHeaderBehavior
Pythonaws_cdk.aws_cloudfront.OriginRequestHeaderBehavior
TypeScript (source)aws-cdk-lib » aws_cloudfront » OriginRequestHeaderBehavior

Determines whether any HTTP headers (and if so, which headers) are included in requests that CloudFront sends to the origin.

Example

// Creating a custom origin request policy for a Distribution -- all parameters optional
declare const bucketOrigin: origins.S3Origin;
const myOriginRequestPolicy = new cloudfront.OriginRequestPolicy(this, 'OriginRequestPolicy', {
  originRequestPolicyName: 'MyPolicy',
  comment: 'A default policy',
  cookieBehavior: cloudfront.OriginRequestCookieBehavior.none(),
  headerBehavior: cloudfront.OriginRequestHeaderBehavior.all('CloudFront-Is-Android-Viewer'),
  queryStringBehavior: cloudfront.OriginRequestQueryStringBehavior.allowList('username'),
});

new cloudfront.Distribution(this, 'myDistCustomPolicy', {
  defaultBehavior: {
    origin: bucketOrigin,
    originRequestPolicy: myOriginRequestPolicy,
  },
});

Properties

NameTypeDescription
behaviorstringThe behavior of headers: allow all, none or an allow list.
headers?string[]The headers for the allow list or the included CloudFront headers, if applicable.

behavior

Type: string

The behavior of headers: allow all, none or an allow list.


headers?

Type: string[] (optional)

The headers for the allow list or the included CloudFront headers, if applicable.

Methods

NameDescription
static all(...cloudfrontHeaders)All HTTP headers in viewer requests are included in requests that CloudFront sends to the origin.
static allowList(...headers)Listed headers are included in requests that CloudFront sends to the origin.
static none()HTTP headers are not included in requests that CloudFront sends to the origin.

static all(...cloudfrontHeaders)

public static all(...cloudfrontHeaders: string[]): OriginRequestHeaderBehavior

Parameters

  • cloudfrontHeaders string

Returns

  • OriginRequestHeaderBehavior

All HTTP headers in viewer requests are included in requests that CloudFront sends to the origin.

Additionally, any additional CloudFront headers provided are included; the additional headers are added by CloudFront.

See also: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-cloudfront-headers.html


static allowList(...headers)

public static allowList(...headers: string[]): OriginRequestHeaderBehavior

Parameters

  • headers string

Returns

  • OriginRequestHeaderBehavior

Listed headers are included in requests that CloudFront sends to the origin.


static none()

public static none(): OriginRequestHeaderBehavior

Returns

  • OriginRequestHeaderBehavior

HTTP headers are not included in requests that CloudFront sends to the origin.

Any headers that are listed in a CachePolicy are still included in origin requests.