Install and configure Scalr with Terraform on AWS
This template will install Scalr on multiple servers. Currently it sets up 6 servers
- Mysql Master and Slave with replication enabled
- influxDB
- Worker
- Proxy/App x 2
- AWS ELB created for the Proxies.
This template is configured as follows.
- Built for AWS
- Auto selects latest Canonical Ubuntu 18.04 LTS AMI for the chosen region
- Requires user to define VPC and Subnet mappings either in terraform.tfvars(.json) or via policy bindings in scalr-module.hcl (Scalr Next-gen, see https://scalr-athena.readthedocs-hosted.com/en/latest/details/variables.html#binding-to-policy)
- Scalr requires 4GB minimum of Ram. Instance type must be set in terraform.tfvars(.json) or via policy binding.
Below are descriptions on how to use this template in 3 possible modes.
- Locally
- Scalr Next-gen as the remote backend
- Scalr Next-Gen Service Catalog Offering
- Pull the repo.
- Upload your public key to AWS.
- Copy your Scalr license to ./license/license.json in the repo
- Copy your private ssh key to ./ssh/id_rsa in the repo
- Set values for the following variables in terraform.tfvars(.json) or provide values on the command line at runtime
region
- AWS Region to use.key_name
- Key in AWS.token
- Your packagecloud.io download token supplied with the license.vpc
- VPC to be used.subnet
- Subnet to be used.instance_type
- Must be 4GB ram. t3.medium recommended.name_prefix
- 1-3 character prefix to be added to all instance names.- Adjust scalr.ui.login_warning in
scalr_install_set_config.sh
to suit your needs. - Comment out the remote backend config block in
scalr-prod.tf
(terraform {......
). - Add your AWS access and secret keys to terraform.tfvars(.json), or enter them at the run time prompts. (scalr_aws_access_key, scalr_aws_secret_key)
- Run
terraform init;terraform apply
and watch the magic happen.
NOTE: SSH Key and Scalr license can either be provided via Files in the repo or through Variables in Scalr Next-Gen
- Pull the repo.
- Upload the public key to AWS.
- To provide the Scalr license via a file copy it to ./license/license.json in the repo
- To provide the SSH private key via a file copy it to ./shh/id_rsa in the repo
- Create a CLI workspace in Scalr Next-Gen and configure the backend to match in
scalr-prod.tf
. - Create an TF API token in Scalr Next-Gen and add it to
~/.terraformrc
. - In Scalr Workspace add Terraform variables and values as follows (note that terraform.tfvars(.json) in the template is not used with a remote backend).
region
- AWS Region to use.key_name
- Key in AWS.token
- Your packagecloud.io download token supplied with the license. Mark as "SENSITIVE".- To provide the license via variable:
license
- The full text of your Scalr license file. Mark as "SENSITIVE". - To provide the SSH private key via variable:
ssh_private_key
- The full text of you private key file in either PEM or PPK format. Mark as "SENSITIVE". vpc
- VPC to be used.subnet
- Subnet to be used.instance_type
- Must be 4GB ram. t3.medium recommended.name_prefix
- 1-3 character prefix to be added to all instance names.- Adjust scalr.ui.login_warning in
scalr_install_set_config.sh
to suit your needs. - Run
terraform init;terraform apply
and watch the magic happen.
In general follow the example here https://scalr-athena.readthedocs-hosted.com/en/latest/next-gen/service_catalog.html#service-catalog
For this specific template you need to do the following in Scalr
- Create Policies (scalr-module.hcl shows the policy bindings that are required)
- cloud.locations - Policy to limit the cloud locations (note this can be all locations but the policy must exist)
- cloud.networks - Create a policy for every location allowed in the cloud.locations policy.
- cloud.subnets - Create a policy for every location/network (vpc) combination that is allowed.
- cloud.instance_types - Restrict the instance types that are allowed. Minimum 4GB of ram.
- Create a Global Variable called
name_prefix_fmt
of type text with the REGEX^[A-Z0-9]{1,3}$
. - Fork or clone the Source repo (https://github.com/scalr-eap/scalr-install)
- Create the Service Catalog offering pointing to your copy repo
- Adjust scalr.ui.login_warning in
scalr_install_set_config.sh
to suit your needs. - Request the offering.