Interface IBehavior
A CloudFront behavior wrapper.
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IBehavior
Syntax (vb)
Public Interface 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;
Function function_;
KeyGroup keyGroup;
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 = function_
} },
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 [] { keyGroup },
TrustedSigners = new [] { "trustedSigners" },
ViewerProtocolPolicy = ViewerProtocolPolicy.HTTPS_ONLY
};
Synopsis
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. |
Properties
AllowedMethods
The method this CloudFront distribution responds do.
CloudFrontAllowedMethods? AllowedMethods { get; }
Property Value
Remarks
Default: GET_HEAD
CachedMethods
Which methods are cached by CloudFront by default.
CloudFrontAllowedCachedMethods? CachedMethods { get; }
Property Value
CloudFrontAllowedCachedMethods?
Remarks
Default: GET_HEAD
Compress
If CloudFront should automatically compress some content types.
bool? Compress { get; }
Property Value
bool?
Remarks
Default: true
DefaultTtl
The default amount of time CloudFront will cache an object.
Duration? DefaultTtl { get; }
Property Value
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.
CfnDistribution.IForwardedValuesProperty? ForwardedValues { get; }
Property Value
CfnDistribution.IForwardedValuesProperty
Remarks
Default: none (no cookies - no headers)
FunctionAssociations
The CloudFront functions to invoke before serving the contents.
IFunctionAssociation[]? FunctionAssociations { get; }
Property Value
Remarks
Default: - no functions will be invoked
IsDefaultBehavior
If this behavior is the default behavior for the distribution.
bool? IsDefaultBehavior { get; }
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.
ILambdaFunctionAssociation[]? LambdaFunctionAssociations { get; }
Property Value
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.
Duration? MaxTtl { get; }
Property Value
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.
Duration? MinTtl { get; }
Property Value
Remarks
ExampleMetadata: fixture=_generated
PathPattern
The path this behavior responds to.
string? PathPattern { get; }
Property Value
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.
IKeyGroup[]? TrustedKeyGroups { get; }
Property Value
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.")]
string[]? TrustedSigners { get; }
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.
ViewerProtocolPolicy? ViewerProtocolPolicy { get; }
Property Value
Remarks
Default: - the distribution wide viewer protocol policy will be used