@Generated(value="jsii-pacmak/1.50.0 (build d1830a4)", date="2022-01-11T17:58:48.846Z") @Stability(value=Stable) public class ResponseHeadersPolicy extends Resource implements IResponseHeadersPolicy
Example:
// Using an existing managed response headers policy
S3Origin bucketOrigin;
Distribution.Builder.create(this, "myDistManagedPolicy")
.defaultBehavior(BehaviorOptions.builder()
.origin(bucketOrigin)
.responseHeadersPolicy(ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS)
.build())
.build();
// Creating a custom response headers policy -- all parameters optional
ResponseHeadersPolicy myResponseHeadersPolicy = ResponseHeadersPolicy.Builder.create(this, "ResponseHeadersPolicy")
.responseHeadersPolicyName("MyPolicy")
.comment("A default policy")
.corsBehavior(ResponseHeadersCorsBehavior.builder()
.accessControlAllowCredentials(false)
.accessControlAllowHeaders(List.of("X-Custom-Header-1", "X-Custom-Header-2"))
.accessControlAllowMethods(List.of("GET", "POST"))
.accessControlAllowOrigins(List.of("*"))
.accessControlExposeHeaders(List.of("X-Custom-Header-1", "X-Custom-Header-2"))
.accessControlMaxAge(Duration.seconds(600))
.originOverride(true)
.build())
.customHeadersBehavior(ResponseCustomHeadersBehavior.builder()
.customHeaders(List.of(ResponseCustomHeader.builder().header("X-Amz-Date").value("some-value").override(true).build(), ResponseCustomHeader.builder().header("X-Amz-Security-Token").value("some-value").override(false).build()))
.build())
.securityHeadersBehavior(ResponseSecurityHeadersBehavior.builder()
.contentSecurityPolicy(ResponseHeadersContentSecurityPolicy.builder().contentSecurityPolicy("default-src https:;").override(true).build())
.contentTypeOptions(ResponseHeadersContentTypeOptions.builder().override(true).build())
.frameOptions(ResponseHeadersFrameOptions.builder().frameOption(HeadersFrameOption.DENY).override(true).build())
.referrerPolicy(ResponseHeadersReferrerPolicy.builder().referrerPolicy(HeadersReferrerPolicy.NO_REFERRER).override(true).build())
.strictTransportSecurity(ResponseHeadersStrictTransportSecurity.builder().accessControlMaxAge(Duration.seconds(600)).includeSubdomains(true).override(true).build())
.xssProtection(ResponseHeadersXSSProtection.builder().protection(true).modeBlock(true).reportUri("https://example.com/csp-report").override(true).build())
.build())
.build();
Distribution.Builder.create(this, "myDistCustomPolicy")
.defaultBehavior(BehaviorOptions.builder()
.origin(bucketOrigin)
.responseHeadersPolicy(myResponseHeadersPolicy)
.build())
.build();
| Modifier and Type | Class and Description |
|---|---|
static class |
ResponseHeadersPolicy.Builder
A fluent builder for
ResponseHeadersPolicy. |
software.amazon.jsii.JsiiObject.InitializationModeIResponseHeadersPolicy.Jsii$Default, IResponseHeadersPolicy.Jsii$ProxyIResource.Jsii$Default| Modifier and Type | Field and Description |
|---|---|
static IResponseHeadersPolicy |
CORS_ALLOW_ALL_ORIGINS
Use this managed policy to allow simple CORS requests from any origin.
|
static IResponseHeadersPolicy |
CORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERS
Use this managed policy to allow simple CORS requests from any origin and add a set of security headers to all responses that CloudFront sends to viewers.
|
static IResponseHeadersPolicy |
CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT
Use this managed policy to allow CORS requests from any origin, including preflight requests.
|
static IResponseHeadersPolicy |
CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS
Use this managed policy to allow CORS requests from any origin, including preflight requests, and add a set of security headers to all responses that CloudFront sends to viewers.
|
static IResponseHeadersPolicy |
SECURITY_HEADERS
Use this managed policy to add a set of security headers to all responses that CloudFront sends to viewers.
|
| Modifier | Constructor and Description |
|---|---|
|
ResponseHeadersPolicy(software.constructs.Construct scope,
String id) |
|
ResponseHeadersPolicy(software.constructs.Construct scope,
String id,
ResponseHeadersPolicyProps props) |
protected |
ResponseHeadersPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
ResponseHeadersPolicy(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
static IResponseHeadersPolicy |
fromResponseHeadersPolicyId(software.constructs.Construct scope,
String id,
String responseHeadersPolicyId)
Import an existing Response Headers Policy from its ID.
|
String |
getResponseHeadersPolicyId()
The ID of the response headers policy.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourcegetNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validatejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetNode@Stability(value=Stable) public static final IResponseHeadersPolicy CORS_ALLOW_ALL_ORIGINS
@Stability(value=Stable) public static final IResponseHeadersPolicy CORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERS
@Stability(value=Stable) public static final IResponseHeadersPolicy CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT
@Stability(value=Stable) public static final IResponseHeadersPolicy CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS
@Stability(value=Stable) public static final IResponseHeadersPolicy SECURITY_HEADERS
protected ResponseHeadersPolicy(software.amazon.jsii.JsiiObjectRef objRef)
protected ResponseHeadersPolicy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public ResponseHeadersPolicy(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@Nullable
ResponseHeadersPolicyProps props)
scope - This parameter is required.id - This parameter is required.props - @Stability(value=Stable)
public ResponseHeadersPolicy(@NotNull
software.constructs.Construct scope,
@NotNull
String id)
scope - This parameter is required.id - This parameter is required.@Stability(value=Stable) @NotNull public static IResponseHeadersPolicy fromResponseHeadersPolicyId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String responseHeadersPolicyId)
scope - This parameter is required.id - This parameter is required.responseHeadersPolicyId - This parameter is required.@Stability(value=Stable) @NotNull public String getResponseHeadersPolicyId()
getResponseHeadersPolicyId in interface IResponseHeadersPolicyCopyright © 2022. All rights reserved.