A Screwdriver CD template that deploys an immutable instance of React-based frontend App
to AWS. It uses the screwdriver-template-main npm package to assist with template validation, publishing, and tagging.
This template tags the latest versions with the latest
tag.
Tip
React App release definition template is a satellite project of hashicorp-aws and more documentation can be found in its dedicated page for React App deployment support
Note
Before preceding, please note that it is assumed React App release definition template has already been installed in Screwdriver CD.
If not, please see documentation on publishing a template in Screwdriver
Create a Screwdriver pipeline that uses this template. Here is an example:
---
jobs:
main:
requires: [~pr, ~commit]
template: QubitPi/react-app-release-definition-template@latest
secrets:
- AWS_REACT_PKRVARS_HCL
- SSL_CERTIFICATE
- SSL_CERTIFICATE_KEY
- NGINX_CONFIG_FILE
- AWS_REACT_TFVARS
- DOT_ENV_FILE
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
The following Screwdriver Secrets needs to be defined before running this template:
-
AWS_REACT_PKRVARS_HCL - A HashiCorp Packer variable values file with the following variable values:
aws_image_region = "us-east-2" ami_name = "my-react-app-ami" instance_type = "t2.small" aws_react_ssl_cert_file_path = "ssl.crt" aws_react_ssl_cert_key_file_path = "ssl.key" aws_react_nginx_config_file_path = "nginx.conf" react_dist_path = "dist"
aws_image_region
is the image region of AWS AMIami_name
is the published AMI name; it can be arbitraryinstance_type
is the recommended AWS EC2 instance type running this image- Please keep the values of
react_dist_path
,aws_react_ssl_cert_file_path
,aws_react_ssl_cert_key_file_path
, andaws_react_nginx_config_file_path
as they are. They are used by template so that SSL configs are picked up from the right locations
-
AWS_REACT_TFVARS - A HashiCorp Terraform variable values file with the following variable values:
aws_deploy_region = "us-east-2" ami_name = "my-react-app-ami" instance_type = "t2.small" ec2_instance_name = "My React App" ec2_security_groups = ["My React App Security Group"] route_53_zone_id = "MBS8YLKZML18VV2E8M8OK" react_domain = "myapp.mycompany.com"
aws_deploy_region
is the EC2 runtime regionami_name
is the name of the published AMI; it must be the same as theami_name
in AWS_REACT_PKRVARS_HCLinstance_type
is the chosen AWS EC2 instance type at runtimeec2_instance_name
is the deployed EC2 name as appeared in the instance list of AWS console; it can be arbitraryec2_security_groups
is the AWS Security Group name (yes, not ID, but name...)react_domain
is the SSL-enabled domain that will serve the React Approute_53_zone_id
is the AWS Route 53 hosted Zone ID that hosts the domainmyapp.mycompany.com
Tip
To find the zone ID in AWS Route 53, we can:
- Sign in to the AWS Management Console
- Open the Route 53 console at https://console.aws.amazon.com/route53/
- Select Hosted zones in the navigation pane
- Find the requested ID in the top level Hosted Zones summary in the Route 53 section
The use and distribution terms for React App release definition template are covered by the Apache License, Version 2.0.