Coder Social home page Coder Social logo

amahaveer / commercetools-custom-application-aws-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from commercetools/commercetools-custom-application-aws-starter

0.0 0.0 0.0 64 KB

Guide to deploying a Custom Application to AWS with Terraform.

JavaScript 19.01% HCL 80.99%

commercetools-custom-application-aws-starter's Introduction

commercetools logo Merchant Center Custom Application
Deploy to AWS

ย 

This repository assists in deploying a Merchant Center Custom Application to AWS using Terraform.

High-level Architecture Diagram

infrastructure

Prerequisite

Make sure you have the latest version of the following before deploying. (Or Your CI Platform is ready)

  • node.js
  • npm
  • yarn
  • aws cli - installed and configured
  • terraform
  • git
  • The DNS Domain of Your Site (With edit rights to DNS Records)

You should already have a Merchant Center Custom Application built. Follow the getting started guide to install the starter template. You should have already completed the following steps:

Adjust the cloud identifier

The custom-application-config.json is configured to use the HTTP APIs in the GCP-EU region. If you plan to run the Custom Application in another environment, change the cloud identifier accordingly.

Adjust the configuration for production

The custom-application-config.json has a env.production configuration object. When you're ready to deploy the application to production, make sure to provide the URL where the Custom Application is hosted.

Build the production bundles

Run the following command to build the production bundles with webpack:

$ yarn build

Steps to Deploy

Copy files

  • Copy the terraform folder from this repository into your application.
  • Copy the config folder from this repository into your application.

Set Terraform Variables

  • Edit variables.tf and edit the necessary variables
  • Edit main.tf and set the region and aws profile

Verify Route53

If you don't already have a route53 hosted zone for your domain, create one now. Ensure that the DNS is configured properly.

Obtain Certificate

  1. Login to AWS Console
  2. Select US East (N. Virginia) region (Need to obtain Global Cert for CloudFront)
  3. Request or Import SSL Certificate to your domain, wildcard at that domain level is acceptable
  4. Select Any suitable validation method (DNS or E Mail)
  5. Note down the issued certificate . (It can take few minutes to get it issued)

* Note: This step can be automated using Terraform, but AWS can take up to 30 mins to issue a new cert and validation could take even longer. The delay can create problems for the terraform module deployment.

Build the Resources

Build the Custom Application

$ yarn build
$ yarn compile-html

Generate the Lambda Function

You can compile manually with the command:

$ npx mc-scripts compile-html --transformer  config/transformer-aws.js

Or add it to your package.json for future use:

  "scripts": {
    "compile-html:aws": "NODE_ENV=production dotenv -- mc-scripts compile-html --transformer  $(pwd)/config/transformer-aws.js",
  }
$ yarn compile-html:aws

Deploy the Infrastructure

$ cd terraform
$ terraform init
$ terraform validate
$ terraform plan
$ terraform apply

Copy the complied application to the newly created bucket.

aws s3 cp --recursive --acl public-read public/ s3://<spa-app-bucket-name>/

* Tip: aws s3 sync can be used for updating the application

Register

Register the custom application within the Merchant Center.

commercetools-custom-application-aws-starter's People

Contributors

jluterek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.