Infrastructure Foundation - Create the AWS infrastructure components that will host your self-hosted Relvy with proper security and networking.

Overview

This section guides you through creating the cloud infrastructure for Relvy self-hosting using AWS as an example. The core self-hosting setup requires an application server and database.

Routing Options

If you have a way to route a subdomain to your Relvy server (e.g., through your existing load balancer, reverse proxy, or direct DNS), you can skip the load balancer and SSL certificate setup. Otherwise, you’ll need to deploy an Application Load Balancer and obtain an SSL certificate for secure access.

Core Components (Required)

EC2 Instance

Self-hosted application with Docker containers

RDS Database

PostgreSQL database for application data

Optional Components (Production)

Application Load Balancer

Traffic distribution and SSL termination

SSL Certificate

Secure HTTPS communication

Step 1: Create Security Groups

Security groups act as virtual firewalls to control network access. We’ll create security groups for the required components, with optional groups for the load balancer setup.

1.1 ALB Security Group (Optional)

Navigate to EC2 Console → Security Groups → Create Security Group

FieldValue
Namerelvy-alb-sg
DescriptionLoad balancer security group for Relvy App
VPC[Your VPC]

Inbound Rules

TypeProtocolPortSourceDescription
HTTPTCP800.0.0.0/0HTTP redirect
HTTPSTCP4430.0.0.0/0HTTPS from internet

Outbound Rules

TypeProtocolPortDestinationDescription
HTTPTCP80[Will add app SG after creating]To app instances

Note - We’ll update the outbound rule destination after creating the app security group.

1.2 App Security Group

Navigate to EC2 Console → Security Groups → Create Security Group

FieldValue
Namerelvy-app-sg
DescriptionApplication server security group for Relvy App
VPC[Your VPC]

Inbound Rules

TypeProtocolPortSourceDescription
HTTPTCP80relvy-alb-sgFrom load balancer
SSHTCP22[Your IP]/32SSH access

Outbound Rules

TypeProtocolPortDestinationDescription
HTTPSTCP4430.0.0.0/0HTTPS outbound
HTTPTCP800.0.0.0/0Package downloads
DNSUDP530.0.0.0/0DNS resolution

1.3 Database Security Group

Navigate to EC2 Console → Security Groups → Create Security Group

FieldValue
Namerelvy-db-sg
DescriptionDatabase security group for Relvy
VPC[Your VPC]

Inbound Rules

TypeProtocolPortSourceDescription
PostgreSQLTCP5432relvy-app-sgDatabase access from application only

Outbound Rules

  • None (databases don’t need outbound access)

1.4 Update ALB Security Group

Now update the ALB security group’s outbound rule:

  1. Navigate to EC2 Console → Security Groups
  2. Select relvy-alb-sg
  3. Click Edit outbound rules
  4. Update the HTTP rule destination to relvy-app-sg

Step 2: Create Application Load Balancer (Optional)

If you have a way to route a subdomain to your Relvy server (as mentioned in the Routing Options above), you can skip this step. Otherwise, create a load balancer for production use.

Navigate to EC2 Console → Load Balancers → Create Load Balancer

2.1 Basic Configuration

FieldValue
Namerelvy-alb
SchemeInternet-facing
IP address typeIPv4

2.2 Network Configuration

FieldValue
VPC[Your VPC]
MappingsSelect 2 public subnets in different AZs
Security GroupsRemove default, Add relvy-alb-sg

2.3 Create Target Group

  1. Click “Create target group” (opens in new tab)
  2. Configure as follows:
FieldValue
Target typeInstances
Target group namerelvy-app-tg
ProtocolHTTP, Port: 80
VPC[Your VPC]
Health check path/health

Important - Don’t register targets yet. We’ll do this after creating the EC2 instance.

2.4 Configure Listener

FieldValue
ListenerHTTP:80
Default actionForward to relvy-app-tg

2.5 Review and Create

Review the configuration and create the ALB. Note down the ALB DNS name: relvy-app-alb-xxxxxxxxx.us-west-2.elb.amazonaws.com

Save This - You’ll need the ALB DNS name for domain configuration in the next step.

Step 3: Create EC2 Instance (Core Component)

This is the main application server. You can access Relvy directly through this instance if you don’t need a load balancer.

Navigate to AWS Console → EC2 → Instances → Launch Instance

3.1 Basic Configuration

FieldValue
Name and tagsName: relvy-app-ec2
Application and OS Images (AMI)Amazon Linux 2023 AMI (64-bit x86)

3.2 Instance Type

FieldValue
Instance familyGeneral purpose
Instance typet3.xlarge

3.3 Key Pair

Option A: Create new key pair

  1. Click Create new key pair
  2. Name: relvy-app-key
  3. Key pair type: RSA
  4. Private key format: .pem
  5. Click Create key pair and download

Option B: Use existing key pair

  • Select from dropdown if you already have one

Security - Keep your private key secure. You’ll need it to SSH into the instance.

3.4 Network Settings

FieldValue
VPC[Your VPC]
Subnet[Select a subnet in the same AZ as target group]
Auto-assign public IPEnable (for ssh)
Firewall (Security groups)Select existing security group relvy-app-sg

3.5 Storage Configuration

FieldValue
Root volume (gp3)Size: 100 GiB

3.6 Launch Instance

Review and launch the instance. Wait for it to reach the “Running” state.

3.7 Register with Load Balancer (Optional)

If you created a load balancer in Step 2:

  1. Navigate to EC2 → Target Groups
  2. Select your target group (relvy-app-tg)
  3. Click Register targets
  4. Select your new instance
  5. Port: 80
  6. Click Include as pending below → Register pending targets

If you’re not using a load balancer, you can access Relvy directly via the EC2 instance’s public IP address.

Step 4: Create RDS Instance

4.1 Create Database Instance

Navigate to RDS Console → Databases → Create database

4.1.1 Database Creation Method

  • Standard create (not Easy create)

4.1.2 Engine Options

FieldValue
Engine typePostgreSQL
VersionPostgreSQL 17.4-R2 (or latest)

4.1.3 Templates

  • Production (for best practices)

4.1.4 Settings

FieldValue
DB instance identifierrelvy-app-db
Master usernamepostgres
Master password[Generate strong password - save this securely]

Important - Save the database password securely. You’ll need it for application deployment configuration.

4.1.5 Instance Configuration

FieldValue
DB instance classdb.t3.medium (2 vCPU, 4 GB RAM)
Storage typeGeneral Purpose SSD (gp3)
Allocated storage50 GB
Storage autoscalingEnable
Maximum storage threshold200 GB

4.1.6 Connectivity

FieldValue
Connect to EC2 Compute ResourceSelect the EC2 instance we created (relvy-app-ec2)
DB subnet groupAutomatic setup
Public accessNo
VPC security groupsChoose existing → relvy-db-sg
Certificate authoritydefault

4.1.7 Database Authentication

  • Database authentication: Password authentication

4.1.8 Additional Configuration

FieldValue
Initial database namerelvydb
Enable Performance InsightsYes (optional)
Deletion protectionEnable

Database Name - The initial database name must be set to relvydb for the Relvy application to work correctly.

Wait for DB creation and note the endpoint.

4.2 Update App Security Group

Navigate to EC2 Console → Security Groups → relvy-app-sg

Add outbound rule:

  • Type: PostgreSQL, Port: 5432, Destination: relvy-db-sg, Description: Database access

Step 5: Verify Infrastructure

5.1 Check All Components

Verify all components are created and running:

ComponentStatus Check
Security GroupsApp and DB groups created with proper rules
EC2 InstanceInstance running (and registered with target group if using ALB)
RDS DatabaseDatabase available and accessible
Load BalancerALB running with target group (if created)

5.2 Test Connectivity

# Test SSH access to EC2
ssh -i relvy-app-key.pem ec2-user@<EC2_PUBLIC_IP>

# Test database connectivity (from EC2)
sudo yum install -y postgresql17
psql -h <RDS_ENDPOINT> -U postgres -d relvydb

Important Notes

Save These Details - Keep track of the following for the next steps:

  • RDS endpoint
  • Database username and password
  • EC2 IP for ssh
  • ALB DNS name (if created)

Next Steps

Your cloud infrastructure is now ready! The next steps are:

  1. Configure Domain - Set up DNS records and SSL certificate in Domain Configuration
  2. Setup Slack Integration - Create Slack app (optional) in Slack Setup
  3. Deploy Application - Install Docker and deploy Relvy in Application Deployment

Cost Alert - Your AWS resources are now running and incurring charges. Complete the deployment to start using Relvy.