Welcome to our open-source project Biostasis! This guide will help you set up your own cloud infrastructure using various AWS services. Also, it will help you setup the external services that we use for our application.
By following the steps outlined below, you'll be able to create an environment similar to the one used in our project.
PS: if you do not have an experience in AWS and want to contribute to the project send an email to emil@havetomorrow.com. we will consider providing you with the credentials needed to run the application.
Make sure you have the following:
-
An AWS account: You will need an AWS account to create and manage your cloud infrastructure.
-
AWS CLI: Install the AWS Command Line Interface (CLI) on your local machine. You can find installation instructions Here.
-
Backend Repository: Clone the backend repository of the project to access the required Docker images for ECR. You can find the repository Here.
you may ask yourself: Why you need to build your own cloud infrastructure and external services?
we need those services to run our project and create the .env
credentials for the FrontEnd and BackendEnd applications to fully understand and test the whole functionality of our project.
However, You can also surpass those steps, but then you need to modify the code and the .env
credentials to be able to run the project properly.
Follow the steps below to set up your cloud infrastructure:
We will create two Linux instances: one for SSH hosting and another for deep links.
-
Launch two EC2 instances using the AWS Management Console or the AWS CLI. Make sure to select the appropriate Linux image.
-
Secure Shell (SSH) Host: Use this instance for administrative tasks and SSH access to other instances.
-
Deep Links: This instance is responsible for handling deep links functionality in our project.
Set up an RDS instance to host the MySQL database.
-
Use the AWS Management Console or CLI to create an RDS instance. Choose the appropriate instance type and storage options.
-
Configure the database settings, including username, password, and database name.
Create an Elasticache cluster to host the Redis service used in our project.
-
Use the AWS Management Console or CLI to create an Elasticache cluster.
-
Choose Redis as the caching engine and configure the necessary settings.
We utilize Google and Apple for authorization and authentication services through Cognito. Follow these steps to set up Cognito with the required providers:
-
Access the AWS Management Console and create a Cognito User Pool.
-
Configure the user pool settings, including identity providers such as Google and Apple.
Set up an SES domain to host the email address domain used in our project.
-
Use the AWS Management Console to create an SES domain.
-
Configure the necessary email settings and verify the domain.
Create an AWS Lambda function to handle the email structure for our Cognito services.
-
Use the AWS Management Console or CLI to create a Lambda function.
-
Implement the necessary logic for handling Cognito-related email workflows.
Host the application Docker images in the Elastic Container Registry (ECR).
-
Access the AWS Management Console or use the CLI to create an ECR repository.
-
Push your Docker images to the ECR repository, which you can find in the backend repository.
Create tasks and services in the Elastic Container Service (ECS) to deploy your Docker images from ECR.
-
Use the AWS Management Console or CLI to create an ECS cluster.
-
Define the necessary task definitions and services to deploy your Docker images.
Set up a CloudFront distribution to create a public key pair.
-
Use the AWS Management Console or CLI to create a CloudFront distribution.
-
Configure the distribution settings and generate the required public and private key pair.
Create an S3 bucket to store user-uploaded files.
-
Use the AWS Management Console or CLI to create an S3 bucket.
-
Configure the bucket settings, including permissions and access control
Assign an Elastic IP to access the EC2 instance hosting the backend application.
-
Use the AWS Management Console or CLI to allocate an Elastic IP.
-
Associate the Elastic IP with the EC2 instance running the backend application.
Set up an Elastic Load Balancer to host your backend application inside the EC2 instance.
-
Use the AWS Management Console or CLI to create an Elastic Load Balancer.
-
Configure the load balancer settings and specify the backend EC2 instance as the target.
Use Route53 to redirect traffic to your cloud infrastructure.
-
Access the AWS Management Console and create a Route53 hosted zone.
-
Configure the necessary DNS settings to redirect traffic to your cloud infrastructure.
Set up a Virtual Private Cloud (VPC) to connect all the cloud services in one network.
-
Use the AWS Management Console or CLI to create a VPC.
-
Configure the necessary subnets, route tables, and security groups.
Obtain an ACM certificate to certify the domain name used to host the backend.
-
Use the AWS Management Console or CLI to request an ACM certificate.
-
Configure the certificate settings and verify domain ownership.
In addition to the cloud infrastructure, our open-source project requires the integration of external services to enable certain functionalities. This section will guide you through the process of setting up the following external services: Mailjet for email templates and Twilio for sending SMS messages to users.
Mailjet is used to create transactional email templates for specific purposes within our project. Follow the steps below to set up Mailjet and configure the required email templates:
-
Sign up for a Mailjet account at https://www.mailjet.com/ if you don't have one already.
-
Once logged in to your Mailjet account, navigate to the "Transactional Email" section.
-
Create a new transactional email template for each of the following purposes:
a. User Change Email: This template should be used when a user changes their email address.
b. Emergency Message without Location: This template should be used to send an email when a user reports an emergency situation without providing location data.
c. Emergency Message with Location: This template should be used to send an email when a user reports an emergency situation with location data.
d. Data Export: This template should be used to send an email containing exported user data for compliance with GDPR regulations.
-
Customize each template according to the project's requirements. You can use the Mailjet template editor to design the email content and incorporate dynamic variables as needed.
-
Make note of the template IDs or any other necessary credentials provided by Mailjet, as you will need them for the integration with the project.
Twilio is used to send SMS messages to users. To set up Twilio for our project, follow these steps:
-
Sign up for a Twilio account at https://www.twilio.com/ if you don't have one already.
-
Once you have logged in to your Twilio account, navigate to the console.
-
Obtain your Account SID and Auth Token from the Twilio dashboard. These will be used for authentication when making API requests.
-
To send SMS messages, you will need to have a Twilio phone number. You can either purchase a new number or use an existing one.
-
Make sure you have the Twilio SDK or client library installed in your project, depending on your programming language of choice. Refer to the Twilio documentation for detailed instructions on integrating Twilio into your project.
-
Implement the necessary logic in your project to utilize the Twilio API and send SMS messages to users.
That's it! You have now successfully set up the external services required for our open-source project. Make sure to configure the necessary credentials and endpoints within your project code to enable the integration with Mailjet for email templates and Twilio for sending SMS messages to users.
Congratulations! You have successfully set up your own cloud infrastructure using various AWS services. In addition, you setup Mailjet and Twilio to be able to send emails and sms messages.
You can now start using the infrastructure for the project and make any necessary customizations. If you encounter any issues or have any questions, refer to the documentation or add your question on the discussion page of this repository.
Thank you for contributing to the Biostasis project!