preact-redux-isomorphic icon indicating copy to clipboard operation
preact-redux-isomorphic copied to clipboard

serverless set up

Open kiwicopple opened this issue 7 years ago • 4 comments

Hey, I'm really interested in the serverless set up - do you think you could include the terraform scripts in the repo or a gist? I tried following the instructions but got lost - I think the script will be a bit more explicit.

Great boilerplate btw

kiwicopple avatar Jun 01 '17 08:06 kiwicopple

I recommend preact-cli / PR #11, lots of work done for serverless prerendering.

Am 01.06.2017 10:06 schrieb "Copple" [email protected]:

Hey, I'm really interested in the serverless set up - do you think you could include the terraform scripts in the repo or a gist? I tried following the instructions but got lost - I think the script will be a bit more explicit.

Great boilerplate btw

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BerndWessels/preact-redux-isomorphic/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AAepgoq3EnhV8GlviwsR_6jaxzZ4bO_7ks5r_nEHgaJpZM4NsoKJ .

kurtextrem avatar Jun 01 '17 08:06 kurtextrem

@kiwicopple You can find a complete example with terraform infrastructure here.

It automatically builds the domain and complete infrastructure for it and the preact website in a Lambda with SSR and static resources in S3. Its live at wessels.nz

Let me know what you think and if you have any more questions.

BerndWessels avatar Jun 01 '17 19:06 BerndWessels

This is a really great set of scripts, thanks @BerndWessels !!

Perhaps one more question - I have the cloudfront distro set up, but I'm getting errors when I try to access it via my website. I have Route53 Record Set with an Alias target that is equal to the cloudfront URL, but I can't quite figure it out.

I'll drop the full set of steps I took below, since I figure someone else may find them useful. My first time with terraform, it was quite enjoyable

Prereq's

  1. Make sure you have created an IAM role with AWSLambdaBasicExecutionRole and CloudWatchLogsFullAccess
  2. Make sure you have added your ssh key to your github account (this is required for the terraform get command later)
  3. Create a certificate for your domain if you don't already have one using AWS Certificate manager (this had to be in the us-east-1 region for some reason?)

Instructions

  1. Fork repo - https://github.com/wessels-nz/infrastructure-modules (this is required for the terraform get command later)
  2. clone the repo to local
  3. cd platform-api - this is the "master" terraform
  4. terraform get - this will pull down all the required submodules for the master terraform
  5. Create a file in this folder that is called prod.tfvars that has the terraform vars (example below)
  6. Run terraform apply -var-file="prod.tfvars"
  7. upload /Path/to/preact-redux-isomorphic/dist/client/* into the newly created bucket in a subfolder _
  8. wait for the cloudfront distro to populate completely
  9. point your DNS to the new cloudfront distro's domain name
  10. visit website (this is the part I am getting an error, could have something to do with Cert, but i'm not sure how to diagnose the problem yet)
  11. send thanks to @BerndWessels

Example prod.tfvars

domain_certificate_arn = "arn:aws:acm:us-east-1:XXXX:certificate/XXX-XX-XXX-XXX"
domain_name = "app.yourdomain.com"
region = "ap-southeast-1"
stage_description = "Production website"
stage_name = "live"
website_lambda_filename = "/Path/to/preact-redux-isomorphic/dist/Archive.zip"
website_lambda_role_arn = "arn:aws:iam::XXXX:role/service-role/XXXXNAME"

kiwicopple avatar Jun 02 '17 09:06 kiwicopple

Looks like it may have resolved itself. Perhaps just a propagation issue - feel free to close this one off

kiwicopple avatar Jun 02 '17 12:06 kiwicopple