SL-run-xx: Add Multitenancy to dev deployment #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview:
This pull request introduces multitenancy support for our application through the use of wildcard SSL certificates. These certificates are crucial in securely managing multiple subdomains under a specific domain, a necessity in a multitenant architecture.
We employ the Certbot plugin for Amazon Route53 to automate the DNS-01 challenge, streamlining the process of obtaining and renewing these wildcard certificates.
The key change in this setup is the switch from the generic Certbot Docker image to the Certbot/Route53 Docker image. This adjustment enables DNS-based validation via Route53 during the certificate issuance process, effectively automating the "_acme-challenge" procedure.
Setting up a Scalelite Development Environment with Multitenancy
Please note that the following guide is for users using the AWS suite.
Pre-requisites:
Steps:
1. Set up your EC2 instance:
Launch your EC2 instance and ensure that it has an IAM role attached with the AmazonRoute53FullAccess policy. This will allow the EC2 instance to make changes in the Route53 service.
Here are the steps to create an IAM role with AmazonRoute53FullAccess:
Now, you can assign this role to the EC2 instance running your application. When applications or services on this EC2 instance make AWS API requests, AWS will use the role's permissions to determine whether the request is allowed or denied.
2. Set up Docker and Docker Compose:
Ensure Docker and Docker Compose are installed on your EC2 instance. You'll be using Docker to run the Certbot container and Docker Compose to manage your Scalelite application services. You can follow the instructions from the Scalelite deployment guide to install Docker and Docker Compose.
3. Set up DNS:
Create a hosted zone in AWS Route53 for your domain (e.g., sl-dev.aws.blindside-dev.com). Then, add a wildcard DNS record (e.g., *.sl-dev.aws.blindside-dev.com) to this hosted zone.
4. Generate a wildcard SSL certificate with automatic DNS challenge:
For secure communication, Scalelite requires an SSL certificate. We are using Certbot's Route53 plugin to generate a wildcard SSL certificate. The plugin will automatically handle the ACME DNS challenge, creating and deleting the necessary DNS TXT records (_acme-challenge.yourdomain.com). It is crucial to generate a certificate for both the base domain and the wildcard domain to avoid SSL issues in the browsers.
Note: the first certificates have to be generated manually (by the docker command below). The renewal of the certificates should be automated.
Here's the Docker command to generate the original certificates:
In the above command, replace
yourdomain.com
with your actual domain and[email protected]
with your actual email address. The generated certificates will be stored in the $(pwd)/data/certbot/conf:/etc/letsencrypt directory on your host machine, which will be mounted into the Scalelite containers for secure communication.5. Set up your scalelite-run application:
Clone the scalelite-run application to your EC2 instance. Make sure the following variables are configured in your
.env
file:6. Run the scalelite-run application
docker-compose -f docker-compose-dev.yml up -d
7. Validate your setup:
You can now validate your setup by navigating to your domain in a web browser. You should confirm your Scalelite deployment with Multitenancy is working by accessing
yourdomain.com
and*.yourdomain.com
in your browser and seeing thesuccess
message.Remember, the details of these steps may vary depending on the specifics of your setup. If you are having issues, you can fall back on the Scalelite deployment guide.