Setup guide - aws

wrenderer | CloudFront integration | on premise setup guide

This guide will walk you through the steps to set up wrenderer in an AWS environment using AWS CloudFormation templates.



Prerequisites

Use pre-built image

Pull the pre-built image from Docker Hub.


docker pull liuminhaw/wrenderer:latest

Build manually

Clone wrenderer git repository.


git clone --depth 1 [email protected]:liuminhaw/wrenderer.git && cd wrenderer

Build docker image.


docker build -t wrenderer .

Setup steps

All environment resources will be created using CloudFormation templates provided in the setup/aws-lambda directory. Choose a name for your wrenderer setup, wrenderer-demo will be use as the ${Name} for demonstration purpose in this guide, you can replace it with your own setting.

Note: All CloudFormation stacks created in this guide should be in the same AWS region unless the step has specific region requirement.

Step 1 - Create ECR repository

Create ECR with template: setup/aws-lambda/wrenderer-img.yaml.
Choose CloudFormation template to create ECR

Specify stack name and parameters
Specify stack name and parameters for ECR

Stack name: ${Name}-img
Parameters:

Configure stack options: Keep the default options or change as required.

Review and create stack: Review the configuration and create the stack.

A stack with name ${Name}-img with status CREATE_COMPLETE should be seen in CloudFormation Stacks page once creation is complete.
img stack creation complete

Step 2 - Upload wrenderer image to ECR

Upload wrenderer docker image to ECR repository created in step 1. Push commands can be found in the ECR repository console page.
Push image to ECR repository

Step 3 - Create wrenderer function

Create environemnt resources with template: setup/aws-lambda/wrenderer-main.yaml.
Choose CloudFormation template to create wrenderer function

Specify stack name and parameters
Specify stack name

Stack name: ${Name}
Parameters:

Configure stack options: Keep the default options or change as required.

Review and create stack: Review the configuration and create the stack.

A stack with name ${Name} with status CREATE_COMPLETE should be seen in CloudFormation Stacks page once creation is complete.
main stack creation complete

Step 4 - Create ACM certificate

Generate SSL certificate in us-east-1 (N. Virginia) region for CloudFront distribution.

This step is required only if no certificate for the domain hosting wrenderer service exist in us-east-1 AWS Certificate Manager.

Set aws region: change region to us-east-1 (N. Virginia)
Set AWS region to us-east-1

Generate SSL certificate with template: setup/aws-lambda/wrenderer-acm.yaml.
Choose CloudFormation template to create ACM certificate

Specify stack name and parameters
Specify stack name and parameters for ACM

Stack name: ${Name}-acm
Parameters:

Configure stack options: Keep the default options or change as required.

Review and create stack: Review the configuration and create the stack.

DNS validation: CloudFormation will pause for DNS validation, set DNS record according to the value shown in events view and the progress will continue after the record is validated.
Set DNS record for certificate validation

A stack with name ${Name}-acm with status CREATE_COMPLETE should be seen in CloudFormation Stacks page once creation is complete.
acm stack creation complete

Step 5 - Create CloudFront distribution

Set aws region: change region to us-east-1 (N. Virginia)
Set AWS region to us-east-1

Create CloudFront distribution with template: setup/aws-lambda/wrenderer-cdn.yaml.
Choose CloudFormation template to create CloudFront distribution

Stack name: ${Name}-cdn
Specify name for cdn stack

Parameters:

Configure stack options: Keep the default options or change as required.

Review and create stack: Review the configuration and create the stack.

A stack with name ${Name}-cdn with status CREATE_COMPLETE should be seen in CloudFormation Stacks page once creation is complete.
cdn stack creation complete

Step 6 - Set DNS record

Get the domain name of the CloudFront distribution created in step 5 from the output WrendererDistributionDomain of the CloudFront stack and point your domain to this domain name with a CNAME record.
Set DNS record for wrenderer domain

Usage

Once DNS changes have propagated, wrenderer service should be accessible at the domain specified. You can start making requests to the API. Refer to the API documentation for available endpoints and usage.

Obtain api key from API Gateway console under API keys section. Obtaining api key

Middlewares

Add middleware to your application for forwarding bot requests to the wrenderer service.