Class Distribution

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.cloudfront.Distribution
All Implemented Interfaces:
IConstruct, IDependable, IResource, IDistribution, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:43.673Z") @Stability(Stable) public class Distribution extends Resource implements IDistribution
A CloudFront distribution with associated origin(s) and caching behavior(s).

Example:

 // Adding an existing Lambda@Edge function created in a different stack
 // to a CloudFront distribution.
 Bucket s3Bucket;
 IVersion functionVersion = Version.fromVersionArn(this, "Version", "arn:aws:lambda:us-east-1:123456789012:function:functionName:1");
 Distribution.Builder.create(this, "distro")
         .defaultBehavior(BehaviorOptions.builder()
                 .origin(new S3Origin(s3Bucket))
                 .edgeLambdas(List.of(EdgeLambda.builder()
                         .functionVersion(functionVersion)
                         .eventType(LambdaEdgeEventType.VIEWER_REQUEST)
                         .build()))
                 .build())
         .build();
 
  • Constructor Details

    • Distribution

      protected Distribution(software.amazon.jsii.JsiiObjectRef objRef)
    • Distribution

      protected Distribution(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Distribution

      @Stability(Stable) public Distribution(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DistributionProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromDistributionAttributes

      @Stability(Stable) @NotNull public static IDistribution fromDistributionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DistributionAttributes attrs)
      Creates a Distribution construct that represents an external (imported) distribution.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addBehavior

      @Stability(Stable) public void addBehavior(@NotNull String pathPattern, @NotNull IOrigin origin, @Nullable AddBehaviorOptions behaviorOptions)
      Adds a new behavior to this distribution for the given pathPattern.

      Parameters:
      pathPattern - the path pattern (e.g., 'images/*') that specifies which requests to apply the behavior to. This parameter is required.
      origin - the origin to use for this behavior. This parameter is required.
      behaviorOptions - the options for the behavior at this path.
    • addBehavior

      @Stability(Stable) public void addBehavior(@NotNull String pathPattern, @NotNull IOrigin origin)
      Adds a new behavior to this distribution for the given pathPattern.

      Parameters:
      pathPattern - the path pattern (e.g., 'images/*') that specifies which requests to apply the behavior to. This parameter is required.
      origin - the origin to use for this behavior. This parameter is required.
    • getDistributionDomainName

      @Stability(Stable) @NotNull public String getDistributionDomainName()
      The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.
      Specified by:
      getDistributionDomainName in interface IDistribution
    • getDistributionId

      @Stability(Stable) @NotNull public String getDistributionId()
      The distribution ID for this distribution.
      Specified by:
      getDistributionId in interface IDistribution
    • getDomainName

      @Stability(Stable) @NotNull public String getDomainName()
      The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.
      Specified by:
      getDomainName in interface IDistribution