OriginRequestPolicyProps

class aws_cdk.aws_cloudfront.OriginRequestPolicyProps(*, comment=None, cookie_behavior=None, header_behavior=None, origin_request_policy_name=None, query_string_behavior=None)

Bases: object

Properties for creating a Origin Request Policy.

Parameters
  • comment (Optional[str]) – A comment to describe the origin request policy. Default: - no comment

  • cookie_behavior (Optional[OriginRequestCookieBehavior]) – The cookies from viewer requests to include in origin requests. Default: OriginRequestCookieBehavior.none()

  • header_behavior (Optional[OriginRequestHeaderBehavior]) – The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront. Default: OriginRequestHeaderBehavior.none()

  • origin_request_policy_name (Optional[str]) – A unique name to identify the origin request policy. The name must only include ‘-‘, ‘_’, or alphanumeric characters. Default: - generated from the id

  • query_string_behavior (Optional[OriginRequestQueryStringBehavior]) – The URL query strings from viewer requests to include in origin requests. Default: OriginRequestQueryStringBehavior.none()

ExampleMetadata

infused

Example:

# Creating a custom origin request policy for a Distribution -- all parameters optional
# bucket_origin: origins.S3Origin

my_origin_request_policy = cloudfront.OriginRequestPolicy(self, "OriginRequestPolicy",
    origin_request_policy_name="MyPolicy",
    comment="A default policy",
    cookie_behavior=cloudfront.OriginRequestCookieBehavior.none(),
    header_behavior=cloudfront.OriginRequestHeaderBehavior.all("CloudFront-Is-Android-Viewer"),
    query_string_behavior=cloudfront.OriginRequestQueryStringBehavior.allow_list("username")
)

cloudfront.Distribution(self, "myDistCustomPolicy",
    default_behavior=cloudfront.BehaviorOptions(
        origin=bucket_origin,
        origin_request_policy=my_origin_request_policy
    )
)

Attributes

comment

A comment to describe the origin request policy.

Default
  • no comment

Return type

Optional[str]

cookie_behavior

The cookies from viewer requests to include in origin requests.

Default

OriginRequestCookieBehavior.none()

Return type

Optional[OriginRequestCookieBehavior]

header_behavior

The HTTP headers to include in origin requests.

These can include headers from viewer requests and additional headers added by CloudFront.

Default

OriginRequestHeaderBehavior.none()

Return type

Optional[OriginRequestHeaderBehavior]

origin_request_policy_name

A unique name to identify the origin request policy.

The name must only include ‘-‘, ‘_’, or alphanumeric characters.

Default
  • generated from the id

Return type

Optional[str]

query_string_behavior

The URL query strings from viewer requests to include in origin requests.

Default

OriginRequestQueryStringBehavior.none()

Return type

Optional[OriginRequestQueryStringBehavior]