Deploying a static site to S3 works really well unless we consider the fact that you cannot add HTTPS support to the site directly in S3. In order to do that - a CloudFront distribution is required.
While it is possible to setup CloudFront with CDK on our own, we don't always have to do anything on our own.
Instead, we can use constructs that were created by the community.
In this quick lesson we're going to learn how to use CDK-SPA-Deploy construct in order to deploy our app to S3 (using
createBasicSite construct) and deploy it with HTTPS support and behind a CloudFront CDN distribution.
IMPORTANT NOTE: All AWS Construct Library modules used in your project must be the same version.
I was getting errors after installing cdk-spa-deploy via yarn and trying to implement SPADeploy in the code. The app wouldn't build. There error I was getting was: "Argument type of 'this' is not assignable to parameter of type 'Construct'"
In order to get it working I had to make sure all aws-cdk packages had matching versions. remove all carets in version numbers (^)... then npm install, npm run build, cdk deploy.
I ended up deleting my npm_modules folder but I'm not sure if that's necessary. No issues have arose at the moment.
I am getting this error while installing cdk-spa-deploy npm package
Error: 404 Not Found - GET https://registry.npmjs.org/@aws-cdk%2faws-iam - Not found
npm was down around 2 hours ago, could you try again? :)