- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
UpdateResponseHeadersPolicyCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CloudFrontClient, UpdateResponseHeadersPolicyCommand } from "@aws-sdk/client-cloudfront"; // ES Modules import
// const { CloudFrontClient, UpdateResponseHeadersPolicyCommand } = require("@aws-sdk/client-cloudfront"); // CommonJS import
const client = new CloudFrontClient(config);
const input = { // UpdateResponseHeadersPolicyRequest
ResponseHeadersPolicyConfig: { // ResponseHeadersPolicyConfig
Comment: "STRING_VALUE",
Name: "STRING_VALUE", // required
CorsConfig: { // ResponseHeadersPolicyCorsConfig
AccessControlAllowOrigins: { // ResponseHeadersPolicyAccessControlAllowOrigins
Quantity: Number("int"), // required
Items: [ // AccessControlAllowOriginsList // required
"STRING_VALUE",
],
},
AccessControlAllowHeaders: { // ResponseHeadersPolicyAccessControlAllowHeaders
Quantity: Number("int"), // required
Items: [ // AccessControlAllowHeadersList // required
"STRING_VALUE",
],
},
AccessControlAllowMethods: { // ResponseHeadersPolicyAccessControlAllowMethods
Quantity: Number("int"), // required
Items: [ // AccessControlAllowMethodsList // required
"GET" || "POST" || "OPTIONS" || "PUT" || "DELETE" || "PATCH" || "HEAD" || "ALL",
],
},
AccessControlAllowCredentials: true || false, // required
AccessControlExposeHeaders: { // ResponseHeadersPolicyAccessControlExposeHeaders
Quantity: Number("int"), // required
Items: [ // AccessControlExposeHeadersList
"STRING_VALUE",
],
},
AccessControlMaxAgeSec: Number("int"),
OriginOverride: true || false, // required
},
SecurityHeadersConfig: { // ResponseHeadersPolicySecurityHeadersConfig
XSSProtection: { // ResponseHeadersPolicyXSSProtection
Override: true || false, // required
Protection: true || false, // required
ModeBlock: true || false,
ReportUri: "STRING_VALUE",
},
FrameOptions: { // ResponseHeadersPolicyFrameOptions
Override: true || false, // required
FrameOption: "DENY" || "SAMEORIGIN", // required
},
ReferrerPolicy: { // ResponseHeadersPolicyReferrerPolicy
Override: true || false, // required
ReferrerPolicy: "no-referrer" || "no-referrer-when-downgrade" || "origin" || "origin-when-cross-origin" || "same-origin" || "strict-origin" || "strict-origin-when-cross-origin" || "unsafe-url", // required
},
ContentSecurityPolicy: { // ResponseHeadersPolicyContentSecurityPolicy
Override: true || false, // required
ContentSecurityPolicy: "STRING_VALUE", // required
},
ContentTypeOptions: { // ResponseHeadersPolicyContentTypeOptions
Override: true || false, // required
},
StrictTransportSecurity: { // ResponseHeadersPolicyStrictTransportSecurity
Override: true || false, // required
IncludeSubdomains: true || false,
Preload: true || false,
AccessControlMaxAgeSec: Number("int"), // required
},
},
ServerTimingHeadersConfig: { // ResponseHeadersPolicyServerTimingHeadersConfig
Enabled: true || false, // required
SamplingRate: Number("double"),
},
CustomHeadersConfig: { // ResponseHeadersPolicyCustomHeadersConfig
Quantity: Number("int"), // required
Items: [ // ResponseHeadersPolicyCustomHeaderList
{ // ResponseHeadersPolicyCustomHeader
Header: "STRING_VALUE", // required
Value: "STRING_VALUE", // required
Override: true || false, // required
},
],
},
RemoveHeadersConfig: { // ResponseHeadersPolicyRemoveHeadersConfig
Quantity: Number("int"), // required
Items: [ // ResponseHeadersPolicyRemoveHeaderList
{ // ResponseHeadersPolicyRemoveHeader
Header: "STRING_VALUE", // required
},
],
},
},
Id: "STRING_VALUE", // required
IfMatch: "STRING_VALUE",
};
const command = new UpdateResponseHeadersPolicyCommand(input);
const response = await client.send(command);
// { // UpdateResponseHeadersPolicyResult
// ResponseHeadersPolicy: { // ResponseHeadersPolicy
// Id: "STRING_VALUE", // required
// LastModifiedTime: new Date("TIMESTAMP"), // required
// ResponseHeadersPolicyConfig: { // ResponseHeadersPolicyConfig
// Comment: "STRING_VALUE",
// Name: "STRING_VALUE", // required
// CorsConfig: { // ResponseHeadersPolicyCorsConfig
// AccessControlAllowOrigins: { // ResponseHeadersPolicyAccessControlAllowOrigins
// Quantity: Number("int"), // required
// Items: [ // AccessControlAllowOriginsList // required
// "STRING_VALUE",
// ],
// },
// AccessControlAllowHeaders: { // ResponseHeadersPolicyAccessControlAllowHeaders
// Quantity: Number("int"), // required
// Items: [ // AccessControlAllowHeadersList // required
// "STRING_VALUE",
// ],
// },
// AccessControlAllowMethods: { // ResponseHeadersPolicyAccessControlAllowMethods
// Quantity: Number("int"), // required
// Items: [ // AccessControlAllowMethodsList // required
// "GET" || "POST" || "OPTIONS" || "PUT" || "DELETE" || "PATCH" || "HEAD" || "ALL",
// ],
// },
// AccessControlAllowCredentials: true || false, // required
// AccessControlExposeHeaders: { // ResponseHeadersPolicyAccessControlExposeHeaders
// Quantity: Number("int"), // required
// Items: [ // AccessControlExposeHeadersList
// "STRING_VALUE",
// ],
// },
// AccessControlMaxAgeSec: Number("int"),
// OriginOverride: true || false, // required
// },
// SecurityHeadersConfig: { // ResponseHeadersPolicySecurityHeadersConfig
// XSSProtection: { // ResponseHeadersPolicyXSSProtection
// Override: true || false, // required
// Protection: true || false, // required
// ModeBlock: true || false,
// ReportUri: "STRING_VALUE",
// },
// FrameOptions: { // ResponseHeadersPolicyFrameOptions
// Override: true || false, // required
// FrameOption: "DENY" || "SAMEORIGIN", // required
// },
// ReferrerPolicy: { // ResponseHeadersPolicyReferrerPolicy
// Override: true || false, // required
// ReferrerPolicy: "no-referrer" || "no-referrer-when-downgrade" || "origin" || "origin-when-cross-origin" || "same-origin" || "strict-origin" || "strict-origin-when-cross-origin" || "unsafe-url", // required
// },
// ContentSecurityPolicy: { // ResponseHeadersPolicyContentSecurityPolicy
// Override: true || false, // required
// ContentSecurityPolicy: "STRING_VALUE", // required
// },
// ContentTypeOptions: { // ResponseHeadersPolicyContentTypeOptions
// Override: true || false, // required
// },
// StrictTransportSecurity: { // ResponseHeadersPolicyStrictTransportSecurity
// Override: true || false, // required
// IncludeSubdomains: true || false,
// Preload: true || false,
// AccessControlMaxAgeSec: Number("int"), // required
// },
// },
// ServerTimingHeadersConfig: { // ResponseHeadersPolicyServerTimingHeadersConfig
// Enabled: true || false, // required
// SamplingRate: Number("double"),
// },
// CustomHeadersConfig: { // ResponseHeadersPolicyCustomHeadersConfig
// Quantity: Number("int"), // required
// Items: [ // ResponseHeadersPolicyCustomHeaderList
// { // ResponseHeadersPolicyCustomHeader
// Header: "STRING_VALUE", // required
// Value: "STRING_VALUE", // required
// Override: true || false, // required
// },
// ],
// },
// RemoveHeadersConfig: { // ResponseHeadersPolicyRemoveHeadersConfig
// Quantity: Number("int"), // required
// Items: [ // ResponseHeadersPolicyRemoveHeaderList
// { // ResponseHeadersPolicyRemoveHeader
// Header: "STRING_VALUE", // required
// },
// ],
// },
// },
// },
// ETag: "STRING_VALUE",
// };
UpdateResponseHeadersPolicyCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Id Required | string | undefined | The identifier for the response headers policy that you are updating. |
ResponseHeadersPolicyConfig Required | ResponseHeadersPolicyConfig | undefined | A response headers policy configuration. |
IfMatch | string | undefined | The version of the response headers policy that you are updating. The version is returned in the cache policy's |
UpdateResponseHeadersPolicyCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
ETag | string | undefined | The current version of the response headers policy. |
ResponseHeadersPolicy | ResponseHeadersPolicy | undefined | A response headers policy. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDenied | client | Access denied. |
IllegalUpdate | client | The update contains modifications that are not allowed. |
InconsistentQuantities | client | The value of |
InvalidArgument | client | An argument is invalid. |
InvalidIfMatchVersion | client | The |
NoSuchResponseHeadersPolicy | client | The response headers policy does not exist. |
PreconditionFailed | client | The precondition in one or more of the request fields evaluated to |
ResponseHeadersPolicyAlreadyExists | client | A response headers policy with this name already exists. You must provide a unique name. To modify an existing response headers policy, use |
TooLongCSPInResponseHeadersPolicy | client | The length of the For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide. |
TooManyCustomHeadersInResponseHeadersPolicy | client | The number of custom headers in the response headers policy exceeds the maximum. For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide. |
TooManyRemoveHeadersInResponseHeadersPolicy | client | The number of headers in For more information, see Quotas (formerly known as limits) in the Amazon CloudFront Developer Guide. |
CloudFrontServiceException | Base exception class for all service exceptions from CloudFront service. |