Class CfnResponseHeadersPolicy

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.CfnElement
software.amazon.awscdk.CfnRefElement
software.amazon.awscdk.CfnResource
software.amazon.awscdk.services.cloudfront.CfnResponseHeadersPolicy
All Implemented Interfaces:
IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-05T03:43:39.968Z") @Stability(Stable) public class CfnResponseHeadersPolicy extends CfnResource implements IInspectable
A response headers policy.

A response headers policy contains information about a set of HTTP response 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 .

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.cloudfront.*;
 CfnResponseHeadersPolicy cfnResponseHeadersPolicy = CfnResponseHeadersPolicy.Builder.create(this, "MyCfnResponseHeadersPolicy")
         .responseHeadersPolicyConfig(ResponseHeadersPolicyConfigProperty.builder()
                 .name("name")
                 // the properties below are optional
                 .comment("comment")
                 .corsConfig(CorsConfigProperty.builder()
                         .accessControlAllowCredentials(false)
                         .accessControlAllowHeaders(AccessControlAllowHeadersProperty.builder()
                                 .items(List.of("items"))
                                 .build())
                         .accessControlAllowMethods(AccessControlAllowMethodsProperty.builder()
                                 .items(List.of("items"))
                                 .build())
                         .accessControlAllowOrigins(AccessControlAllowOriginsProperty.builder()
                                 .items(List.of("items"))
                                 .build())
                         .originOverride(false)
                         // the properties below are optional
                         .accessControlExposeHeaders(AccessControlExposeHeadersProperty.builder()
                                 .items(List.of("items"))
                                 .build())
                         .accessControlMaxAgeSec(123)
                         .build())
                 .customHeadersConfig(CustomHeadersConfigProperty.builder()
                         .items(List.of(CustomHeaderProperty.builder()
                                 .header("header")
                                 .override(false)
                                 .value("value")
                                 .build()))
                         .build())
                 .removeHeadersConfig(RemoveHeadersConfigProperty.builder()
                         .items(List.of(RemoveHeaderProperty.builder()
                                 .header("header")
                                 .build()))
                         .build())
                 .securityHeadersConfig(SecurityHeadersConfigProperty.builder()
                         .contentSecurityPolicy(ContentSecurityPolicyProperty.builder()
                                 .contentSecurityPolicy("contentSecurityPolicy")
                                 .override(false)
                                 .build())
                         .contentTypeOptions(ContentTypeOptionsProperty.builder()
                                 .override(false)
                                 .build())
                         .frameOptions(FrameOptionsProperty.builder()
                                 .frameOption("frameOption")
                                 .override(false)
                                 .build())
                         .referrerPolicy(ReferrerPolicyProperty.builder()
                                 .override(false)
                                 .referrerPolicy("referrerPolicy")
                                 .build())
                         .strictTransportSecurity(StrictTransportSecurityProperty.builder()
                                 .accessControlMaxAgeSec(123)
                                 .override(false)
                                 // the properties below are optional
                                 .includeSubdomains(false)
                                 .preload(false)
                                 .build())
                         .xssProtection(XSSProtectionProperty.builder()
                                 .override(false)
                                 .protection(false)
                                 // the properties below are optional
                                 .modeBlock(false)
                                 .reportUri("reportUri")
                                 .build())
                         .build())
                 .serverTimingHeadersConfig(ServerTimingHeadersConfigProperty.builder()
                         .enabled(false)
                         // the properties below are optional
                         .samplingRate(123)
                         .build())
                 .build())
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnResponseHeadersPolicy

      protected CfnResponseHeadersPolicy(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnResponseHeadersPolicy

      protected CfnResponseHeadersPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnResponseHeadersPolicy

      @Stability(Stable) public CfnResponseHeadersPolicy(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnResponseHeadersPolicyProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrId

      @Stability(Stable) @NotNull public String getAttrId()
      The unique identifier for the response headers policy.

      For example: 57f99797-3b20-4e1b-a728-27972a74082a .

    • getAttrLastModifiedTime

      @Stability(Stable) @NotNull public String getAttrLastModifiedTime()
      The date and time when the response headers policy was last modified.
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getResponseHeadersPolicyConfig

      @Stability(Stable) @NotNull public Object getResponseHeadersPolicyConfig()
      A response headers policy configuration.
    • setResponseHeadersPolicyConfig

      @Stability(Stable) public void setResponseHeadersPolicyConfig(@NotNull IResolvable value)
      A response headers policy configuration.
    • setResponseHeadersPolicyConfig

      @Stability(Stable) public void setResponseHeadersPolicyConfig(@NotNull CfnResponseHeadersPolicy.ResponseHeadersPolicyConfigProperty value)
      A response headers policy configuration.