-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Please expose Distribution in sst/constructs #3723
Comments
Hmm it's an internal construct. Is there a reason you want to use it? |
Yes, sure, there's quite a reason to use it, and I don't see a reason not to, cause everything is well-put and ready to be used for the only exception being not exposed, which you can fix with a simple patch (tested). I want to use SST Distribution to create a CloudFront distribution and couple it up with a S3 bucket while having other things (like ACM cert) to be taken care of for me. I considered that for image hosting, or other static assets off of alternative origin relative to a website (not necessarily for a fully-fledged static website though, which I know there's another construct exists for) The simplest pattern I've come up is this: import { Bucket, Distribution, StackContext, use } from 'sst/constructs'
export function DataStack({ stack }: StackContext) {
const notionBucket = new Bucket(stack, 'NotionBucket')
const distribution = new Distribution(stack, 'NotionDistribution', {
customDomain: staticDomain.value,
cdk: {
distribution: {
comment: 'Static assets for a website',
defaultBehavior: {
// viewerProtocolPolicy: ViewerProtocolPolicy.HTTPS_ONLY,
// allowedMethods: AllowedMethods.ALLOW_ALL,
origin: new S3Origin(notionBucket.cdk.bucket),
},
},
},
})
... Though, requires a bit of patching to work. But I hate patching, let's do it properly with author's confirmation |
Yes +1 I would use this. |
This can potentially help suffice other problems, such as being able to host multiple static sites under the same distribution (which can be done right now but it's super painful). +1 would use this |
When trying to import and use Distribution constructs:
It's complaining that Distribution isn't available, despite having this construct exported in source code...
Problem is index.d.ts, index.js do not include Distribution module and as such, a consumer code can't use it
Workaround, use pnpm patch or patch-package to slightly modify the sts package. Eg:
Author, please export/expose this object for usage out of 'sst/constructs', find it necessary.
Thank you so much!
The text was updated successfully, but these errors were encountered: