Vultr Terraform Guide
#
TerraformTerraform within the strapi-vultr-deploy template does the following:
- Uses the
vultr/vultr
andcloudflare/cloudflare
providers - Creates a DB Instance (Default type is
vc2-2c-4gb
) ~20$/month - Creates a Strapi Instance (Default type is
vc2-1c-2gb
) ~10$/month - Deploys a user provided SSH key to both instances
- Registers an A record for the Strapi instance on a subdomain in Cloudflare
- Automatically outputs an Ansible inventory file to the proper directory
- Automatically outputs an Ansible vars file to the proper directory
#
Terraform Requirementsinfo
You should have already configured Terraform, see the variables section before proceeding.
- Vultr API Key
- Cloudflare email
- Cloudflare API Key
- Cloudflare Zone ID for Domain
- Have a subdomain in mind (example:
api-test
) - Have an SSH public key (Doesn't currently support existing keys, yet)
- Terraform already installed
#
Terraform Instructions- Ensure you have configured the
terraform.tfvars
file per the variables guide - Navigate to the terraform directory and run
terraform init
(This will install the required providers - Run
terraform plan --out plan.txt
to get a summery of what terraform will do - If the plan looks good run
terraform apply plan.txt
and it will ask you to confirm, typeyes
- Let Terraform do it's thing, this might take a few minutes
- Validate that Terraform created the
./ansible/inventory
file - Validate that Terraform created the
./ansible/tf_vars/tf_vars.yml
file
Congrats, you just spun up the infrastructure, move on to Ansible to install the services and deploy your application.
#
Optional ModificationsBelow are some optional modifications you can make to your Terraform configuration for more secure storage.
#
Remote tfstate storageThe .tfstate
file is extremely important to Terraform as it maintains the state information of the deployed infrastructure. While it is possible to regenerate this file (not a fun task), you must keep this file safe as it contains sensitive information. Terraform has some great backend provider documentation for things like:
If you are interested in using Consul, they also currently have a free beta going on for their Consul Cloud.