Interface Behavior

All Superinterfaces:
software.amazon.jsii.JsiiSerializable
All Known Implementing Classes:
Behavior.Jsii$Proxy

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-18T17:54:13.597Z") @Stability(Stable) public interface Behavior extends software.amazon.jsii.JsiiSerializable
A CloudFront behavior wrapper.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.*;
 import software.amazon.awscdk.services.cloudfront.*;
 import software.amazon.awscdk.services.lambda.*;
 Function function_;
 KeyGroup keyGroup;
 Version version;
 Behavior behavior = Behavior.builder()
         .allowedMethods(CloudFrontAllowedMethods.GET_HEAD)
         .cachedMethods(CloudFrontAllowedCachedMethods.GET_HEAD)
         .compress(false)
         .defaultTtl(Duration.minutes(30))
         .forwardedValues(ForwardedValuesProperty.builder()
                 .queryString(false)
                 // the properties below are optional
                 .cookies(CookiesProperty.builder()
                         .forward("forward")
                         // the properties below are optional
                         .whitelistedNames(List.of("whitelistedNames"))
                         .build())
                 .headers(List.of("headers"))
                 .queryStringCacheKeys(List.of("queryStringCacheKeys"))
                 .build())
         .functionAssociations(List.of(FunctionAssociation.builder()
                 .eventType(FunctionEventType.VIEWER_REQUEST)
                 .function(function_)
                 .build()))
         .isDefaultBehavior(false)
         .lambdaFunctionAssociations(List.of(LambdaFunctionAssociation.builder()
                 .eventType(LambdaEdgeEventType.ORIGIN_REQUEST)
                 .lambdaFunction(version)
                 // the properties below are optional
                 .includeBody(false)
                 .build()))
         .maxTtl(Duration.minutes(30))
         .minTtl(Duration.minutes(30))
         .pathPattern("pathPattern")
         .trustedKeyGroups(List.of(keyGroup))
         .trustedSigners(List.of("trustedSigners"))
         .viewerProtocolPolicy(ViewerProtocolPolicy.HTTPS_ONLY)
         .build();
 
  • Method Details

    • getAllowedMethods

      @Stability(Stable) @Nullable default CloudFrontAllowedMethods getAllowedMethods()
      The method this CloudFront distribution responds do.

      Default: GET_HEAD

    • getCachedMethods

      @Stability(Stable) @Nullable default CloudFrontAllowedCachedMethods getCachedMethods()
      Which methods are cached by CloudFront by default.

      Default: GET_HEAD

    • getCompress

      @Stability(Stable) @Nullable default Boolean getCompress()
      If CloudFront should automatically compress some content types.

      Default: true

    • getDefaultTtl

      @Stability(Stable) @Nullable default Duration getDefaultTtl()
      The default amount of time CloudFront will cache an object.

      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)

    • getForwardedValues

      @Stability(Stable) @Nullable default CfnDistribution.ForwardedValuesProperty getForwardedValues()
      The values CloudFront will forward to the origin when making a request.

      Default: none (no cookies - no headers)

    • getFunctionAssociations

      @Stability(Stable) @Nullable default List<FunctionAssociation> getFunctionAssociations()
      The CloudFront functions to invoke before serving the contents.

      Default: - no functions will be invoked

    • getIsDefaultBehavior

      @Stability(Stable) @Nullable default Boolean getIsDefaultBehavior()
      If this behavior is the default behavior for the distribution.

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

    • getLambdaFunctionAssociations

      @Stability(Stable) @Nullable default List<LambdaFunctionAssociation> getLambdaFunctionAssociations()
      Declares associated lambda@edge functions for this distribution behaviour.

      Default: No lambda function associated

    • getMaxTtl

      @Stability(Stable) @Nullable default Duration getMaxTtl()
      The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

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

    • getMinTtl

      @Stability(Stable) @Nullable default Duration getMinTtl()
      The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.
    • getPathPattern

      @Stability(Stable) @Nullable default String getPathPattern()
      The path this behavior responds to.

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

    • getTrustedKeyGroups

      @Stability(Stable) @Nullable default List<IKeyGroup> getTrustedKeyGroups()
      A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.

      Default: - no KeyGroups are associated with cache behavior

      See Also:
    • getTrustedSigners

      @Stability(Deprecated) @Deprecated @Nullable default List<String> getTrustedSigners()
      Deprecated.
      • We recommend using trustedKeyGroups instead of trustedSigners.
      (deprecated) Trusted signers is how CloudFront allows you to serve private content.

      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)

    • getViewerProtocolPolicy

      @Stability(Stable) @Nullable default ViewerProtocolPolicy getViewerProtocolPolicy()
      The viewer policy for this behavior.

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

    • builder

      @Stability(Stable) static Behavior.Builder builder()
      Returns:
      a Behavior.Builder of Behavior