aws-cdk-lib.aws_cloudfront.OriginRequestCookieBehavior

class OriginRequestCookieBehavior

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

Determines whether any cookies in viewer requests (and if so, which cookies) 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 cookies: allow all, none or an allow list.
cookies?string[]The cookies to allow, if the behavior is an allow list.

behavior

Type: string

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


cookies?

Type: string[] (optional)

The cookies to allow, if the behavior is an allow list.

Methods

NameDescription
static all()All cookies in viewer requests are included in requests that CloudFront sends to the origin.
static allowList(...cookies)Only the provided cookies are included in requests that CloudFront sends to the origin.
static none()Cookies in viewer requests are not included in requests that CloudFront sends to the origin.

static all()

public static all(): OriginRequestCookieBehavior

Returns

  • OriginRequestCookieBehavior

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


static allowList(...cookies)

public static allowList(...cookies: string[]): OriginRequestCookieBehavior

Parameters

  • cookies string

Returns

  • OriginRequestCookieBehavior

Only the provided cookies are included in requests that CloudFront sends to the origin.


static none()

public static none(): OriginRequestCookieBehavior

Returns

  • OriginRequestCookieBehavior

Cookies in viewer requests are not included in requests that CloudFront sends to the origin.

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