github.com/mweagle/Sparta@v1.15.0/docs_source/content/reference/decorators/cloudfront_distribution.md (about) 1 --- 2 date: 2018-01-22 21:49:38 3 title: CloudFront Distribution 4 weight: 10 5 alwaysopen: false 6 --- 7 8 The [CloudFrontDistributionDecorator](https://godoc.org/github.com/mweagle/Sparta/decorator#CloudFrontSiteDistributionDecorator) associates a CloudFront Distribution with your S3-backed website. It is implemented as a [ServiceDecoratorHookHandler](https://godoc.org/github.com/mweagle/Sparta#ServiceDecoratorHookHandler) as a single service can only provision one CloudFront distribution. 9 10 Sample usage: 11 12 ```go 13 14 //////////////////////////////////////////////////////////////////////////////// 15 // CloudFront settings 16 const subdomain = "mySiteSubdomain" 17 18 // The domain managed by Route53. 19 const domainName = "myRoute53ManagedDomain.net" 20 21 // The site will be available at 22 // https://mySiteSubdomain.myRoute53ManagedDomain.net 23 24 // The S3 bucketname must match the subdomain.domain 25 // name pattern to serve as a CloudFront Distribution target 26 var bucketName = fmt.Sprintf("%s.%s", subdomain, domainName) 27 28 func distroHooks(s3Site *sparta.S3Site) *sparta.WorkflowHooks { 29 30 // Commented out demonstration of how to front the site 31 // with a CloudFront distribution. 32 // Note that provisioning a distribution will incur additional 33 // costs 34 hooks := &sparta.WorkflowHooks{} 35 siteHookDecorator := spartaDecorators.CloudFrontSiteDistributionDecorator(s3Site, 36 subdomain, 37 domainName, 38 gocf.String(os.Getenv("SPARTA_ACM_CLOUDFRONT_ARN"))) 39 hooks.ServiceDecorators = []sparta.ServiceDecoratorHookHandler{ 40 siteHookDecorator, 41 } 42 return hooks 43 } 44 45 ```