Create a new project
Before proceeding make sure that you have followed the Installation.
Configure direnv
For direnv to work properly it needs to be hooked into the shell. Check direnv docs to know more: https://direnv.net/docs/hook.html
Make sure that you have followed direnv documentation before proceeding.
Configure Terrabutler
Create your project folder
Download Template
Start by downloading the Terrabutler Template Project from the repository source below:
Copy the files inside ./terrabutler-template/
to the root of your project folder.
Create a new workspace
Before configuring terrabutler, inside <project_name>/site_inception
folder, you will need to create a Terraform Workspace:
For example, we are gonna call it "staging"
Change Variables
Run the script ./<project_name>/config_template.sh
, with the following arguments, located inside the project folder root:
$ ./config_template.sh -d <domain> -e <environment_name> -p <project_name>
USAGE:
./config_template [FLAG] [STRING]
FLAGS:
-o <organization_name> The name for your organization.
Example: -o example
-d <domain> The domain of your organization.
Example: -d example.com
-e <environment_name> The environment name of your organization.
Example: -e staging
Danger
This script only works with the template folder! Don't use it in another project folders!
./terrabutler-template/config_template.sh
Terraform
Start by installing Terraform with tfenv:
Initialize the Project
Perform an Terraform Initialization inside site_inception:
Perform an Terraform Apply with the.tfvars
inside /config/variables/
:
./configs/variables/global.tfvars
./configs/variables/<project_name>-<environment_name>.tfvars"
./configs/variables/<project_name>-<environment_name>-inception.tfvars"
$ terraform apply -var-file="../configs/variables/global.tfvars" -var-file="../configs/variables/<project_name>-<environment_name>.tfvars" -var-file="../configs/variables/<project_name>-<environment_name>-inception.tfvars"
Change local to remote backend
Uncomment the remote backend line
Remove the commented line as below, in the terrabutler-template
in the path ./site-inception/terraform.tf
to change from local to remote.
Perform an Terraform initialization with the backend config file,located in /configs/backend/
to update the new changes:
Tip
Example:
$ terraform init -backend-config="./configs/backends/
Delete the local state
Delete the local state in /site_inception
, as it is not necessary:
Terrabutler commands
Terrabutler Plan
Perform an Terrabutler Plan to ensure everything is ok, and plan any changes:
Terrabutler Apply
Perform an Terrabutler Apply to apply the planned changes:
Terrabutler Destroy
Perform an Terrabutler Destroy to delete or undo any changes made in the provider: