AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

DistributionConfig

import "github.com/aws/aws-sdk-go/service/cloudfront"

type DistributionConfig struct { Aliases *Aliases `type:"structure"` CacheBehaviors *CacheBehaviors `type:"structure"` CallerReference *string `type:"string" required:"true"` Comment *string `type:"string" required:"true"` CustomErrorResponses *CustomErrorResponses `type:"structure"` DefaultCacheBehavior *DefaultCacheBehavior `type:"structure" required:"true"` DefaultRootObject *string `type:"string"` Enabled *bool `type:"boolean" required:"true"` HttpVersion *string `type:"string" enum:"HttpVersion"` IsIPV6Enabled *bool `type:"boolean"` Logging *LoggingConfig `type:"structure"` OriginGroups *OriginGroups `type:"structure"` Origins *Origins `type:"structure" required:"true"` PriceClass *string `type:"string" enum:"PriceClass"` Restrictions *Restrictions `type:"structure"` ViewerCertificate *ViewerCertificate `type:"structure"` WebACLId *string `type:"string"` }

A distribution configuration.

Aliases

A complex type that contains information about CNAMEs (alternate domain names), if any, for this distribution.

CacheBehaviors

A complex type that contains zero or more CacheBehavior elements.

CallerReference

Type: *string

A unique value (for example, a date-time stamp) that ensures that the request can't be replayed.

If the value of CallerReference is new (regardless of the content of the DistributionConfig object), CloudFront creates a new distribution.

If CallerReference is a value that you already sent in a previous request to create a distribution, CloudFront returns a DistributionAlreadyExists error.

CallerReference is a required field

Comment

Type: *string

Any comments you want to include about the distribution.

If you don't want to specify a comment, include an empty Comment element.

To delete an existing comment, update the distribution configuration and include an empty Comment element.

To add or change a comment, update the distribution configuration and specify the new comment.

Comment is a required field

CustomErrorResponses

A complex type that controls:

  • Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.

  • How long CloudFront caches HTTP status codes in the 4xx and 5xx range.

For more information about custom error pages, see Customizing Error Responses (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html) in the Amazon CloudFront Developer Guide.

DefaultCacheBehavior

A complex type that describes the default cache behavior if you don't specify a CacheBehavior element or if files don't match any of the values of PathPattern in CacheBehavior elements. You must create exactly one default cache behavior.

DefaultRootObject

Type: *string

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 (http://www.example.com) instead of an object in your distribution (http://www.example.com/product-description.html). Specifying a default root object avoids exposing the contents of your distribution.

Specify only the object name, for example, index.html. Don't add a / before the object name.

If you don't want to specify a default root object when you create a distribution, include an empty DefaultRootObject element.

To delete the default root object from an existing distribution, update the distribution configuration and include an empty DefaultRootObject element.

To replace the default root object, update the distribution configuration and specify the new object.

For more information about the default root object, see Creating a Default Root Object (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html) in the Amazon CloudFront Developer Guide.

Enabled

Type: *bool

From this field, you can enable or disable the selected distribution.

Enabled is a required field

HttpVersion

Type: *string

(Optional) Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. The default value for new web distributions is http2. Viewers that don't support HTTP/2 automatically use an earlier HTTP version.

For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support Server Name Identification (SNI).

In general, configuring CloudFront to communicate with viewers using HTTP/2 reduces latency. You can improve performance by optimizing for HTTP/2. For more information, do an Internet search for "http/2 optimization."

IsIPV6Enabled

Type: *bool

If you want CloudFront to respond to IPv6 DNS requests with an IPv6 address for your distribution, specify true. 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.

In general, you should enable IPv6 if you have users on IPv6 networks who want to access your content. However, if you're using signed URLs or signed cookies to restrict access to your content, and if you're using a custom policy that includes the IpAddress parameter to restrict the IP addresses that can access your content, don't enable IPv6. If you want to restrict access to some content by IP address and not restrict access to other content (or restrict access but not by IP address), you can create two distributions. For more information, see Creating a Signed URL Using a Custom Policy (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html) in the Amazon CloudFront Developer Guide.

If you're using an Amazon Route 53 alias resource record set to route traffic to your CloudFront distribution, you need to create a second alias resource record set when both of the following are true:

  • You enable IPv6 for the distribution

  • You're using alternate domain names in the URLs for your objects

For more information, see Routing Traffic to an Amazon CloudFront Web Distribution by Using Your Domain Name (https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html) in the Amazon Route 53 Developer Guide.

If you created a CNAME resource record set, either with Amazon Route 53 or with another DNS service, you don't need to make any changes. A CNAME record will route traffic to your distribution regardless of the IP address format of the viewer request.

Logging

A complex type that controls whether access logs are written for the distribution.

OriginGroups

A complex data type for the origin groups specified for a distribution.

Origins

A complex type that contains information about origins and origin groups for this distribution.

PriceClass

Type: *string

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. Viewers who are in or near regions that are excluded from your specified price class may encounter slower performance.

For more information about price classes, see Choosing the Price Class for a CloudFront Distribution (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PriceClass.html) in the Amazon CloudFront Developer Guide. For information about CloudFront pricing, including how price classes (such as Price Class 100) map to CloudFront regions, see Amazon CloudFront Pricing (https://aws.amazon.com/cloudfront/pricing/). For price class information, scroll down to see the table at the bottom of the page.

Restrictions

A complex type that identifies ways in which you want to restrict distribution of your content.

ViewerCertificate

A complex type that specifies the following:

  • Whether you want viewers to use HTTP or HTTPS to request your objects.

  • If you want viewers to use HTTPS, whether you're using an alternate domain name such as example.com or the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net.

  • If you're using an alternate domain name, whether AWS Certificate Manager

(ACM) provided the certificate, or you purchased a certificate from a third-party certificate authority and imported it into ACM or uploaded it to the IAM certificate store.

You must specify only one of the following values:

  • ViewerCertificate$ACMCertificateArn

  • ViewerCertificate$IAMCertificateId

  • ViewerCertificate$CloudFrontDefaultCertificate

Don't specify false for CloudFrontDefaultCertificate.

If you want viewers to use HTTP instead of HTTPS to request your objects: Specify the following value:

<CloudFrontDefaultCertificate>true<CloudFrontDefaultCertificate>

In addition, specify allow-all for ViewerProtocolPolicy for all of your cache behaviors.

If you want viewers to use HTTPS to request your objects: Choose the type of certificate that you want to use based on whether you're using an alternate domain name for your objects or the CloudFront domain name:

  • If you're using an alternate domain name, such as example.com: Specify one of the following values, depending on whether ACM provided your certificate or you purchased your certificate from third-party certificate authority:

<ACMCertificateArn>ARN for ACM SSL/TLS certificate<ACMCertificateArn> where

ARN for ACM SSL/TLS certificate is the ARN for the ACM SSL/TLS certificate that you want to use for this distribution.

<IAMCertificateId>IAM certificate ID<IAMCertificateId> where IAM certificate

ID is the ID that IAM returned when you added the certificate to the IAM certificate store.

If you specify ACMCertificateArn or IAMCertificateId, you must also specify

a value for SSLSupportMethod.

If you choose to use an ACM certificate or a certificate in the IAM certificate

store, we recommend that you use only an alternate domain name in your object URLs (https://example.com/logo.jpg). If you use the domain name that is associated with your CloudFront distribution (such as https://d111111abcdef8.cloudfront.net/logo.jpg) and the viewer supports SNI, then CloudFront behaves normally. However, if the browser does not support SNI, the user's experience depends on the value that you choose for SSLSupportMethod:

vip: The viewer displays a warning because there is a mismatch between the

CloudFront domain name and the domain name in your SSL/TLS certificate.

sni-only: CloudFront drops the connection with the browser without returning

the object.
  • If you're using the CloudFront domain name for your distribution, such as d111111abcdef8.cloudfront.net: Specify the following value:

<CloudFrontDefaultCertificate>true<CloudFrontDefaultCertificate>

If you want viewers to use HTTPS, you must also specify one of the following values in your cache behaviors:

  • <ViewerProtocolPolicy>https-only<ViewerProtocolPolicy>

  • <ViewerProtocolPolicy>redirect-to-https<ViewerProtocolPolicy>

You can also optionally require that CloudFront use HTTPS to communicate with your origin by specifying one of the following values for the applicable origins:

  • <OriginProtocolPolicy>https-only<OriginProtocolPolicy>

  • <OriginProtocolPolicy>match-viewer<OriginProtocolPolicy>

For more information, see Using Alternate Domain Names and HTTPS (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html#CNAMEsAndHTTPS) in the Amazon CloudFront Developer Guide.

WebACLId

Type: *string

A unique identifier that specifies the AWS WAF web ACL, if any, to associate with this distribution.

AWS WAF is a web application firewall that lets you monitor the HTTP and HTTPS requests that are forwarded to CloudFront, and lets you control access to your content. Based on conditions that you specify, such as the IP addresses that requests originate from or the values of query strings, CloudFront responds to requests either with the requested content or with an HTTP 403 status code (Forbidden). You can also configure CloudFront to return a custom error page when a request is blocked. For more information about AWS WAF, see the AWS WAF Developer Guide (https://docs.aws.amazon.com/waf/latest/developerguide/what-is-aws-waf.html).

Method

GoString

func (s DistributionConfig) GoString() string

GoString returns the string representation

SetAliases

func (s *DistributionConfig) SetAliases(v *Aliases) *DistributionConfig

SetAliases sets the Aliases field's value.

SetCacheBehaviors

func (s *DistributionConfig) SetCacheBehaviors(v *CacheBehaviors) *DistributionConfig

SetCacheBehaviors sets the CacheBehaviors field's value.

SetCallerReference

func (s *DistributionConfig) SetCallerReference(v string) *DistributionConfig

SetCallerReference sets the CallerReference field's value.

SetComment

func (s *DistributionConfig) SetComment(v string) *DistributionConfig

SetComment sets the Comment field's value.

SetCustomErrorResponses

func (s *DistributionConfig) SetCustomErrorResponses(v *CustomErrorResponses) *DistributionConfig

SetCustomErrorResponses sets the CustomErrorResponses field's value.

SetDefaultCacheBehavior

func (s *DistributionConfig) SetDefaultCacheBehavior(v *DefaultCacheBehavior) *DistributionConfig

SetDefaultCacheBehavior sets the DefaultCacheBehavior field's value.

SetDefaultRootObject

func (s *DistributionConfig) SetDefaultRootObject(v string) *DistributionConfig

SetDefaultRootObject sets the DefaultRootObject field's value.

SetEnabled

func (s *DistributionConfig) SetEnabled(v bool) *DistributionConfig

SetEnabled sets the Enabled field's value.

SetHttpVersion

func (s *DistributionConfig) SetHttpVersion(v string) *DistributionConfig

SetHttpVersion sets the HttpVersion field's value.

SetIsIPV6Enabled

func (s *DistributionConfig) SetIsIPV6Enabled(v bool) *DistributionConfig

SetIsIPV6Enabled sets the IsIPV6Enabled field's value.

SetLogging

func (s *DistributionConfig) SetLogging(v *LoggingConfig) *DistributionConfig

SetLogging sets the Logging field's value.

SetOriginGroups

func (s *DistributionConfig) SetOriginGroups(v *OriginGroups) *DistributionConfig

SetOriginGroups sets the OriginGroups field's value.

SetOrigins

func (s *DistributionConfig) SetOrigins(v *Origins) *DistributionConfig

SetOrigins sets the Origins field's value.

SetPriceClass

func (s *DistributionConfig) SetPriceClass(v string) *DistributionConfig

SetPriceClass sets the PriceClass field's value.

SetRestrictions

func (s *DistributionConfig) SetRestrictions(v *Restrictions) *DistributionConfig

SetRestrictions sets the Restrictions field's value.

SetViewerCertificate

func (s *DistributionConfig) SetViewerCertificate(v *ViewerCertificate) *DistributionConfig

SetViewerCertificate sets the ViewerCertificate field's value.

SetWebACLId

func (s *DistributionConfig) SetWebACLId(v string) *DistributionConfig

SetWebACLId sets the WebACLId field's value.

String

func (s DistributionConfig) String() string

String returns the string representation

Validate

func (s *DistributionConfig) Validate() error

Validate inspects the fields of the type to determine if they are valid.

On this page: