https://serverless-stack.com/ logo
#help
Title
# help
d

Daniel Gato

01/13/2022, 9:20 AM
How would recommend to structure a deliverable script with SST? For example, our product would be available on domain.com/3.0.1/bundle.js available for our customers to link on their websites with a <script/> tage Second part of the question, ideally, how to handle the version of it with SST? • cdn.com/latest/ -> cdn.com/3.0.1/bundle.jscdn.com/1.0.0/bundle.js • … • cdn.com/3.0.1/bundle.js I’m thinking about StaticSite as this already creates a CDN, handle custom domains, etc but I’m not sure it will be able to handle versioning.
t

thdxr

01/13/2022, 1:35 PM
The way the static site works I'm not sure if it can support this well
I'd maybe start by setting up a bucket and have cdk build + upload this file
d

Daniel Gato

01/13/2022, 8:42 PM
I’m thinking about this workflow: 1. Use StaticSite: it would build and upload my bundle.js to S3 and be behind a CF distribution 2. Have a Function that would detect a new deployment and then copy the new deployed files (that would include a VERSION file) to some folder of the VERSION I’m not sure if there is functions / hooks that would help me doing this.
When you say
cdk build
+ upload, what do you mean exactly? Having some script to do the upload and that I would run? Or would this be part of my Stacks and be automated?
t

thdxr

01/13/2022, 8:43 PM
in your cdk code
you can upload files
Copy code
new s3deploy.BucketDeployment(this, "bundle", {
      sources: [s3deploy.Source.asset(dir)],
      destinationBucket: bucket.s3Bucket,
    })
so on every deploy in nyour cdk code you just have to create a folder with the version + built code and cdk will upload it
You can attach a cloudfront distribution in front of it as well
d

Daniel Gato

01/13/2022, 8:44 PM
That’s amazing.
This looks like what the StaticSite would do
What part of CDK would your s3deploy be?
2 Views