Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bucket construct should expose WebsiteURL #1521

Closed
AlexChesters opened this issue Jan 11, 2019 · 1 comment · Fixed by #1544
Closed

Bucket construct should expose WebsiteURL #1521

AlexChesters opened this issue Jan 11, 2019 · 1 comment · Fixed by #1544

Comments

@AlexChesters
Copy link
Contributor

Currently, (as far as I can see), the Bucket construct doesn't export the WebsiteURL property. It would be useful if this was exported to prevent situations like the following where you have to hardcode bits of a URL

import * as cloudfront from '@aws-cdk/aws-cloudfront'
import * as s3 from '@aws-cdk/aws-s3'
import * as cdk from '@aws-cdk/cdk'

export default class Stack extends cdk.Stack {
  constructor (parent: cdk.App, name: string, props?: cdk.StackProps) {
    super(parent, name, props)

    const bucket = new s3.Bucket(this, 'Bucket', {
      publicReadAccess: true,
      websiteIndexDocument: 'index.html'
    })

    const distribution = new cloudfront.CloudFrontWebDistribution(this, 'Distribution', {
      aliasConfiguration: {
        acmCertRef: '<MY_CERT_ARN>',
        names: ['my.domain']
      },
      originConfigs: [
        {
          behaviors: [
            {
              defaultTtlSeconds: 10,
              isDefaultBehavior: true,
              maxTtlSeconds: 30,
              minTtlSeconds: 0
            }
          ],
          customOriginSource: {
            // ideally here we could do something like:
            // domainName: bucket.websiteURL,
            domainName: `${bucket.bucketName}.s3-website-eu-west-1.amazonaws.com`,
            originProtocolPolicy: cloudfront.OriginProtocolPolicy.HttpOnly
          }
        }
      ]
    })
}

Planning to open a PR for this unless someone is already working on it :)

@AlexChesters
Copy link
Contributor Author

AlexChesters commented Jan 11, 2019

Opened #1522 #1544 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant