Skip to main content

response_headers_policies

Creates, updates, deletes, gets or lists a response_headers_policies resource.

Overview

Nameresponse_headers_policies
TypeResource
Idaws.cloudfront.response_headers_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier for the response headers policy.
last_modified_timestringThe date and time when the response headers policy was last modified.
response_headers_policy_configstringA response headers policy configuration.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_response_headers_policyselectid, regionGets a response headers policy, including metadata (the policy's identifier and the date and time when the policy was last modified). To get a response headers policy, you must provide the policy's identifier. If the response headers policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the response headers policy is not attached to a cache behavior, you can get the identifier using ListResponseHeadersPolicies.
list_response_headers_policiesselectregionType, Marker, MaxItemsGets a list of response headers policies. You can optionally apply a filter to get 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_response_headers_policyinsertregion, ResponseHeadersPolicyConfigCreates a response headers policy. A response headers policy contains information about a set of HTTP headers. To create a response headers policy, you provide some metadata about the policy and a set of configurations that specify the headers. After you create a response headers policy, you can use its ID to attach it to one or more cache behaviors in a CloudFront distribution. When it's attached to a cache behavior, the response headers policy affects the HTTP headers that CloudFront includes in HTTP responses to requests that match the cache behavior. CloudFront adds or removes response headers according to the configuration of the response headers policy. For more information, see Adding or removing HTTP headers in CloudFront responses in the Amazon CloudFront Developer Guide.
update_response_headers_policyupdateid, region, ResponseHeadersPolicyConfigIf-MatchUpdates a response headers policy. When you update a response headers policy, the entire policy is replaced. You cannot update some policy fields independent of others. To update a response headers policy configuration: Use GetResponseHeadersPolicyConfig to get the current policy's configuration. Modify the fields in the response headers policy configuration that you want to update. Call UpdateResponseHeadersPolicy, providing the entire response headers policy configuration, including the fields that you modified and those that you didn't.
delete_response_headers_policydeleteid, regionIf-MatchDeletes a response headers policy. You cannot delete a response headers policy if it's attached to a cache behavior. First update your distributions to remove the response headers policy from all cache behaviors, then delete the response headers policy. To delete a response headers policy, you must provide the policy's identifier and version. To get these values, you can use ListResponseHeadersPolicies or GetResponseHeadersPolicy.

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 identifier for the response headers policy that you are deleting. To get the identifier, you can use ListResponseHeadersPolicies.
regionstringAWS region (default: us-east-1)
If-MatchstringThe version of the response headers policy that you are deleting. The version is the response headers policy's ETag value, which you can get using ListResponseHeadersPolicies, GetResponseHeadersPolicy, or GetResponseHeadersPolicyConfig.
MarkerstringUse this field when paginating results to indicate where to begin in your list of response headers policies. The response includes response headers 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 response headers policies that you want to get in the response.
TypestringA filter to get only the specified kind of response headers policies. Valid values are: managed – Gets only the managed policies created by Amazon Web Services. custom – Gets only the custom policies created in your Amazon Web Services account.

SELECT examples

Gets a response headers policy, including metadata (the policy's identifier and the date and time when the policy was last modified). To get a response headers policy, you must provide the policy's identifier. If the response headers policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the response headers policy is not attached to a cache behavior, you can get the identifier using ListResponseHeadersPolicies.

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

INSERT examples

Creates a response headers policy. A response headers policy contains information about a set of HTTP headers. To create a response headers policy, you provide some metadata about the policy and a set of configurations that specify the headers. After you create a response headers policy, you can use its ID to attach it to one or more cache behaviors in a CloudFront distribution. When it's attached to a cache behavior, the response headers policy affects the HTTP headers that CloudFront includes in HTTP responses to requests that match the cache behavior. CloudFront adds or removes response headers according to the configuration of the response headers policy. For more information, see Adding or removing HTTP headers in CloudFront responses in the Amazon CloudFront Developer Guide.

INSERT INTO aws.cloudfront.response_headers_policies (
ResponseHeadersPolicyConfig,
region
)
SELECT
'{{ ResponseHeadersPolicyConfig }}' /* required */,
'{{ region }}'
RETURNING
id,
last_modified_time,
response_headers_policy_config
;

UPDATE examples

Updates a response headers policy. When you update a response headers policy, the entire policy is replaced. You cannot update some policy fields independent of others. To update a response headers policy configuration: Use GetResponseHeadersPolicyConfig to get the current policy's configuration. Modify the fields in the response headers policy configuration that you want to update. Call UpdateResponseHeadersPolicy, providing the entire response headers policy configuration, including the fields that you modified and those that you didn't.

UPDATE aws.cloudfront.response_headers_policies
SET
ResponseHeadersPolicyConfig = '{{ ResponseHeadersPolicyConfig }}'
WHERE
id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND ResponseHeadersPolicyConfig = '{{ ResponseHeadersPolicyConfig }}' --required
AND `If-Match` = '{{ If-Match}}'
RETURNING
id,
last_modified_time,
response_headers_policy_config;

DELETE examples

Deletes a response headers policy. You cannot delete a response headers policy if it's attached to a cache behavior. First update your distributions to remove the response headers policy from all cache behaviors, then delete the response headers policy. To delete a response headers policy, you must provide the policy's identifier and version. To get these values, you can use ListResponseHeadersPolicies or GetResponseHeadersPolicy.

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