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.
Parameters:
-
response_headers_policy_config
(ResponseHeadersPolicyConfig)
–
Contains metadata about the response headers policy, and a set of configurations that specify the HTTP headers.
Raises:
Source code in docs_src/capo_cloudfront/_services/cloud_front.py
| def create_response_headers_policy(
self,
response_headers_policy_config: "capo_cloudfront.types.response_headers_policy_config.ResponseHeadersPolicyConfig",
*,
config_overrides: Optional[CloudFrontClientConfig] = None,
) -> "capo_cloudfront.types.create_response_headers_policy_result.CreateResponseHeadersPolicyResult":
"""<p>Creates a response headers policy.</p> <p>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.</p> <p>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.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/modifying-response-headers.html">Adding or removing HTTP headers in CloudFront responses</a> in the <i>Amazon CloudFront Developer Guide</i>.</p>
Args:
response_headers_policy_config: <p>Contains metadata about the response headers policy, and a set of configurations that specify the HTTP headers.</p>
Raises:
capo_cloudfront.errors.access_denied.AccessDenied: <p>Access denied.</p>
capo_cloudfront.errors.inconsistent_quantities.InconsistentQuantities: <p>The value of <code>Quantity</code> and the size of <code>Items</code> don't match.</p>
capo_cloudfront.errors.invalid_argument.InvalidArgument: <p>An argument is invalid.</p>
capo_cloudfront.errors.response_headers_policy_already_exists.ResponseHeadersPolicyAlreadyExists: <p>A response headers policy with this name already exists. You must provide a unique name. To modify an existing response headers policy, use <code>UpdateResponseHeadersPolicy</code>.</p>
capo_cloudfront.errors.too_long_csp_in_response_headers_policy.TooLongCSPInResponseHeadersPolicy: <p>The length of the <code>Content-Security-Policy</code> header value in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
capo_cloudfront.errors.too_many_custom_headers_in_response_headers_policy.TooManyCustomHeadersInResponseHeadersPolicy: <p>The number of custom headers in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
capo_cloudfront.errors.too_many_remove_headers_in_response_headers_policy.TooManyRemoveHeadersInResponseHeadersPolicy: <p>The number of headers in <code>RemoveHeadersConfig</code> in the response headers policy exceeds the maximum.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
capo_cloudfront.errors.too_many_response_headers_policies.TooManyResponseHeadersPolicies: <p>You have reached the maximum number of response headers policies for this Amazon Web Services account.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html">Quotas</a> (formerly known as limits) in the <i>Amazon CloudFront Developer Guide</i>.</p>
capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudfront.types.create_response_headers_policy_request.CreateResponseHeadersPolicyRequest]",
) -> OperationResponse[
"capo_cloudfront.types.create_response_headers_policy_result.CreateResponseHeadersPolicyResult"
]:
import capo_cloudfront._operations.cloudfront2020_05_31.create_response_headers_policy
output, http_response = (
capo_cloudfront._operations.cloudfront2020_05_31.create_response_headers_policy.create_response_headers_policy(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateResponseHeadersPolicy")
)
input_: capo_cloudfront.types.create_response_headers_policy_request.CreateResponseHeadersPolicyRequest = {
"response_headers_policy_config": response_headers_policy_config
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|