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

serverless set up #3

Open
kiwicopple opened this issue Jun 1, 2017 · 4 comments
Open

serverless set up #3

kiwicopple opened this issue Jun 1, 2017 · 4 comments

Comments

@kiwicopple
Copy link

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

@kurtextrem
Copy link

kurtextrem commented Jun 1, 2017 via email

@BerndWessels
Copy link
Owner

@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.

@kiwicopple
Copy link
Author

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
Copy link
Author

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

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

No branches or pull requests

3 participants