Show / Hide Table of Contents

Class Behavior

A CloudFront behavior wrapper.

Inheritance
object
Behavior
Implements
IBehavior
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Behavior : IBehavior
Syntax (vb)
Public Class Behavior Implements IBehavior
Remarks

ExampleMetadata: fixture=_generated

Examples
// The code below shows an example of how to instantiate this type.
            // The values are placeholders you should change.
            using Amazon.CDK;
            using Amazon.CDK.AWS.CloudFront;
            using Amazon.CDK.AWS.Lambda;
            using Amazon.CDK.Interfaces.CloudFront;

            IFunctionRef functionRef;
            IKeyGroupRef keyGroupRef;
            Version version;

            var behavior = new Behavior {
                AllowedMethods = CloudFrontAllowedMethods.GET_HEAD,
                CachedMethods = CloudFrontAllowedCachedMethods.GET_HEAD,
                Compress = false,
                DefaultTtl = Duration.Minutes(30),
                ForwardedValues = new ForwardedValuesProperty {
                    QueryString = false,

                    // the properties below are optional
                    Cookies = new CookiesProperty {
                        Forward = "forward",

                        // the properties below are optional
                        WhitelistedNames = new [] { "whitelistedNames" }
                    },
                    Headers = new [] { "headers" },
                    QueryStringCacheKeys = new [] { "queryStringCacheKeys" }
                },
                FunctionAssociations = new [] { new FunctionAssociation {
                    EventType = FunctionEventType.VIEWER_REQUEST,
                    Function = functionRef
                } },
                IsDefaultBehavior = false,
                LambdaFunctionAssociations = new [] { new LambdaFunctionAssociation {
                    EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
                    LambdaFunction = version,

                    // the properties below are optional
                    IncludeBody = false
                } },
                MaxTtl = Duration.Minutes(30),
                MinTtl = Duration.Minutes(30),
                PathPattern = "pathPattern",
                TrustedKeyGroups = new [] { keyGroupRef },
                TrustedSigners = new [] { "trustedSigners" },
                ViewerProtocolPolicy = ViewerProtocolPolicy.HTTPS_ONLY
            };

Synopsis

Constructors

Behavior()

A CloudFront behavior wrapper.

Properties

AllowedMethods

The method this CloudFront distribution responds do.

CachedMethods

Which methods are cached by CloudFront by default.

Compress

If CloudFront should automatically compress some content types.

DefaultTtl

The default amount of time CloudFront will cache an object.

ForwardedValues

The values CloudFront will forward to the origin when making a request.

FunctionAssociations

The CloudFront functions to invoke before serving the contents.

IsDefaultBehavior

If this behavior is the default behavior for the distribution.

LambdaFunctionAssociations

Declares associated lambda@edge functions for this distribution behaviour.

MaxTtl

The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

MinTtl

The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.

PathPattern

The path this behavior responds to.

TrustedKeyGroups

A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.

TrustedSigners

(deprecated) Trusted signers is how CloudFront allows you to serve private content.

ViewerProtocolPolicy

The viewer policy for this behavior.

Constructors

Behavior()

A CloudFront behavior wrapper.

public Behavior()
Remarks

ExampleMetadata: fixture=_generated

Examples
// The code below shows an example of how to instantiate this type.
            // The values are placeholders you should change.
            using Amazon.CDK;
            using Amazon.CDK.AWS.CloudFront;
            using Amazon.CDK.AWS.Lambda;
            using Amazon.CDK.Interfaces.CloudFront;

            IFunctionRef functionRef;
            IKeyGroupRef keyGroupRef;
            Version version;

            var behavior = new Behavior {
                AllowedMethods = CloudFrontAllowedMethods.GET_HEAD,
                CachedMethods = CloudFrontAllowedCachedMethods.GET_HEAD,
                Compress = false,
                DefaultTtl = Duration.Minutes(30),
                ForwardedValues = new ForwardedValuesProperty {
                    QueryString = false,

                    // the properties below are optional
                    Cookies = new CookiesProperty {
                        Forward = "forward",

                        // the properties below are optional
                        WhitelistedNames = new [] { "whitelistedNames" }
                    },
                    Headers = new [] { "headers" },
                    QueryStringCacheKeys = new [] { "queryStringCacheKeys" }
                },
                FunctionAssociations = new [] { new FunctionAssociation {
                    EventType = FunctionEventType.VIEWER_REQUEST,
                    Function = functionRef
                } },
                IsDefaultBehavior = false,
                LambdaFunctionAssociations = new [] { new LambdaFunctionAssociation {
                    EventType = LambdaEdgeEventType.ORIGIN_REQUEST,
                    LambdaFunction = version,

                    // the properties below are optional
                    IncludeBody = false
                } },
                MaxTtl = Duration.Minutes(30),
                MinTtl = Duration.Minutes(30),
                PathPattern = "pathPattern",
                TrustedKeyGroups = new [] { keyGroupRef },
                TrustedSigners = new [] { "trustedSigners" },
                ViewerProtocolPolicy = ViewerProtocolPolicy.HTTPS_ONLY
            };

Properties

AllowedMethods

The method this CloudFront distribution responds do.

public CloudFrontAllowedMethods? AllowedMethods { get; set; }
Property Value

CloudFrontAllowedMethods?

Remarks

Default: GET_HEAD

CachedMethods

Which methods are cached by CloudFront by default.

public CloudFrontAllowedCachedMethods? CachedMethods { get; set; }
Property Value

CloudFrontAllowedCachedMethods?

Remarks

Default: GET_HEAD

Compress

If CloudFront should automatically compress some content types.

public bool? Compress { get; set; }
Property Value

bool?

Remarks

Default: true

DefaultTtl

The default amount of time CloudFront will cache an object.

public Duration? DefaultTtl { get; set; }
Property Value

Duration

Remarks

This value applies only when your custom origin does not add HTTP headers, such as Cache-Control max-age, Cache-Control s-maxage, and Expires to objects.

Default: 86400 (1 day)

ForwardedValues

The values CloudFront will forward to the origin when making a request.

public CfnDistribution.IForwardedValuesProperty? ForwardedValues { get; set; }
Property Value

CfnDistribution.IForwardedValuesProperty

Remarks

Default: none (no cookies - no headers)

FunctionAssociations

The CloudFront functions to invoke before serving the contents.

public IFunctionAssociation[]? FunctionAssociations { get; set; }
Property Value

IFunctionAssociation[]

Remarks

Default: - no functions will be invoked

IsDefaultBehavior

If this behavior is the default behavior for the distribution.

public bool? IsDefaultBehavior { get; set; }
Property Value

bool?

Remarks

You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the "path" property.

LambdaFunctionAssociations

Declares associated lambda@edge functions for this distribution behaviour.

public ILambdaFunctionAssociation[]? LambdaFunctionAssociations { get; set; }
Property Value

ILambdaFunctionAssociation[]

Remarks

Default: No lambda function associated

MaxTtl

The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

public Duration? MaxTtl { get; set; }
Property Value

Duration

Remarks

Default: Duration.seconds(31536000) (one year)

MinTtl

The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.

public Duration? MinTtl { get; set; }
Property Value

Duration

Remarks

ExampleMetadata: fixture=_generated

PathPattern

The path this behavior responds to.

public string? PathPattern { get; set; }
Property Value

string

Remarks

Required for all non-default behaviors. (The default behavior implicitly has "*" as the path pattern. )

TrustedKeyGroups

A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.

public IKeyGroupRef[]? TrustedKeyGroups { get; set; }
Property Value

IKeyGroupRef[]

Remarks

Default: - no KeyGroups are associated with cache behavior

See: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html

TrustedSigners

(deprecated) Trusted signers is how CloudFront allows you to serve private content.

[Obsolete("- We recommend using trustedKeyGroups instead of trustedSigners.")]
public string[]? TrustedSigners { get; set; }
Property Value

string[]

Remarks

The signers are the account IDs that are allowed to sign cookies/presigned URLs for this distribution.

If you pass a non empty value, all requests for this behavior must be signed (no public access will be allowed)

Stability: Deprecated

ViewerProtocolPolicy

The viewer policy for this behavior.

public ViewerProtocolPolicy? ViewerProtocolPolicy { get; set; }
Property Value

ViewerProtocolPolicy?

Remarks

Default: - the distribution wide viewer protocol policy will be used

Implements

IBehavior
Back to top Generated by DocFX