Merchant Center Custom Application
Deploy to AWS
This repository assists in deploying a Merchant Center Custom Application to AWS using Terraform.
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 configuredterraform
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:
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.
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.
Run the following command to build the production bundles with webpack:
$ yarn build
- Copy the
terraform
folder from this repository into your application. - Copy the
config
folder from this repository into your application.
- Edit
variables.tf
and edit the necessary variables - Edit
main.tf
and set the region and aws profile
If you don't already have a route53 hosted zone for your domain, create one now. Ensure that the DNS is configured properly.
- Login to AWS Console
- Select US East (N. Virginia) region (Need to obtain Global Cert for CloudFront)
- Request or Import SSL Certificate to your domain, wildcard at that domain level is acceptable
- Select Any suitable validation method (DNS or E Mail)
- 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.
$ yarn build
$ yarn compile-html
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
$ cd terraform
$ terraform init
$ terraform validate
$ terraform plan
$ terraform apply
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 the custom application within the Merchant Center.