Skip to content
v2.273.0

ResponseHeadersPolicy L2 construct ​

A Response Headers Policy configuration.

Example ​

ts
// Using an existing managed response headers policy
declare const bucketOrigin: origins.S3Origin;
new cloudfront.Distribution(this, 'myDistManagedPolicy', {
  defaultBehavior: {
    origin: bucketOrigin,
    responseHeadersPolicy: cloudfront.ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS,
  },
});

// Creating a custom response headers policy -- all parameters optional
const myResponseHeadersPolicy = new cloudfront.ResponseHeadersPolicy(this, 'ResponseHeadersPolicy', {
  responseHeadersPolicyName: 'MyPolicy',
  comment: 'A default policy',
  corsBehavior: {
    accessControlAllowCredentials: false,
    accessControlAllowHeaders: ['X-Custom-Header-1', 'X-Custom-Header-2'],
    accessControlAllowMethods: ['GET', 'POST'],
    accessControlAllowOrigins: ['*'],
    accessControlExposeHeaders: ['X-Custom-Header-1', 'X-Custom-Header-2'],
    accessControlMaxAge: Duration.seconds(600),
    originOverride: true,
  },
  customHeadersBehavior: {
    customHeaders: [
      { header: 'X-Amz-Date', value: 'some-value', override: true },
      { header: 'X-Amz-Security-Token', value: 'some-value', override: false },
    ],
  },
  securityHeadersBehavior: {
    contentSecurityPolicy: { contentSecurityPolicy: 'default-src https:;', override: true },
    contentTypeOptions: { override: true },
    frameOptions: { frameOption: cloudfront.HeadersFrameOption.DENY, override: true },
    referrerPolicy: { referrerPolicy: cloudfront.HeadersReferrerPolicy.NO_REFERRER, override: true },
    strictTransportSecurity: { accessControlMaxAge: Duration.seconds(600), includeSubdomains: true, override: true },
    xssProtection: { protection: true, modeBlock: false, reportUri: 'https://example.com/csp-report', override: true },
  },
  removeHeaders: ['Server'],
  serverTimingSamplingRate: 50,
});
new cloudfront.Distribution(this, 'myDistCustomPolicy', {
  defaultBehavior: {
    origin: bucketOrigin,
    responseHeadersPolicy: myResponseHeadersPolicy,
  },
});
python
# Using an existing managed response headers policy
# bucket_origin: origins.S3Origin

cloudfront.Distribution(self, "myDistManagedPolicy",
    default_behavior=cloudfront.BehaviorOptions(
        origin=bucket_origin,
        response_headers_policy=cloudfront.ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS
    )
)

# Creating a custom response headers policy -- all parameters optional
my_response_headers_policy = cloudfront.ResponseHeadersPolicy(self, "ResponseHeadersPolicy",
    response_headers_policy_name="MyPolicy",
    comment="A default policy",
    cors_behavior=cloudfront.ResponseHeadersCorsBehavior(
        access_control_allow_credentials=False,
        access_control_allow_headers=["X-Custom-Header-1", "X-Custom-Header-2"],
        access_control_allow_methods=["GET", "POST"],
        access_control_allow_origins=["*"],
        access_control_expose_headers=["X-Custom-Header-1", "X-Custom-Header-2"],
        access_control_max_age=Duration.seconds(600),
        origin_override=True
    ),
    custom_headers_behavior=cloudfront.ResponseCustomHeadersBehavior(
        custom_headers=[cloudfront.ResponseCustomHeader(header="X-Amz-Date", value="some-value", override=True), cloudfront.ResponseCustomHeader(header="X-Amz-Security-Token", value="some-value", override=False)
        ]
    ),
    security_headers_behavior=cloudfront.ResponseSecurityHeadersBehavior(
        content_security_policy=cloudfront.ResponseHeadersContentSecurityPolicy(content_security_policy="default-src https:;", override=True),
        content_type_options=cloudfront.ResponseHeadersContentTypeOptions(override=True),
        frame_options=cloudfront.ResponseHeadersFrameOptions(frame_option=cloudfront.HeadersFrameOption.DENY, override=True),
        referrer_policy=cloudfront.ResponseHeadersReferrerPolicy(referrer_policy=cloudfront.HeadersReferrerPolicy.NO_REFERRER, override=True),
        strict_transport_security=cloudfront.ResponseHeadersStrictTransportSecurity(access_control_max_age=Duration.seconds(600), include_subdomains=True, override=True),
        xss_protection=cloudfront.ResponseHeadersXSSProtection(protection=True, mode_block=False, report_uri="https://example.com/csp-report", override=True)
    ),
    remove_headers=["Server"],
    server_timing_sampling_rate=50
)
cloudfront.Distribution(self, "myDistCustomPolicy",
    default_behavior=cloudfront.BehaviorOptions(
        origin=bucket_origin,
        response_headers_policy=my_response_headers_policy
    )
)
java
// 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(false).reportUri("https://example.com/csp-report").override(true).build())
                .build())
        .removeHeaders(List.of("Server"))
        .serverTimingSamplingRate(50)
        .build();
Distribution.Builder.create(this, "myDistCustomPolicy")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(bucketOrigin)
                .responseHeadersPolicy(myResponseHeadersPolicy)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Using an existing managed response headers policy
S3Origin bucketOrigin;

new Distribution(this, "myDistManagedPolicy", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = bucketOrigin,
        ResponseHeadersPolicy = ResponseHeadersPolicy.CORS_ALLOW_ALL_ORIGINS
    }
});

// Creating a custom response headers policy -- all parameters optional
var myResponseHeadersPolicy = new ResponseHeadersPolicy(this, "ResponseHeadersPolicy", new ResponseHeadersPolicyProps {
    ResponseHeadersPolicyName = "MyPolicy",
    Comment = "A default policy",
    CorsBehavior = new ResponseHeadersCorsBehavior {
        AccessControlAllowCredentials = false,
        AccessControlAllowHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
        AccessControlAllowMethods = new [] { "GET", "POST" },
        AccessControlAllowOrigins = new [] { "*" },
        AccessControlExposeHeaders = new [] { "X-Custom-Header-1", "X-Custom-Header-2" },
        AccessControlMaxAge = Duration.Seconds(600),
        OriginOverride = true
    },
    CustomHeadersBehavior = new ResponseCustomHeadersBehavior {
        CustomHeaders = new [] { new ResponseCustomHeader { Header = "X-Amz-Date", Value = "some-value", Override = true }, new ResponseCustomHeader { Header = "X-Amz-Security-Token", Value = "some-value", Override = false } }
    },
    SecurityHeadersBehavior = new ResponseSecurityHeadersBehavior {
        ContentSecurityPolicy = new ResponseHeadersContentSecurityPolicy { ContentSecurityPolicy = "default-src https:;", Override = true },
        ContentTypeOptions = new ResponseHeadersContentTypeOptions { Override = true },
        FrameOptions = new ResponseHeadersFrameOptions { FrameOption = HeadersFrameOption.DENY, Override = true },
        ReferrerPolicy = new ResponseHeadersReferrerPolicy { ReferrerPolicy = HeadersReferrerPolicy.NO_REFERRER, Override = true },
        StrictTransportSecurity = new ResponseHeadersStrictTransportSecurity { AccessControlMaxAge = Duration.Seconds(600), IncludeSubdomains = true, Override = true },
        XssProtection = new ResponseHeadersXSSProtection { Protection = true, ModeBlock = false, ReportUri = "https://example.com/csp-report", Override = true }
    },
    RemoveHeaders = new [] { "Server" },
    ServerTimingSamplingRate = 50
});
new Distribution(this, "myDistCustomPolicy", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = bucketOrigin,
        ResponseHeadersPolicy = myResponseHeadersPolicy
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Using an existing managed response headers policy
var bucketOrigin S3Origin

cloudfront.NewDistribution(this, jsii.String("myDistManagedPolicy"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: bucketOrigin,
		ResponseHeadersPolicy: cloudfront.ResponseHeadersPolicy_CORS_ALLOW_ALL_ORIGINS(),
	},
})

// Creating a custom response headers policy -- all parameters optional
myResponseHeadersPolicy := cloudfront.NewResponseHeadersPolicy(this, jsii.String("ResponseHeadersPolicy"), &ResponseHeadersPolicyProps{
	ResponseHeadersPolicyName: jsii.String("MyPolicy"),
	Comment: jsii.String("A default policy"),
	CorsBehavior: &ResponseHeadersCorsBehavior{
		AccessControlAllowCredentials: jsii.Boolean(false),
		AccessControlAllowHeaders: []*string{
			jsii.String("X-Custom-Header-1"),
			jsii.String("X-Custom-Header-2"),
		},
		AccessControlAllowMethods: []*string{
			jsii.String("GET"),
			jsii.String("POST"),
		},
		AccessControlAllowOrigins: []*string{
			jsii.String("*"),
		},
		AccessControlExposeHeaders: []*string{
			jsii.String("X-Custom-Header-1"),
			jsii.String("X-Custom-Header-2"),
		},
		AccessControlMaxAge: awscdk.Duration_Seconds(jsii.Number(600)),
		OriginOverride: jsii.Boolean(true),
	},
	CustomHeadersBehavior: &ResponseCustomHeadersBehavior{
		CustomHeaders: []ResponseCustomHeader{
			&ResponseCustomHeader{
				Header: jsii.String("X-Amz-Date"),
				Value: jsii.String("some-value"),
				Override: jsii.Boolean(true),
			},
			&ResponseCustomHeader{
				Header: jsii.String("X-Amz-Security-Token"),
				Value: jsii.String("some-value"),
				Override: jsii.Boolean(false),
			},
		},
	},
	SecurityHeadersBehavior: &ResponseSecurityHeadersBehavior{
		ContentSecurityPolicy: &ResponseHeadersContentSecurityPolicy{
			ContentSecurityPolicy: jsii.String("default-src https:;"),
			Override: jsii.Boolean(true),
		},
		ContentTypeOptions: &ResponseHeadersContentTypeOptions{
			Override: jsii.Boolean(true),
		},
		FrameOptions: &ResponseHeadersFrameOptions{
			FrameOption: cloudfront.HeadersFrameOption_DENY,
			Override: jsii.Boolean(true),
		},
		ReferrerPolicy: &ResponseHeadersReferrerPolicy{
			ReferrerPolicy: cloudfront.HeadersReferrerPolicy_NO_REFERRER,
			Override: jsii.Boolean(true),
		},
		StrictTransportSecurity: &ResponseHeadersStrictTransportSecurity{
			AccessControlMaxAge: awscdk.Duration_*Seconds(jsii.Number(600)),
			IncludeSubdomains: jsii.Boolean(true),
			Override: jsii.Boolean(true),
		},
		XssProtection: &ResponseHeadersXSSProtection{
			Protection: jsii.Boolean(true),
			ModeBlock: jsii.Boolean(false),
			ReportUri: jsii.String("https://example.com/csp-report"),
			Override: jsii.Boolean(true),
		},
	},
	RemoveHeaders: []*string{
		jsii.String("Server"),
	},
	ServerTimingSamplingRate: jsii.Number(50),
})
cloudfront.NewDistribution(this, jsii.String("myDistCustomPolicy"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: bucketOrigin,
		ResponseHeadersPolicy: myResponseHeadersPolicy,
	},
})

Initializer ​

ts
new ResponseHeadersPolicy(scope: Construct, id: string, props?: ResponseHeadersPolicyProps)
python
ResponseHeadersPolicy(scope: Construct, id: str, props: typing.Optional[ResponseHeadersPolicyProps] = None)
java
new ResponseHeadersPolicy(Construct scope, String id, ResponseHeadersPolicyProps props)
csharp
new ResponseHeadersPolicy(Construct scope, string id, ResponseHeadersPolicyProps? props = null)
go
NewResponseHeadersPolicy(Scope Construct, Id *string, Props ResponseHeadersPolicyProps)

Construct Props ​

commentstringcommentstrcommentStringCommentstringComment*string= no comment#
A comment to describe the response headers policy.
A configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS).
customHeadersBehaviorResponseCustomHeadersBehaviorcustom_headers_behaviorResponseCustomHeadersBehaviorcustomHeadersBehaviorResponseCustomHeadersBehaviorCustomHeadersBehaviorResponseCustomHeadersBehaviorCustomHeadersBehaviorResponseCustomHeadersBehavior= no custom headers behavior#
A configuration for a set of custom HTTP response headers.
removeHeadersstring[]remove_headerstyping.List[str]removeHeadersList<String>RemoveHeadersstring[]RemoveHeaders*[]*string= no headers are removed#
A list of HTTP response headers that CloudFront removes from HTTP responses that it sends to viewers.
responseHeadersPolicyNamestringresponse_headers_policy_namestrresponseHeadersPolicyNameStringResponseHeadersPolicyNamestringResponseHeadersPolicyName*string= generated from the `id`#
A unique name to identify the response headers policy.
securityHeadersBehaviorResponseSecurityHeadersBehaviorsecurity_headers_behaviorResponseSecurityHeadersBehaviorsecurityHeadersBehaviorResponseSecurityHeadersBehaviorSecurityHeadersBehaviorResponseSecurityHeadersBehaviorSecurityHeadersBehaviorResponseSecurityHeadersBehavior= no security headers behavior#
A configuration for a set of security-related HTTP response headers.
serverTimingSamplingRatenumberserver_timing_sampling_rateint | floatserverTimingSamplingRateNumberServerTimingSamplingRatedoubleServerTimingSamplingRate*float64= no Server-Timing header is added…#
The percentage of responses that you want CloudFront to add the Server-Timing header to.
default

Default: no Server-Timing header is added to HTTP responses

Properties ​

CORS_ALLOW_ALL_ORIGINSIResponseHeadersPolicycors_allow_all_originsIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINSIResponseHeadersPolicyrequiredstatic#
Use this managed policy to allow simple CORS requests from any origin.
CORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERSIResponseHeadersPolicycors_allow_all_origins_and_security_headersIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_AND_SECURITY_HEADERSIResponseHeadersPolicyrequiredstatic#
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.
CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHTIResponseHeadersPolicycors_allow_all_origins_with_preflightIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHTIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHTIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHTIResponseHeadersPolicyrequiredstatic#
Use this managed policy to allow CORS requests from any origin, including preflight requests.
CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERSIResponseHeadersPolicycors_allow_all_origins_with_preflight_and_security_headersIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERSIResponseHeadersPolicyCORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERSIResponseHeadersPolicyrequiredstatic#
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.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
responseHeadersPolicyIdstringresponse_headers_policy_idstrresponseHeadersPolicyIdStringResponseHeadersPolicyIdstringResponseHeadersPolicyId*stringrequired#
The ID of the response headers policy.
responseHeadersPolicyRefResponseHeadersPolicyReferenceresponse_headers_policy_refResponseHeadersPolicyReferenceresponseHeadersPolicyRefResponseHeadersPolicyReferenceResponseHeadersPolicyRefResponseHeadersPolicyReferenceResponseHeadersPolicyRefResponseHeadersPolicyReferencerequired#
A reference to a ResponseHeadersPolicy resource.
SECURITY_HEADERSIResponseHeadersPolicysecurity_headersIResponseHeadersPolicySECURITY_HEADERSIResponseHeadersPolicySECURITY_HEADERSIResponseHeadersPolicySECURITY_HEADERSIResponseHeadersPolicyrequiredstatic#
Use this managed policy to add a set of security headers to all responses that CloudFront sends to viewers.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromResponseHeadersPolicyId(scope: Construct, id: string, responseHeadersPolicyId: string): IResponseHeadersPolicy@staticmethod def from_response_headers_policy_id(scope: Construct, id: str, response_headers_policy_id: str) -> IResponseHeadersPolicypublic static IResponseHeadersPolicy fromResponseHeadersPolicyId(Construct scope, String id, String responseHeadersPolicyId)public static IResponseHeadersPolicy FromResponseHeadersPolicyId(Construct scope, string id, string responseHeadersPolicyId)func FromResponseHeadersPolicyId(Scope Construct, Id *string, ResponseHeadersPolicyId *string) IResponseHeadersPolicystatic#
Import an existing Response Headers Policy from its ID.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.