Optimize Your Cloud Engineering Workflow

post thumb
Aws
by W. van der Toorren/ on 19 Jul 2024

Optimize Your Cloud Engineering Workflow

As a cloud engineer, efficiency is paramount in my work. The use of tools plays a crucial role in achieving this. Often, I deal with complex tasks and long commands that can be time-consuming if executed manually each time. Tools help automate these processes, allowing me to focus on more important tasks.

Efficiency Through Automation At TechNative, we build environments in AWS using Terraform. The code is stored in a mono-repo, organized into domains (e.g., prod/non-prod) and various stacks (route53, ecs, cloudfront, etc.). For each stack, we use a different Terraform backend. Switching backends involves a lengthy command that calls both the backend and, in our case, a vars file. While this can be managed via an alias, we have developed a tool that searches for Terraform backend files and the corresponding vars file. We have also created tools for running the terraform plan and terraform apply commands, handling the different backend and vars files.

Example

.
│── README.md
│── infra_environments
│  │── nonprod
│  │  │ ── nonprod.tfbackend
│  │  └── nonprod.tfvars.json
│  └── production
│       │ ── prod.tfbackend
│       └── prod.tfvars.json
├── stack
│   ├── networking
│   │   ├── data_remote_state.tf
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   ├── providers.tf
│   │   ├── tf_settings.tf
│   │   └── variables.tf
│   ├── observability
│   │   ├── data_remote_state.tf
│   │   ├── main.tf
│   │   ├─ output.tf
│   │   ├── providers.tf
│   │   ├── tf_settings.tf
│   │   └── variables.tf

➜ wtoorren@Mealhada observability (main) tfbackend <aws:technative>:nonprod
------------- Select Backend -------------
Type the number of the backend you want to use from the list below, and press enter

-: Unset backend
0: nonprod.tfbackend
1: prod.tfbackend

Selection: 0
Activating backend 0: ..../infra_environments/nonprod/nonprod.tfbackend

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
...

```bash
➜ wtoorren@Mealhada observability (main) tfplan
Using TF variable-file: /Users/wtoorren/data/git/Technative/iit/improvement_it-awsaccount-workload-rrs/infra_environments/nonprod/nonprod.tfvars.json
...

Quick AWS Profile Switching Another useful tool is the ability to quickly switch between different AWS profiles. AWS profile switcher is a tool that reads the .aws/config file and generates a list of available profiles for easy selection. Using aws-profile-switcher is straightforward and intuitive. After selecting the desired profile, the tool automatically sets the correct AWS_PROFILE. Additionally, the script checks if your AWS MFA token is still valid. If the token has expired, you receive a notification and can immediately generate a new token.

With aws-profile-switcher, managing multiple AWS accounts becomes much simpler and more efficient. No more manual profile switching or expired MFA tokens. This tool ensures that you can always work quickly and securely in your AWS environments.

An excellent addition is using ZSH and the ‘aws’ plugin. This plugin displays the selected profile on the right side of your prompt.

➜ user@my-host <aws:technative>

Conclusion These tools enable you to standardize and simplify repetitive tasks. Instead of typing the same long commands repeatedly, you can execute a series of actions with a single script. This not only saves time but also reduces the likelihood of human error.

By effectively utilizing tools, you optimize your workflow, increase the reliability of your work, and can switch more swiftly between tasks for different clients. Working efficiently with tools is therefore essential for success in cloud engineering.

Although these tools are still in early development and get updated along the way, they are freely available. You can check them out at [https://github.com/wearetechnative/race](https://github.com/wearetechnative/race.

Tags:

Do you like to respond? Mail our Team!