Skip to content

Commit

Permalink
chore: update readme (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
nitesh-balla committed Feb 2, 2024
1 parent 4619272 commit cf03987
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 140 deletions.
108 changes: 56 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
# HyperSwitch Full Stack Deployment
# HyperSwitch Full Stack Deployment Guide

This project contains a script for deploying a full stack of HyperSwitch on AWS using the AWS Cloud Development Kit (CDK). The components installed by this script include:
This guide outlines the process for deploying a comprehensive HyperSwitch stack on AWS, leveraging the power and flexibility of the AWS Cloud Development Kit (CDK). Follow our step-by-step [installation instructions](#installation) to get HyperSwitch up and running efficiently.

- App Server
- Scheduler Services
- Admin Control Center
- Demo App with SDK Integration
- Card Vault
- Monitoring Services
- Automatically build and host SDK (Hyperloader.js)
- Jump Servers
## Table of Contents
- [Installation](#installation)
- [App Server](#app-server)
- [Scheduler Services](#scheduler-services)
- [Admin Control Center](#admin-control-center)
- [Demo App with SDK Integration](#demo-app-with-sdk-integration)
- [Card Vault](#card-vault)
- [Monitoring Services](#monitoring-services)
- [Automatically Build and Host SDK (Hyperloader.js)](#automatically-build-and-host-sdk)
- [Jump Servers](#jump-servers)
- [Image Builder](#image-builder)

### App Server
The cornerstone of the HyperSwitch architecture, the App Server facilitates backend operations. Built in Rust, HyperSwitch is an innovative, open-source payment switch offering a unified API for global payment ecosystem access in over 130 countries. [Learn more](https://github.com/juspay/hyperswitch).

### Scheduler Services
These services are responsible for the scheduling and execution of tasks, ensuring timely operations across the HyperSwitch stack.

### Admin Control Center
Manage and monitor your HyperSwitch environment with ease using the Admin Control Center, a unified dashboard for comprehensive control. [Learn more](https://github.com/juspay/hyperswitch-control-center).

### Demo App with SDK Integration
Explore the capabilities of HyperSwitch through our Demo App, which demonstrates the seamless integration of the HyperSwitch SDK.

### Card Vault
Our Card Vault provides a secure repository for storing sensitive card information, ensuring data safety and compliance.

### Monitoring Services
Dedicated to maintaining the health and performance of the HyperSwitch stack, these services ensure your system remains robust and reliable.

### Automatically Build and Host SDK (Hyperloader.js)
Hyperloader.js simplifies SDK deployment, offering automatic build and hosting capabilities for the HyperSwitch SDK. [Learn more](https://github.com/juspay/hyperswitch-web)

### Jump Servers
Enhance your security posture with Jump Servers, designed to provide secure access to the HyperSwitch stack.

## Installation

Expand Down Expand Up @@ -38,6 +65,7 @@ Before you can use this script, you need to have the following installed:

- Git
- Node.js and npm
- AWS account with Administrator access

You also need to have an AWS account and configure your AWS credentials.

Expand All @@ -62,11 +90,15 @@ export AWS_SESSION_TOKEN="<Your AWS_SESSION_TOKEN>" //optional

<details>
<summary><b>Install all the services provided by hyperswitch</b></summary>
<pre>sh install.sh</pre>
<pre>bash install.sh</pre>
</details>
<details>
<summary><b>Install only card vault as a seperate service</b></summary>
<pre>sh install-locker.sh</pre>
<pre>bash install-locker.sh</pre>
</details>
<details>
<summary><b>Install only Image builder as a seperate service</b></summary>
<pre>bash deploy_imagebuilder.sh</pre>
</details>
<details>
<summary><b>Standalone deployment script to deploy Hyperswitch on AWS quickly</b></summary>
Expand Down Expand Up @@ -102,51 +134,23 @@ curl https://raw.githubusercontent.com/juspay/hyperswitch-cdk/main/locker.sh | b
sh unlock_locker.sh
```

### More Information
# Image Builder (Outgoing and Incoming Proxy)

For more information about each component and the full stack deployment, please refer to the [HyperSwitch Open Source Documentation](https://opensource.hyperswitch.io/hyperswitch-open-source/deploy-hyperswitch-on-aws/deploy-app-server/full-stack-deployment).

### Support

If you encounter any issues or need further assistance, please create an issue in this repository.

### Todo
The imagebuilder component builds images for outgoing and incoming proxy(Squid and Envoy). Optionally you can choose to have hardened base image. You can buy the base image from [here](https://aws.amazon.com/marketplace/pp/prodview-53aklkzclj3wi?sr=0-1&ref_=beagle&applicationId=AWSMPContessa).

- [ ] Networking
- [x] VPC
- [ ] Subnets
- [ ] NAT
- [ ] Route Table
- [ ] IGW
- [ ] Load Balancers
- [ ] Auto Scaling Groups
- [ ] Launch Templates
- [ ] RDS
- [ ] ElastiCache
- [ ] S3
- [ ] EKS
- [ ] Service Endpoints
Currently supported platforms:
- Amazon Linux 2

### Decisions
## Deploying

- [ ] How should we have the subnet distribution?
1. Similar to how we currently have in production

### Subnet design
```bash
bash deploy_image_builder.sh
```

We can consist of 4 Subnets
### More Information

1. Public Incoming - (consisting of 1 subnet per AZ)
2. DMZ - (consisting of 1 subnet per AZ) (non-public)
3. Application - (consisting of 1 subnet per AZ) (isolated)
4. Storage Layer - (consisting of 1 subnet per AZ) (isolated)
5. Outbound - (consisting of 1 subnet per AZ) (connected to igw)
For more information about each component and the full stack deployment, please refer to the [HyperSwitch Open Source Documentation](https://opensource.hyperswitch.io/hyperswitch-open-source/deploy-hyperswitch-on-aws/deploy-app-server/full-stack-deployment).

#### Structure
### Support

- api-public (exist in 1)
- envoy (exist in 2)
- external jump (exists in 2)
- EKS exists in (3)
- Internal Jump (3)
- squid (4)
If you encounter any issues or need further assistance, please create an issue in this repository.
205 changes: 117 additions & 88 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,115 @@ padding="$(printf '%*s' $(( (term_width - box_width) / 2 )) '')"
box_line="$(printf '%*s' $box_width '')"
box_line="${box_line// /-}"

# Checking for AWS credentials
if [[ -z "$AWS_ACCESS_KEY_ID" || -z "$AWS_SECRET_ACCESS_KEY" || -z "$AWS_SESSION_TOKEN" ]]; then
display_error "Missing AWS credentials. Please configure the AWS CLI with your credentials."
exit 1
fi
# Function to display error messages in red
display_error() {
echo "${bold}${red}$1${reset}"
}

# Checking for AWS credentials
if [[ -z "$AWS_ACCESS_KEY_ID" || -z "$AWS_SECRET_ACCESS_KEY" || -z "$AWS_SESSION_TOKEN" ]]; then
display_error "Missing AWS credentials. Please configure the AWS CLI with your credentials."
echo
echo "${green}##########################################${reset}"
echo "${green} Installing Dependencies${reset}"
echo "${green}##########################################${reset}"
echo
# Function to display a simple loading animation
show_loader() {
local message=$1
local pid=$!
local delay=0.3
local spinstr='|/-\\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf "\r%s [%c] " "$message" "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
done
printf "\r%s [Done] \n" "$message"
}

# Check for Node.js
echo "Checking for Node.js..."
if ! command -v node &> /dev/null; then
echo "Node.js could not be found. Please install node js 18 or above."
exit 1
else
echo "${bold}${green}AWS credentials detected successfully.${reset}"
fi

# Trying to retrieve AWS account owner's details
if ! AWS_ACCOUNT_DETAILS_JSON=$(aws sts get-caller-identity 2>&1); then
display_error "Unable to obtain AWS caller identity: $AWS_ACCOUNT_DETAILS_JSON"
display_error "Check if your AWS credentials are expired and you have appropriate permissions."
# Verify Node.js version
version=$(node -v | cut -d'.' -f1 | tr -d 'v')
if [ "$version" -lt 18 ]; then
echo "Invalid Node.js version. Expected 18 or above, but got $version."
exit 1
fi
echo "Node.js version is valid."


# Extracting and displaying account details
AWS_ACCOUNT_ID=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.Account')
AWS_USER_ID=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.UserId')
AWS_ARN=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.Arn')
AWS_ROLE=$(aws sts get-caller-identity --query 'Arn' --output text | cut -d '/' -f 2)
# Install AWS CDK
echo "Installing AWS CDK..."
npm install -g aws-cdk & show_loader "Installing AWS CDK..."
echo "AWS CDK is installed successfully."

# Check for AWS CDK
if ! command -v cdk &> /dev/null; then
echo "AWS CDK could not be found. Please rerun 'bash install.sh' with Sudo access and ensure the command is available within the \$PATH"
exit 1
fi

# Determine OS and run respective dependency script
os=$(uname)
case "$os" in
"Linux")
echo "Detecting operating system: Linux"
(bash linux_deps.sh & show_loader "Running Linux dependencies script...")
;;
"Darwin")
echo "Detecting operating system: macOS"
(bash mac_deps.sh & show_loader "Running macOS dependencies script...")
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac

# Check if AWS CLI installation was successful
if ! command -v aws &> /dev/null; then
echo "AWS CLI could not be found. Please rerun 'bash install.sh' with Sudo access and ensure the command is available within the $PATH"
exit 1
fi

echo "Dependency installation completed."


fetch_details(){
# Trying to retrieve AWS account owner's details
if ! AWS_ACCOUNT_DETAILS_JSON=$(aws sts get-caller-identity 2>&1); then
display_error "Unable to obtain AWS caller identity: $AWS_ACCOUNT_DETAILS_JSON"
display_error "Check if your AWS credentials are expired and you have appropriate permissions."
exit 1
fi

# Extracting and displaying account details
AWS_ACCOUNT_ID=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.Account')
AWS_USER_ID=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.UserId')
AWS_ARN=$(echo "$AWS_ACCOUNT_DETAILS_JSON" | jq -r '.Arn')
AWS_ROLE=$(aws sts get-caller-identity --query 'Arn' --output text | cut -d '/' -f 2)
}

show_loader "Fetching AWS account details" &
fetch_details

# Waiting for the fetch_details background process to complete
wait

# Check if fetch_details exited with an error
if [ $? -ne 0 ]; then
echo "Error fetching AWS details. Exiting script."
exit 1
fi

# Function to print a line with padding
print_line() {
Expand Down Expand Up @@ -68,6 +152,23 @@ while true; do
esac
done

# Function to display the header
echo "Checking dependencies..."

# Check for Node.js
if ! command -v node &> /dev/null; then
echo "Node.js could not be found. Please install node js 18 or above."
exit 1
fi

# Verify Node.js version
version=$(node -v | cut -d'.' -f1 | tr -d 'v')
if [ "$version" -lt 18 ]; then
echo "Invalid Node.js version. Expected 18 or above, but got $version."
exit 1
fi
echo "Node.js version is valid."

# Function to display the header
display_header() {
print_line "###########################################"
Expand Down Expand Up @@ -126,7 +227,7 @@ if [[ -z "$AWS_DEFAULT_REGION" ]]; then
echo "Please enter the AWS region to deploy the services: "
read -r AWS_DEFAULT_REGION
else
echo "Please enter the AWS region to deploy the services (Press enter to keep the current region $blue$bold$AWS_DEFAULT_REGION$reset): "
echo "Please enter the AWS region to deploy the services (Press enter to continue with the current region $blue$bold$AWS_DEFAULT_REGION$reset): "
read -r input_region
if [[ -n "$input_region" ]]; then
AWS_DEFAULT_REGION=$input_region
Expand Down Expand Up @@ -168,82 +269,10 @@ function echoLog() {
echo "$1" | tee -a $LOG_FILE
}

echo
echo "${blue}##########################################${reset}"
echo "${blue} Installing Dependencies${reset}"
echo "${blue}##########################################${reset}"
echo
# Function to display a simple loading animation
show_loader() {
local message=$1
local pid=$!
local delay=0.3
local spinstr='|/-\\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf "\r%s [%c] " "$message" "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
done
printf "\r%s [Done] \n" "$message"
}

# Check for Node.js
echo "Checking for Node.js..."
if ! command -v node &> /dev/null; then
echo "Node.js could not be found. Please install node js 18 or above."
exit 1
fi

# Verify Node.js version
version=$(node -v | cut -d'.' -f1 | tr -d 'v')
if [ "$version" -lt 18 ]; then
echo "Invalid Node.js version. Expected 18 or above, but got $version."
exit 1
fi
echo "Node.js version is valid."


# Install AWS CDK
echo "Installing AWS CDK..."
npm install -g aws-cdk & show_loader "Installing AWS CDK..."
echo "AWS CDK is installed successfully."

# Check for AWS CDK
if ! command -v cdk &> /dev/null; then
echo "AWS CDK could not be found. Please rerun 'bash install.sh' with Sudo access and ensure the command is available within the \$PATH"
exit 1
fi

# Determine OS and run respective dependency script
os=$(uname)
case "$os" in
"Linux")
echo "Detecting operating system: Linux"
(bash linux_deps.sh & show_loader "Running Linux dependencies script...")
;;
"Darwin")
echo "Detecting operating system: macOS"
(bash mac_deps.sh & show_loader "Running macOS dependencies script...")
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac

# Check if AWS CLI installation was successful
if ! command -v aws &> /dev/null; then
echo "AWS CLI could not be found. Please rerun 'bash install.sh' with Sudo access and ensure the command is available within the $PATH"
exit 1
fi

echo "Dependency installation completed."

echo
echo "${blue}##########################################${reset}"
echo "${blue} Checking neccessary permissions${reset}"
echo "${blue}##########################################${reset}\n"
echo "${blue}##########################################${reset}"
echo

check_root_user() {
Expand Down

0 comments on commit cf03987

Please sign in to comment.