-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from lucascanero/master
Add and update the documentation
- Loading branch information
Showing
5 changed files
with
248 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# Create a new project | ||
|
||
Before proceeding make sure that you have followed the [Installation](installation.md). | ||
|
||
## 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 | ||
|
||
```shell | ||
mkdir <project_name> | ||
``` | ||
|
||
### Download Template | ||
|
||
Start by downloading the Terrabutler Template Project from the repository source below: | ||
|
||
[![Version-shield]](https://github.com/lucascanero/terrabutler-template/archive/refs/heads/example-template.zip) | ||
|
||
Copy the files inside `./terrabutler-template/` to the root of your project folder. | ||
|
||
```shell | ||
$ cp -a /terrabutler-template/. /<project_name>/ | ||
``` | ||
|
||
### 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" | ||
|
||
```shell | ||
$ cd site_inception | ||
$ terraform workspace new staging | ||
``` | ||
|
||
### Change Variables | ||
|
||
Run the script `./<project_name>/config_template.sh`, with the following arguments, located inside the project folder root: | ||
|
||
```shell | ||
$ ./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: | ||
|
||
```shell | ||
$ tfenv install | ||
``` | ||
|
||
### Initialize the Project | ||
|
||
Perform an Terraform Initialization inside site_inception: | ||
|
||
```shell | ||
$ cd /site_inception/ | ||
$ terraform init | ||
``` | ||
Perform an Terraform Apply with the `.tfvars` inside `/config/variables/`: | ||
|
||
`./configs/variables/global.tfvars` </br> | ||
`./configs/variables/<project_name>-<environment_name>.tfvars"` </br> | ||
`./configs/variables/<project_name>-<environment_name>-inception.tfvars"`</br> | ||
|
||
```shell | ||
$ 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. | ||
|
||
``` | ||
backend "s3" {} | ||
``` | ||
|
||
Perform an Terraform initialization with the backend config file,located in `/configs/backend/` to update the new changes: | ||
|
||
```shell | ||
$ terraform init -backend-config=<inception_backend_path> | ||
``` | ||
|
||
???+ tip | ||
Example: | ||
$ terraform init -backend-config="./configs/backends/<project_name>-<environment_name>-inception.tfvars" | ||
|
||
#### Delete the local state | ||
|
||
Delete the local state in `/site_inception`, as it is not necessary: | ||
|
||
```shell | ||
$ rm -rf terraform.tfstate.d/ terraform.tfstate terraform.tfstate.backup | ||
``` | ||
|
||
### Terrabutler commands | ||
|
||
#### Terrabutler Plan | ||
|
||
Perform an Terrabutler Plan to ensure everything is ok, and plan any changes: | ||
|
||
```shell | ||
$ terrabutler tf -site inception plan | ||
``` | ||
#### Terrabutler Apply | ||
|
||
Perform an Terrabutler Apply to apply the planned changes: | ||
|
||
```shell | ||
$ terrabutler tf -site inception apply | ||
``` | ||
#### Terrabutler Destroy | ||
|
||
Perform an Terrabutler Destroy to delete or undo any changes made in the provider: | ||
|
||
```shell | ||
$ terrabutler tf -site inception destroy | ||
``` | ||
|
||
|
||
[Version-shield]: https://img.shields.io/badge/terrabutler_Template-Download-%23121011.svg?style=for-the-badge&logo=github&colorA=273133&colorB=0093ee "Latest version" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Add a new site | ||
|
||
## Create a new directory | ||
|
||
In the project folder root, create a new diretory called `site_<site-name>`: | ||
|
||
```shell | ||
$ mkdir site_<site-name> | ||
``` | ||
???+ tip | ||
Replace `<site-name>` with your new site name! | ||
|
||
## Configure the new site | ||
|
||
|
||
### Add the new site to `site_inception` variables file | ||
|
||
Add `<site-name>` to the following file, in `inception_projects = []` line: | ||
|
||
``` | ||
./configs/variables/<project>-<env>-inception.tfvars | ||
``` | ||
|
||
### Add the new site to Terrabutler settings | ||
|
||
Add `<site-name>` to the following file, in `sites: ordered: - <site-name>` line: | ||
|
||
``` | ||
./configs/settings.yml | ||
``` | ||
|
||
### Add a new variable file to the Variables Folder | ||
|
||
Create a new file called `<project-name>-<env>-<site-name>.tfvars` to the following directory: | ||
|
||
``` | ||
./configs/variables/<project-name>-<env>-<site-name>.tfvars | ||
``` | ||
|
||
### Perform an apply in `site_inception` | ||
|
||
Run the following command, to update the new configuration on `site_inception`: | ||
|
||
```shell | ||
$ terrabutler tf -site inception apply | ||
``` | ||
|
||
## Add files to the new site | ||
|
||
### Add terraform files | ||
|
||
Run the following commands to copy the following Terraform files to the site_`<site-name>`: | ||
|
||
```shell | ||
$ cd site_<site-name> | ||
``` | ||
|
||
```shell | ||
$ cp ../site_inception/terraform.tf . | ||
``` | ||
|
||
```shell | ||
$ cp ../site_inception/provider.tf . | ||
``` | ||
|
||
### Create Symbolic Links | ||
|
||
Run the following commands to create the Symbolic Links: | ||
|
||
```shell | ||
$ cd site_<site-name> | ||
``` | ||
|
||
```shell | ||
$ ln -s ../globals/data.tf ./data_global.tf | ||
``` | ||
```shell | ||
$ ln -s ../globals/locals.tf ./locals_globals.tf | ||
``` | ||
```shell | ||
$ ln -s ../globals/variables.tf ./variables_globals.tf | ||
``` | ||
### Perform an init in the new site | ||
|
||
Run the following command: | ||
|
||
```shell | ||
$ terrabutler tf -site data init | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters