origin_request_policy#

State module for managing Cloudfront Origin request policies.

async idem_aws.states.aws.cloudfront.origin_request_policy.present(hub, ctx, name: str, headers_config: OriginRequestPolicyHeadersConfig = None, cookies_config: OriginRequestPolicyCookiesConfig = None, query_strings_config: OriginRequestPolicyQueryStringsConfig = None, comment: str = None, resource_id: str = None) Dict[str, Any][source]#

Creates an origin request policy.

After you create an origin request policy, you can attach it to one or morecache behaviors. When it’s attached to a cache behavior, the origin request policy determines the values th includes the following: The request body and the URL path (without the domain name) from the viewer request.

The headers that CloudFront automatically includes in every origin request, including Host, User-Agent, and X-Amz-Cf-Id. All HTTP headers, cookies, and URL query strings that are specified in the cache policy or the origin request policy. These can include items from the viewer request and, in the case of headers, additional ones that are added by CloudFront. CloudFront sends a request when it can’t find a valid object in its cache that matches the request. If you want to send values to the origin and also include them in the cache key, use CachePolicy. For more information about origin request policies, see Controlling origin requests in the Amazon CloudFront Developer Guide.

Parameters:
  • name (str) – An Idem name of the resource.

  • resource_id (str, Optional) – An identifier of the resource in the provider. Defaults to None.

  • comment (str, Optional) – A comment to describe the origin request policy. The comment cannot be longer than 128 characters.

  • headers_config (dict) –

    The HTTP headers to include in origin requests. These can include headers from viewer requests and additional headers added by CloudFront.

    • HeaderBehavior (str):

      Determines whether any HTTP headers are included in requests that CloudFront sends to the origin. Valid values are: none – HTTP headers are not included in requests that CloudFront sends to the origin. Even when this field is set to none, any headers that are listed in a CachePolicy are included in origin requests. whitelist – The HTTP headers that are listed in the Headers type are included in requests that CloudFront sends to the origin. allViewer – All HTTP headers in viewer requests are included in requests that CloudFront sends to the origin. allViewerAndWhitelistCloudFront – All HTTP headers in viewer requests and the additional CloudFront headers that are listed in the Headers type are included in requests that CloudFront sends to the origin. The additional headers are added by CloudFront.

      • Headers (Dict[str, Any], Optional):

        Contains a list of HTTP header names. * Quantity (int): The number of header names in the Items list. * Items (list[str], Optional): A list of HTTP header names.

  • cookies_config (dict) –

    The cookies from viewer requests to include in origin requests.

    • CookieBehavior (str):

      Determines whether cookies in viewer requests are included in requests that CloudFront sends to the origin. Valid values are: none – Cookies in viewer requests are not included in requests that CloudFront sends to the origin. Even when this field is set to none, any cookies that are listed in a CachePolicy are included in origin requests. whitelist – The cookies in viewer requests that are listed in the CookieNames type are included in requests that CloudFront sends to the origin. all – All cookies in viewer requests are included in requests that CloudFront sends to the origin.

      • Cookies (Dict[str, Any], Optional):

        Contains a list of cookie names. * Quantity (int): The number of cookie names in the Items list. * Items (list[str], Optional): A list of cookie names.

  • query_strings_config (dict) –

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

    • QueryStringBehavior (str):

      Determines whether any URL query strings in viewer requests are included in requests that CloudFront sends to the origin. Valid values are: none – Query strings in viewer requests are not included in requests that CloudFront sends to the origin. Even when this field is set to none, any query strings that are listed in a CachePolicy are included in origin requests. whitelist – The query strings in viewer requests that are listed in the QueryStringNames type are included in requests that CloudFront sends to the origin. all – All query strings in viewer requests are included in requests that CloudFront sends to the origin.

      • QueryStrings (Dict[str, Any], Optional):

        Contains a list of the query strings in viewer requests that are included in requests that CloudFront sends to the origin. * Quantity (int): The number of query string names in the Items list. * Items (list[str], Optional): A list of query string names.

Request Syntax:

resource_is_present:
  aws.cloudfront.origin_request_policy.present:
    - name: "string"
    - comment: "string"
    - headers_config:
        HeaderBehavior: "dict"
    - cookies_config:
        CookieBehavior: "dict"
    - query_strings_config:
        QueryStringBehavior: "dict"
Returns:

Dict[str, Any]

Examples

resource_is_present:
  aws.cloudfront.origin_request_policy.present:
    - name: value
    - comment: value
    - headers_config:
        HeaderBehavior: none
    - cookies_config:
        CookieBehavior: none
    - query_strings_config:
        QueryStringBehavior: none
async idem_aws.states.aws.cloudfront.origin_request_policy.absent(hub, ctx, name: str, resource_id: str = None) Dict[str, Any][source]#

Deletes an origin request policy.

You cannot delete an origin request policy if it’s attached to any cache behaviors. First update your distributions to remove the origin request policy from all cache behaviors, then delete the origin request policy. To delete an origin request policy, you must provide the policy’s identifier and version.

Parameters:
  • name (str) – An Idem name of the resource.

  • resource_id (str) – An identifier of the resource in the provider.

Request Syntax:

resource_is_absent:
  aws_auto.cloudfront.origin_request_policy.absent:
    - name: "string"
    - resource_id: "string"
Returns:

Dict[str, Any]

Examples

resource_is_absent:
  aws_auto.cloudfront.origin_request_policy.absent:
    - name: value
    - resource_id: value
async idem_aws.states.aws.cloudfront.origin_request_policy.describe(hub, ctx) Dict[str, Dict[str, Any]][source]#

Describe the resource in a way that can be recreated/managed with the corresponding “present” function

Returns:

Dict[str, Any]

Examples

$ idem describe aws_auto.cloudfront.origin_request_policy