Cloud Infrastructure
Running Smarter in production in the cloud requires some additional configuration and setup. Smarter currently support AWS as its sole cloud infrastructure provider. The project maintains a set of Terraform scripts to fully automate the deployment and management of all AWS infrastructure resources required for normal operation of the Smarter platform.
Official Smarter Terraform Scripts - https://github.com/smarter-sh/smarter-infrastructure.
See the README file in that repository for detailed instructions on how to use Terraform scripts to deploy and manage Smarter infrastructure on AWS. This set of Terraform scripts will store its state remotely in an AWS S3 bucket, and it will also enable state locking using AWS DynamoDB to prevent concurrent modifications to the infrastructure. See smarter-infrastructure/aws/terragrunt.hcl for more details.
Smarter’s Terraform scripts also use Terragrunt, a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules and managing remote state. It is highly recommended to use Terragrunt when working with the Smarter infrastructure Terraform scripts as this facilitates reuse of the Terraform modules across different environments (e.g., alpha, beta, next, production) and simplifies management of remote state files in S3.
Danger
THERE ARE COSTS ASSOCIATED WITH RUNNING CLOUD INFRASTRUCTURE. Be sure to review the AWS pricing documentation for each of the services that will be created by the Terraform scripts to understand the potential costs involved.
CREATING AND MANAGING CLOUD INFRASTRUCTURE IS MUCH MORE COMPLEX THAN SIMPLY DEPLOYING THE SMARTER APPLICATION ITSELF. It is assumed that the person using these Terraform scripts has a good understanding of AWS services, Terraform, and Terragrunt. If you are not familiar with these technologies, it is highly recommended to seek assistance from someone who is experienced in cloud infrastructure management before attempting to use these scripts.
Usage
To use the Terraform scripts, follow these steps:
Install the AWS CLI on your local machine. Follow the instructions at https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html.
Configure the AWS CLI with your credentials by running:
aws configure
Install Terraform on your local machine. Follow the instructions at https://learn.hashicorp.com/tutorials/terraform/install-cli.
Install Terragrunt on your local machine. Follow the instructions at https://terragrunt.gruntwork.io/docs/getting-started/install/.
Clone the smarter-infrastructure repository to your local machine.
git clone https://github.com/smarter-sh/smarter-infrastructure.git cd smarter-infrastructure/aws/prod
Initialize the Terraform working directory by running:
terragrunt initReview and customize the terragrunt.hcl configuration file to match your specific requirements.
Review the Terraform plan by running:
terragrunt planApply the Terraform configuration to create the necessary AWS resources by running:
terragrunt applyFollow the prompts to confirm the creation of resources.
Once the process is complete, Terraform will have created all the necessary AWS resources for running Smarter in production.
Resources Created
The Terraform scripts will create the following AWS resources:
AWS Certificate Manager (ACM) certificates for SSL/TLS encryption.
AWS Cloudfront distribution for content delivery.
AWS Elastic Container Registry (ECR) for storing Docker images.
AWS Identity and Access Management (IAM) roles and policies for secure access control.
AWS Route53 hosted zone(s) and DNS records for domain name resolution.
AWS Simple Email Service (SES) for sending transactional emails.
AWS Simple Storage Service (S3) buckets for storing static and media files.
Kubernetes cert-manager for managing SSL/TLS certificates within the Kubernetes cluster.
Kubernetes ingress resources for routing traffic to the Smarter application.
Kubernetes secrets for storing environment-specific sensitive information used for deployments such as database credentials, smtp credentials, and admin login credentials.
Kubernetes namespace for isolating Smarter resources within the Kubernetes cluster.