Class Distribution.Builder

java.lang.Object
software.amazon.awscdk.services.cloudfront.Distribution.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<Distribution>
Enclosing class:
Distribution

@Stability(Stable) public static final class Distribution.Builder extends Object implements software.amazon.jsii.Builder<Distribution>
A fluent builder for Distribution.
  • Method Details

    • create

      @Stability(Stable) public static Distribution.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of Distribution.Builder.
    • defaultBehavior

      @Stability(Stable) public Distribution.Builder defaultBehavior(BehaviorOptions defaultBehavior)
      The default behavior for the distribution.

      Parameters:
      defaultBehavior - The default behavior for the distribution. This parameter is required.
      Returns:
      this
    • additionalBehaviors

      @Stability(Stable) public Distribution.Builder additionalBehaviors(Map<String,? extends BehaviorOptions> additionalBehaviors)
      Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to.

      Default: - no additional behaviors are added.

      Parameters:
      additionalBehaviors - Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to. This parameter is required.
      Returns:
      this
    • certificate

      @Stability(Stable) public Distribution.Builder certificate(ICertificate certificate)
      A certificate to associate with the distribution.

      The certificate must be located in N. Virginia (us-east-1).

      Default: - the CloudFront wildcard certificate (*.cloudfront.net) will be used.

      Parameters:
      certificate - A certificate to associate with the distribution. This parameter is required.
      Returns:
      this
    • comment

      @Stability(Stable) public Distribution.Builder comment(String comment)
      Any comments you want to include about the distribution.

      Default: - no comment

      Parameters:
      comment - Any comments you want to include about the distribution. This parameter is required.
      Returns:
      this
    • defaultRootObject

      @Stability(Stable) public Distribution.Builder defaultRootObject(String defaultRootObject)
      The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/).

      Default: - no default root object

      Parameters:
      defaultRootObject - The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/). This parameter is required.
      Returns:
      this
    • domainNames

      @Stability(Stable) public Distribution.Builder domainNames(List<String> domainNames)
      Alternative domain names for this distribution.

      If you want to use your own domain name, such as www.example.com, instead of the cloudfront.net domain name, you can add an alternate domain name to your distribution. If you attach a certificate to the distribution, you must add (at least one of) the domain names of the certificate to this list.

      Default: - The distribution will only support the default generated name (e.g., d111111abcdef8.cloudfront.net)

      Parameters:
      domainNames - Alternative domain names for this distribution. This parameter is required.
      Returns:
      this
    • enabled

      @Stability(Stable) public Distribution.Builder enabled(Boolean enabled)
      Enable or disable the distribution.

      Default: true

      Parameters:
      enabled - Enable or disable the distribution. This parameter is required.
      Returns:
      this
    • enableIpv6

      @Stability(Stable) public Distribution.Builder enableIpv6(Boolean enableIpv6)
      Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address.

      If you specify false, CloudFront responds to IPv6 DNS requests with the DNS response code NOERROR and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.

      Default: true

      Parameters:
      enableIpv6 - Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address. This parameter is required.
      Returns:
      this
    • enableLogging

      @Stability(Stable) public Distribution.Builder enableLogging(Boolean enableLogging)
      Enable access logging for the distribution.

      Default: - false, unless `logBucket` is specified.

      Parameters:
      enableLogging - Enable access logging for the distribution. This parameter is required.
      Returns:
      this
    • errorResponses

      @Stability(Stable) public Distribution.Builder errorResponses(List<? extends ErrorResponse> errorResponses)
      How CloudFront should handle requests that are not successful (e.g., PageNotFound).

      Default: - No custom error responses.

      Parameters:
      errorResponses - How CloudFront should handle requests that are not successful (e.g., PageNotFound). This parameter is required.
      Returns:
      this
    • geoRestriction

      @Stability(Stable) public Distribution.Builder geoRestriction(GeoRestriction geoRestriction)
      Controls the countries in which your content is distributed.

      Default: - No geographic restrictions

      Parameters:
      geoRestriction - Controls the countries in which your content is distributed. This parameter is required.
      Returns:
      this
    • httpVersion

      @Stability(Stable) public Distribution.Builder httpVersion(HttpVersion httpVersion)
      Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront.

      For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support server name identification (SNI).

      Default: HttpVersion.HTTP2

      Parameters:
      httpVersion - Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. This parameter is required.
      Returns:
      this
    • logBucket

      @Stability(Stable) public Distribution.Builder logBucket(IBucket logBucket)
      The Amazon S3 bucket to store the access logs in.

      Make sure to set objectOwnership to s3.ObjectOwnership.OBJECT_WRITER in your custom bucket.

      Default: - A bucket is created if `enableLogging` is true

      Parameters:
      logBucket - The Amazon S3 bucket to store the access logs in. This parameter is required.
      Returns:
      this
    • logFilePrefix

      @Stability(Stable) public Distribution.Builder logFilePrefix(String logFilePrefix)
      An optional string that you want CloudFront to prefix to the access log filenames for this distribution.

      Default: - no prefix

      Parameters:
      logFilePrefix - An optional string that you want CloudFront to prefix to the access log filenames for this distribution. This parameter is required.
      Returns:
      this
    • logIncludesCookies

      @Stability(Stable) public Distribution.Builder logIncludesCookies(Boolean logIncludesCookies)
      Specifies whether you want CloudFront to include cookies in access logs.

      Default: false

      Parameters:
      logIncludesCookies - Specifies whether you want CloudFront to include cookies in access logs. This parameter is required.
      Returns:
      this
    • minimumProtocolVersion

      @Stability(Stable) public Distribution.Builder minimumProtocolVersion(SecurityPolicyProtocol minimumProtocolVersion)
      The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.

      CloudFront serves your objects only to browsers or devices that support at least the SSL version that you specify.

      Default: - SecurityPolicyProtocol.TLS_V1_2_2021 if the '@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021' feature flag is set; otherwise, SecurityPolicyProtocol.TLS_V1_2_2019.

      Parameters:
      minimumProtocolVersion - The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. This parameter is required.
      Returns:
      this
    • priceClass

      @Stability(Stable) public Distribution.Builder priceClass(PriceClass priceClass)
      The price class that corresponds with the maximum price that you want to pay for CloudFront service.

      If you specify PriceClass_All, CloudFront responds to requests for your objects from all CloudFront edge locations. If you specify a price class other than PriceClass_All, CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class.

      Default: PriceClass.PRICE_CLASS_ALL

      Parameters:
      priceClass - The price class that corresponds with the maximum price that you want to pay for CloudFront service. This parameter is required.
      Returns:
      this
    • publishAdditionalMetrics

      @Stability(Stable) public Distribution.Builder publishAdditionalMetrics(Boolean publishAdditionalMetrics)
      Whether to enable additional CloudWatch metrics.

      Default: false

      Parameters:
      publishAdditionalMetrics - Whether to enable additional CloudWatch metrics. This parameter is required.
      Returns:
      this
      See Also:
    • sslSupportMethod

      @Stability(Stable) public Distribution.Builder sslSupportMethod(SSLMethod sslSupportMethod)
      The SSL method CloudFront will use for your distribution.

      Server Name Indication (SNI) - is an extension to the TLS computer networking protocol by which a client indicates which hostname it is attempting to connect to at the start of the handshaking process. This allows a server to present multiple certificates on the same IP address and TCP port number and hence allows multiple secure (HTTPS) websites (or any other service over TLS) to be served by the same IP address without requiring all those sites to use the same certificate.

      CloudFront can use SNI to host multiple distributions on the same IP - which a large majority of clients will support.

      If your clients cannot support SNI however - CloudFront can use dedicated IPs for your distribution - but there is a prorated monthly charge for using this feature. By default, we use SNI - but you can optionally enable dedicated IPs (VIP).

      See the CloudFront SSL for more details about pricing : https://aws.amazon.com/cloudfront/custom-ssl-domains/

      Default: SSLMethod.SNI

      Parameters:
      sslSupportMethod - The SSL method CloudFront will use for your distribution. This parameter is required.
      Returns:
      this
    • webAclId

      @Stability(Stable) public Distribution.Builder webAclId(String webAclId)
      Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.

      To specify a web ACL created using the latest version of AWS WAF, use the ACL ARN, for example arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a. To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example 473e64fd-f30b-4765-81a0-62ad96dd167a.

      Default: - No AWS Web Application Firewall web access control list (web ACL).

      Parameters:
      webAclId - Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution. This parameter is required.
      Returns:
      this
      See Also:
    • build

      @Stability(Stable) public Distribution build()
      Specified by:
      build in interface software.amazon.jsii.Builder<Distribution>
      Returns:
      a newly built instance of Distribution.