CloudFront Distribution

The CloudFrontDistributionDecorator associates a CloudFront Distribution with your S3-backed website. It is implemented as a ServiceDecoratorHookHandler as a single service can only provision one CloudFront distribution.

Sample usage:

// CloudFront settings
const subdomain = "mySiteSubdomain"

// The domain managed by Route53.
const domainName = ""

// The site will be available at

// The S3 bucketname must match the subdomain.domain
// name pattern to serve as a CloudFront Distribution target
var bucketName = fmt.Sprintf("%s.%s", subdomain, domainName)

func distroHooks(s3Site *sparta.S3Site) *sparta.WorkflowHooks {

  // Commented out demonstration of how to front the site
  // with a CloudFront distribution.
  // Note that provisioning a distribution will incur additional
  // costs
  hooks := &sparta.WorkflowHooks{}
  siteHookDecorator := spartaDecorators.CloudFrontSiteDistributionDecorator(s3Site,
  hooks.ServiceDecorators = []sparta.ServiceDecoratorHookHandler{
  return hooks