Deploying Reaction Commerce 3 on AWS ECS Tutorial
-
To run Reaction Commerce locally download repository -> Reaction Commerce Repository
-
You will need the following tools installed on your computer:
- You need to register on platrofrms:
- Also AWS or external domain is needed!
- Create MongoDB cluster on MongoDB Atlas and connect it with AWS
- Create Hydra PostgreSQL database
- Build Docker images and push them to ECR
- Setup Load Balancers
- Setup ECS cluster
- Deploy Reaction Commerce API (backend)
- Deploy Hydra's API
- Deploy Identity API
- Deploy Admin panel
- Deploy Storefront
atlas_mongo_public_key => MongoDB Atlas API public_key which should be created by user > Go to MongoDB Atlas account > Projects > Access Manager > Api Keys tab > Create API Key or select existing
atlas_mongo_private_key => Same section as above
atlas_org_id => Go to MongoDB Atlas account > Select Settings Icon > Settings > Copy Organization ID
mongo_user_name = Your MongoDB user name
mongo_user_password = Your MongoDB password
mongo_database_name = "reaction"
mongo_local_database_name = "local"
Variables in the file mongo.tf:
-
cidr_block=> Go to MongoDB Atlas account > Projects > Select Project > Network Access > IP Whitelist tab > Copy existing address or create new ("0.0.0.0/0" allows connection from any IP) -
atlas_cidr_block=> Go to MongoDB Atlas account > Projects > Select Project > Network Access > Peering tab > Add Peering Connection or Select existing > For new Peering Connection Select aws > copy VPC CIDR
aws_account_id => Go to AWS Console > Select 'My Account' (top dropdown mentu for current user) > Copy 'Account Id'
Variables in the file vpc.tf:
-
cidr_block- for resource "aws_vpc" => Go to AWS Console > Services > VPC > Your VPCs (left menu) > Select 'IPv4 CIDR' field for specific VPC
- for each resource "aws_subnet" => for subnets replace /16 with /24 and set different IP for each subnet (example: "0.0.10.0/24", "0.0.20.0/24", "0.0.30.0/24")
-
destination_cidr_block- for each resource "aws_route" "...-gateway" => "0.0.0.0/0"
- for each resource "aws_route" "...-mongo" => Go to MongoDB Atlas account > Projects > Select Project > Network Access > Peering tab > Add Peering Connection or Select existing > For new Peering Connection Select aws > copy VPC CIDR
Additional variable - always when AWS region is mentioned:
aws_region => Name of the AWS region selected by user in AWS console (e.x. "eu-central-1")
stripe_secret_key => your Stripe API secret key
- stripe Log in > Dashboard > Developers > API keys > Create secret key or use existing Secret key
ocid_subject_identifiers_pairwise_salt => Generate ocid subject identifier
secret_system => Generate session secret
oauth2_client_secret => Generate oauth client secret
session_secret => Generate session secret (different from OAUTH2_CLIENT_SECRET)
stripe_public_api_key => your Stripe API public key
- stripe Log in > Dashboard > Developers > API keys > Create secret key or use existing Publishable key
domain_name => http://yoursite.com
postgres_identifier = "hydra" (Set itentifier - can be the same as database name)
postgres_database_name = "hydra"
postgres_username = "postgres"
postgres_password => Set database unique password
postgres_instance_name => Unique name cross all DB instances owned by current AWS account
postgres_db_password => Generate password
postgres_port => Default port for PostgreSQL: 5432
admin_repo_path => External; In our case: "User//projects//reaction-admin"
backend_repo_path => External; In our case: "User//projects//reaction"
identity_repo_path => External; In our case: "User//projects//reaction-identity"
hydra_repo_path => External; In our case: "User//projects//reaction-hydra"
storefront_repo_path => External; In our case: "User//projects//reaction-storefront"
local-exec commands > Get commands to build docker images based on each repository > Go to AWS Console > Services > ECR > Select repository > View push commands
AWS
AWS Working with VPCs and subnets
Redirects with AWS ALB using terraform
Terraform
Terraform Environment Variables
Terraform Resources
aws_lb (Application Load Balancer)
mongodbatlas_network_container
Terraform Data Source
Other
HOW TO CREATE A VPC WITH TERRAFORM
Setup a Container Cluster on AWS with Terraform