From 9bdea37a86fa947a31f0eac40ace8448428753b0 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 13:40:17 +0100 Subject: [PATCH 01/15] mkdcs.yml: Add needed Markdown Extensions --- mkdocs.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index 2659d58..41882e4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -30,8 +30,15 @@ theme: repo: fontawesome/brands/github markdown_extensions: + - admonition - attr_list - md_in_html + - pymdownx.details + - pymdownx.emoji: + emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:materialx.emoji.twemoji + - pymdownx.superfences + - pymdownx.tabbed extra: social: From b8ee2c5cea99986d1b4458aa27671b6da06aab54 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 13:51:11 +0100 Subject: [PATCH 02/15] mkdocs.yml: Add needed extensions and delete not needed ones --- mkdocs.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index 41882e4..e83e602 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -32,12 +32,16 @@ theme: markdown_extensions: - admonition - attr_list + - codehilite - md_in_html - pymdownx.details - pymdownx.emoji: emoji_generator: !!python/name:materialx.emoji.to_svg emoji_index: !!python/name:materialx.emoji.twemoji - - pymdownx.superfences + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.snippets - pymdownx.tabbed extra: @@ -47,3 +51,4 @@ extra: nav: - Home: index.md + - Installation: installation.md From 0a5b029cf7bec636ea40bd2070bd0460c868153a Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 15:47:50 +0100 Subject: [PATCH 03/15] docs: Add installation.md --- docs/installation.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/installation.md diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..795b3c3 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,35 @@ +# Installation + +## Download the binaries and extract them + +All the binaries versions are available inside the [releases pages](https://github.com/angulo-solido/terrabutler/releases) + +To download the latest binaries run the following command: + +``` shell +wget -qO- https://terrabutler-public.s3.amazonaws.com/releases/terrabutler-linux-x86_64-latest.tar.gz | tar -zxvf - terrabutler +``` + +## Install the binaries + +To install the binaries into your system simply run the installer script inside the `terrabutler` folder: + +``` shell +sudo terrabutler/install +``` + +All the binaries will be placed inside the `/usr/share/terrabutler` folder and the bin inside the `/usr/bin` folder + +???+ tip + If you wanna set the location where terrabutler will be installed you can define it by passing arguments when running the install script. + This arguments can be seen by running: + + ``` + terrabutler/install -h + ``` + + Example of installing for local user only **(no need to run the install script as sudo)**: + + ``` + terrabutler/install -i ~/.local/share/terrabutler -b ~/.local/bin + ``` From e81324f6691e77aa9d1793d6402bb9aab69f62dc Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 15:54:27 +0100 Subject: [PATCH 04/15] docs: index.md: Add what is terrabutler --- docs/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/index.md b/docs/index.md index 928b345..574a5fd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,3 +11,10 @@ ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/angulo-solido/terrabutler/Release%20Terrabutler?color=8956c4&logo=Github&style=for-the-badge) ![GitHub](https://img.shields.io/github/license/angulo-solido/terrabutler?color=8956c4&logo=Github&style=for-the-badge) ![GitHub Repo stars](https://img.shields.io/github/stars/angulo-solido/terrabutler?color=8956c4&label=Repo%20Stars&style=for-the-badge) + +--- + +## What is Terrabutler? + +Terrabutler is a **wrapper** written in [Python](https://www.python.org/) that helps maintaining IaC (Infrastructure as code) projects +using [Terraform](https://www.terraform.io/) by managing the **environments**. \ No newline at end of file From c1d474cac9455ee18067e6d79727584001378e57 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 15:58:39 +0100 Subject: [PATCH 05/15] docs: installation.md: Add check if installation was successful --- docs/installation.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 795b3c3..59fe182 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -33,3 +33,20 @@ All the binaries will be placed inside the `/usr/share/terrabutler` folder and t ``` terrabutler/install -i ~/.local/share/terrabutler -b ~/.local/bin ``` + +## Check if the installation was successful + +You should be able to run: + +``` +terrabutler --version +``` + +and the output should be: + + +``` +Terrabutler: v0.1.0 +``` + +If the output is not similar to the one above, then **something went wrong during the installation**. From 6b361fddf28392cb4540ac68f329ff18f9de20f1 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:04:18 +0100 Subject: [PATCH 06/15] docs: installation.md: Add updating process --- docs/installation.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 59fe182..048d36a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -50,3 +50,15 @@ Terrabutler: v0.1.0 ``` If the output is not similar to the one above, then **something went wrong during the installation**. + +## How to update to a newer version? + +If you have **Terrabutler** already installed and want to update to a newer version just do all the installation process again. +When you will be running the installer script it should prompt if you want to upgrade the **Terrabutler**, as we can see below: + +``` +Found preexisting Terrabutler installation: /usr/share/terrabutler. +Do you want to replace it? [y/N] +``` + +Just press `y` and press *enter* and **Terrabutler** should be updated to the version that you downloaded. From a02d7adebd97b8bc725d97d52743d2df0d97da4b Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:14:24 +0100 Subject: [PATCH 07/15] mkdcos.yml: Add missing superfences markdown extension --- mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/mkdocs.yml b/mkdocs.yml index e83e602..30674c8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -42,6 +42,7 @@ markdown_extensions: anchor_linenums: true - pymdownx.inlinehilite - pymdownx.snippets + - pymdownx.superfences - pymdownx.tabbed extra: From 3e36a8bff9111b9a46c72f9db09cb6de06025407 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:14:45 +0100 Subject: [PATCH 08/15] docs: installation.md: Add missing shell declaration --- docs/installation.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 048d36a..937f981 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -24,13 +24,13 @@ All the binaries will be placed inside the `/usr/share/terrabutler` folder and t If you wanna set the location where terrabutler will be installed you can define it by passing arguments when running the install script. This arguments can be seen by running: - ``` + ``` shell terrabutler/install -h ``` Example of installing for local user only **(no need to run the install script as sudo)**: - ``` + ``` shell terrabutler/install -i ~/.local/share/terrabutler -b ~/.local/bin ``` @@ -38,14 +38,14 @@ All the binaries will be placed inside the `/usr/share/terrabutler` folder and t You should be able to run: -``` +``` shell terrabutler --version ``` and the output should be: -``` +``` shell Terrabutler: v0.1.0 ``` @@ -56,7 +56,7 @@ If the output is not similar to the one above, then **something went wrong durin If you have **Terrabutler** already installed and want to update to a newer version just do all the installation process again. When you will be running the installer script it should prompt if you want to upgrade the **Terrabutler**, as we can see below: -``` +``` shell Found preexisting Terrabutler installation: /usr/share/terrabutler. Do you want to replace it? [y/N] ``` From f8b21cf04673a8442c2298b9625568620d4dbfc6 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:16:53 +0100 Subject: [PATCH 09/15] docs: installation.md: Add tip for downloading specific version --- docs/installation.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 937f981..7450868 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -10,6 +10,20 @@ To download the latest binaries run the following command: wget -qO- https://terrabutler-public.s3.amazonaws.com/releases/terrabutler-linux-x86_64-latest.tar.gz | tar -zxvf - terrabutler ``` +???+ tip + If you wanna get a specific version just change the `` in the command below. All the **Terrabutler releases** are + available in the [repository releases pages](https://github.com/angulo-solido/terrabutler/releases) + + ``` shell + wget -qO- https://terrabutler-public.s3.amazonaws.com/releases/terrabutler-linux-x86_64-.tar.gz | tar -zxvf - terrabutler + ``` + + For example, to download **Terrabutler v0.1.0**, just run: + + ``` + wget -qO- https://terrabutler-public.s3.amazonaws.com/releases/terrabutler-linux-x86_64-v0.1.0.tar.gz | tar -zxvf - terrabutler + ``` + ## Install the binaries To install the binaries into your system simply run the installer script inside the `terrabutler` folder: From bf56b8164a36e5823dee72d2f60fa0ebf5e3117f Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:24:02 +0100 Subject: [PATCH 10/15] mkdocs.yml: Add requirements page --- docs/requirements.md | 19 +++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 20 insertions(+) create mode 100644 docs/requirements.md diff --git a/docs/requirements.md b/docs/requirements.md new file mode 100644 index 0000000..c91a944 --- /dev/null +++ b/docs/requirements.md @@ -0,0 +1,19 @@ +# Requirements + +Before you start using you will need to have some tools installed. + +- [direnv](https://direnv.net/) +- [tfenv](https://github.com/tfutils/tfenv) + +These tools are required to be installed for a **Terrabutler** to work properly. + +## Installing requirements + +In the list below you have the install instruction for each tool: + +- [direnv](https://direnv.net/docs/installation.html) +- [tfenv](https://github.com/tfutils/tfenv#installation) + +## After checking requirements + +You can now proceed to the [install](installation.md) process of **Terrabutler**. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 30674c8..f1b1264 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -52,4 +52,5 @@ extra: nav: - Home: index.md + - Requirements: requirements.md - Installation: installation.md From 6666066a145b1b1ad77f7d2debcc8374836ead71 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:26:09 +0100 Subject: [PATCH 11/15] docs: requirements.md: Fix typo --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index c91a944..4f18965 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -16,4 +16,4 @@ In the list below you have the install instruction for each tool: ## After checking requirements -You can now proceed to the [install](installation.md) process of **Terrabutler**. \ No newline at end of file +You can now proceed to the [installation](installation.md) process of **Terrabutler**. \ No newline at end of file From cf73afc8b605bbe021705500eedc42c5cf58fc5f Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:30:14 +0100 Subject: [PATCH 12/15] docs: installation.md: Add check for requirements --- docs/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 7450868..488604b 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,5 +1,7 @@ # Installation +Before proceeding make sure that you have the [requirements](requirements.md). + ## Download the binaries and extract them All the binaries versions are available inside the [releases pages](https://github.com/angulo-solido/terrabutler/releases) From 0ab6c384712cfdb07b6a77354263dedf6dc35203 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 16:32:05 +0100 Subject: [PATCH 13/15] docs: installation.md: Add danger for upgrading process --- docs/installation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 488604b..b56da14 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -78,3 +78,7 @@ Do you want to replace it? [y/N] ``` Just press `y` and press *enter* and **Terrabutler** should be updated to the version that you downloaded. + +???+ danger + In case you have installed the **Terrabutler** earlier with different locations, you will need to pass them, otherwise the + install script **won't prompt** you to update it. From ba64cce194823b19383b0061a279ca0d118ad113 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 17:57:55 +0100 Subject: [PATCH 14/15] docs: Add philosophy.md --- docs/philosophy.md | 22 ++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 23 insertions(+) create mode 100644 docs/philosophy.md diff --git a/docs/philosophy.md b/docs/philosophy.md new file mode 100644 index 0000000..8260be9 --- /dev/null +++ b/docs/philosophy.md @@ -0,0 +1,22 @@ +# Philosophy + +Before settling for **Terrabutler**, it's a good idea to understand the philosophy behind the project, +in order to make sure it aligns with your goals. This page explains the problem and the solution. + +## Problem + +All our IaC projects are backed by Terraform. Instead of having a folder with every resource, we have +created different folders that have resources from the same category, and we call them `sites`. For +example inside the `network site` we will have the creation of `VPC`, `SG` and `WAF`, so this site is +where we have all the resources related to network. By splitting the code into various `sites` we have +smaller plans and it's more easy to manage the code. By having all the code divided into various `sites` +it's a bit more difficult to manage all the terraform variable files. And we wanted all of this for each +**environment**, so it needs to be divided into different environments, for example production and development. +All of the `sites` state needs to be have a remote state and with a lock function, to prevent usage at the same +time. + +## Solution + +Create a IaC with the `inception site` that will be responsible to manage the project environments via Terraform +workspaces tool and where the backends for each site will be created. Use **Terrabutler** to manage all the IAC +between all the sites. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index f1b1264..3891ab9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -52,5 +52,6 @@ extra: nav: - Home: index.md + - Philosophy: philosophy.md - Requirements: requirements.md - Installation: installation.md From 2510c6713997948d45d758b91b0b5d9ce762c007 Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 6 Oct 2022 18:22:25 +0100 Subject: [PATCH 15/15] mkdocs.yml: Add Basic Usage --- docs/usage.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 94 insertions(+) create mode 100644 docs/usage.md diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..63f3e8f --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,93 @@ +# Basic Usage + +In this section we quickly cover the basic commands of **Terrabutler**. +The usage of it can always be seen by using the help menu inside of every +command or subcommand. + +Example: + +``` shell +terrabutler tf -site inception apply --help +``` + +The command above shows all the arguments and options that can be used when +running that command. + +## Usage + +``` shell +terrabutler [global options] command [subcommand] [arguments] [options] +``` + +## Global options + +All global options can be placed at the command level. + +* `--help`, `-help`, `-h`: Show help menu. +* `--version`, `-version`: Show version of **Terrabutler**. + +## Commands + +The commands are: + +- `env`: Manage environments +- `init`: Initialize the manager +- `tf`: Manage terraform commands + +### Command `env` + +Subcommands: + +- `delete`: "Delete an environment" +- `list`: "List environments" +- `new`: "Create a new environment" +- `select`: "Select a environment" +- `show`: "Show the name of the current environment" + +Example: + +``` shell +terrabutler env select staging +``` + +The command above change the current environment to `staging`. + +### Command `tf` + +???+ tip + The `tf` subcommands are the Terraform commands + +Subcommands: + +- `apply`: "Create or update infrastructure" +- `console`: "Try Terraform expressions at an interactive command..." +- `destroy`: "Prepare your working directory for other commands" +- `fmt`: "Reformat your configuration in the standardstyle" +- `force-unlock`: "Release a stuck lock on the current workspace" +- `generate-options`: "Generate terraform options" +- `import`: "Associate existing infrastructure with a Terraform..." +- `init`: "Prepare your working directory for other commands" +- `output`: "Show output values from your root module" +- `plan`: "Show changes required by the current configuration" +- `providers`: "Show the providers required for this configuration" +- `refresh`: "Update the state to match remote systems" +- `show`: "Show the current state or a saved plan" +- `state`: "Advanced state management" +- `taint`: "Mark a resource instance as not fully functional" +- `untaint`: "Remove the 'tainted' state from a resource instance" +- `validate`: "Validate the configuration files" +- `version`: "Show the current Terraform version" + +Example: + +``` shell +terrabutler tf -site inception apply +``` + +The command above run a `terraform apply` command inside the `site inception` in +the current environment. + +### Command `init` + +Has no subcommands + diff --git a/mkdocs.yml b/mkdocs.yml index 3891ab9..249ef4c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -55,3 +55,4 @@ nav: - Philosophy: philosophy.md - Requirements: requirements.md - Installation: installation.md + - Basic Usage: usage.md