A simple CCA (ColdBox Cloud Application) template
Go to this link to sign up and create an account on Digital Ocean.
Requires Microsoft Windows 10 Professional or Enterprise 64-bit link. For previous versions get Docker Toolbox link.
Go to this link and download the Terraform Binary and place it on your path.
Generate a Personal Access Token via the DigitalOcean control panel. Instructions to do that can be found in this link. Terraform will use this token to authenticate to the DigitalOcean API, and control your account.
To use SSH keys with your Droplets, you need to create an SSH key and import your SSH public key into DigitalOcean.
Follow this tutorial to do it. You can run this code in Git Bash ssh-keygen -t rsa -b 4096
git clone [email protected]:murpg/cca-simple.git
Clone the git project and run box install inside the /cca-simple/app folder this will pull all of your dependencies. If you do not know how to run box install it means you are not using CommandBox. You can go to this tutorial to learn how to use CommandBox.
Terraform allows you to override variables used for deployments. Copy terraform.tfvars.sample
to terraform.tfvars
file and adjust variables or comment with a hash mark (#).
admin_allowed_ip_list
: An array of a list of strings for allowed IPs that can get admin access.["127.0.0.1", "0.0.0.0"]
application_allowed_ip_list
: An array of a list of strings for allowed IPs that can get application access.["2.2.2.2", "4.4.4.4"]
admin_password
: Plain text admin password.do_token
: required Your DigitalOcean Personal Access Token.droplet_image
: The Droplet image ID.droplet_region
: The region to start in.droplet_size
: The instance size to start.ssh_key_fingerprint
: required Fingerprint of your SSH public key.ssh_private_key
: required Private SSH key location, so Terraform can connect to new droplets.
CLI option | Environment variable | Default |
---|---|---|
admin_allowed_ip_list |
TF_VAR_admin_allowed_ip_list |
["127.0.0.1"] |
application_allowed_ip_list |
TF_VAR_application_allowed_ip_list |
["all"] |
admin_password |
TF_VAR_admin_password |
commandbox |
do_token |
TF_VAR_do_token |
- |
droplet_image |
TF_VAR_droplet_image |
docker-16-04 |
droplet_region |
TF_VAR_droplet_region |
nyc3 |
droplet_size |
TF_VAR_droplet_size |
s-2vcpu-4gb |
ssh_key_fingerprint |
TF_VAR_ssh_key_fingerprint |
- |
ssh_private_key |
TF_VAR_ssh_private_key |
- |
Terraform makes it possible to create and destroy your ColdBox application in the cloud. First, initialize Terraform for the project. This will read all configuration files and install needed plugins.
$ terraform init
You can check the correctness of your code (e.g. missing values for variables) with:
$ terraform validate
To build your infrastructure and deploy your ColdBox application on DigitalOcean just run.
$ terraform apply
One of the amazing things about CCA application is that it handles the entire lifecycle of the stack. You can easily destroy what you have built by running one simple Terraform command (destroy).
$ terraform destroy