OriginRequestQueryStringBehavior

class aws_cdk.aws_cloudfront.OriginRequestQueryStringBehavior(*args: Any, **kwargs)

Bases: object

Determines whether any URL query strings in viewer requests (and if so, which query strings) are included in requests that CloudFront sends to the origin.

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

behavior

The behavior of query strings – allow all, none, or only an allow list.

query_strings

The query strings to allow, if the behavior is an allow list.

Static Methods

classmethod all()

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

Return type:

OriginRequestQueryStringBehavior

classmethod allow_list(*query_strings)

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

Parameters:

query_strings (str) –

Return type:

OriginRequestQueryStringBehavior

classmethod deny_list(*query_strings)

All query strings except the provided queryStrings are included in requests that CloudFront sends to the origin.

Parameters:

query_strings (str) –

Return type:

OriginRequestQueryStringBehavior

classmethod none()

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

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

Return type:

OriginRequestQueryStringBehavior