Skip to main content

origin_request_policies

Creates, updates, deletes, gets or lists an origin_request_policies resource.

Overview

Nameorigin_request_policies
TypeResource
Idaws.cloudfront.origin_request_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe unique identifier for the origin request policy.
last_modified_timestringThe date and time when the origin request policy was last modified.
origin_request_policy_configstringThe origin request policy configuration.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_origin_request_policyselectid, regionGets an origin request policy, including the following metadata: The policy's identifier. The date and time when the policy was last modified. To get an origin request policy, you must provide the policy's identifier. If the origin request policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the origin request policy is not attached to a cache behavior, you can get the identifier using ListOriginRequestPolicies.
list_origin_request_policiesselectregionType, Marker, MaxItemsGets a list of origin request policies. You can optionally apply a filter to return only the managed policies created by Amazon Web Services, or only the custom policies created in your Amazon Web Services account. You can optionally specify the maximum number of items to receive in the response. If the total number of items in the list exceeds the maximum that you specify, or the default maximum, the response is paginated. To get the next page of items, send a subsequent request that specifies the NextMarker value from the current response as the Marker value in the subsequent request.
create_origin_request_policyinsertregion, OriginRequestPolicyConfigCreates an origin request policy. After you create an origin request policy, you can attach it to one or more cache behaviors. When it's attached to a cache behavior, the origin request policy determines the values that CloudFront includes in requests that it sends to the origin. Each request that CloudFront sends to the origin 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.
update_origin_request_policyupdateid, region, OriginRequestPolicyConfigIf-MatchUpdates an origin request policy configuration. When you update an origin request policy configuration, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update an origin request policy configuration: Use GetOriginRequestPolicyConfig to get the current configuration. Locally modify the fields in the origin request policy configuration that you want to update. Call UpdateOriginRequestPolicy by providing the entire origin request policy configuration, including the fields that you modified and those that you didn't.
delete_origin_request_policydeleteid, regionIf-MatchDeletes 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. To get the identifier, you can use ListOriginRequestPolicies or GetOriginRequestPolicy.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
idstringThe unique identifier for the origin request policy that you are deleting. To get the identifier, you can use ListOriginRequestPolicies.
regionstringAWS region (default: us-east-1)
If-MatchstringThe version of the origin request policy that you are deleting. The version is the origin request policy's ETag value, which you can get using ListOriginRequestPolicies, GetOriginRequestPolicy, or GetOriginRequestPolicyConfig.
MarkerstringUse this field when paginating results to indicate where to begin in your list of origin request policies. The response includes origin request policies in the list that occur after the marker. To get the next page of the list, set this field's value to the value of NextMarker from the current page's response.
MaxItemsstringThe maximum number of origin request policies that you want in the response.
TypestringA filter to return only the specified kinds of origin request policies. Valid values are: managed – Returns only the managed policies created by Amazon Web Services. custom – Returns only the custom policies created in your Amazon Web Services account.

SELECT examples

Gets an origin request policy, including the following metadata: The policy's identifier. The date and time when the policy was last modified. To get an origin request policy, you must provide the policy's identifier. If the origin request policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the origin request policy is not attached to a cache behavior, you can get the identifier using ListOriginRequestPolicies.

SELECT
id,
last_modified_time,
origin_request_policy_config
FROM aws.cloudfront.origin_request_policies
WHERE id = '{{ id }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Creates an origin request policy. After you create an origin request policy, you can attach it to one or more cache behaviors. When it's attached to a cache behavior, the origin request policy determines the values that CloudFront includes in requests that it sends to the origin. Each request that CloudFront sends to the origin 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.

INSERT INTO aws.cloudfront.origin_request_policies (
OriginRequestPolicyConfig,
region
)
SELECT
'{{ OriginRequestPolicyConfig }}' /* required */,
'{{ region }}'
RETURNING
id,
last_modified_time,
origin_request_policy_config
;

UPDATE examples

Updates an origin request policy configuration. When you update an origin request policy configuration, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update an origin request policy configuration: Use GetOriginRequestPolicyConfig to get the current configuration. Locally modify the fields in the origin request policy configuration that you want to update. Call UpdateOriginRequestPolicy by providing the entire origin request policy configuration, including the fields that you modified and those that you didn't.

UPDATE aws.cloudfront.origin_request_policies
SET
OriginRequestPolicyConfig = '{{ OriginRequestPolicyConfig }}'
WHERE
id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND OriginRequestPolicyConfig = '{{ OriginRequestPolicyConfig }}' --required
AND `If-Match` = '{{ If-Match}}'
RETURNING
id,
last_modified_time,
origin_request_policy_config;

DELETE examples

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. To get the identifier, you can use ListOriginRequestPolicies or GetOriginRequestPolicy.

DELETE FROM aws.cloudfront.origin_request_policies
WHERE id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND `If-Match` = '{{ If-Match }}'
;