Terraform-beginner-bootcamp-2023

Week 0 Prerequisite Week & Project Prep

  • Why Terraform

Learning Terraform is crucial for ☁️ cloud engineers because it empowers them to provision and manage cloud resources as code.

This Infrastructure as Code (IaC) approach ensures consistency, scalability, and efficiency in cloud deployments.

Terraform's versatility and support for multiple cloud providers make it a valuable skill for automating infrastructure and orchestrating complex cloud environments, ultimately streamlining operations and reducing manual errors.

. Codeblocks

This code is written in HashiCorp Configuration Language (HCL) and is used to define AWS resources that will be created or managed by Terraform [1]

provider "aws" {
  region = "us-east-1" # Change to your preferred AWS region
}

resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-unique-bucket-name" # Choose a unique name
  acl    = "private"              # Access control settings
}
Task 1 Create Github Repo & write up some documentation using Github Flavored Markdown
Task 2 Set up Gitlab
Task 3 Set up Terraform Cloud
  • Finish Task 1
  • Finish Task 2
  • Finish Task 3

References

Considerations with Terraform CLI changes

The Terraform CLI installations instructions have changed due to gpg keyring changes. So we need to refer to the new terraform CLI installations instructions via terraform documentation. And change the scripting for install.

Install Terraform CLI

Refactoring into Bash Scripts

While fixing the terraform depreciation issues. We realised the install instructions had to many steps. So we decided to create a bash script to install the terraform CLI. Bash scripit is located at (./bin/install_terraform_cli.sh)

  • This will keep the gitpod task file tidy(.gitpod.yml).
  • This wil allow better portability for other projects that need terraform CLI.

Considerations for Linux distribution

This project is built against Ubuntu Please consider check your linux distrubution and change according to your distrubution needs. (Check your linux distribution) Example of checking OS version

$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Gitpod lifecyle (Before, init, command)

We need to be careful when using the Init in our .yml file because it will not rerun if we restart an existing workspace.

Working with Env Vars

env command

We can list out all our envirnomnent varaibles .(Env.Vars) using the env command. We filter specific env vars using grep eg. env | grep AWS

Setting and unsetting Env

In the terminal we set using export HELLO= world

In the terminal we unset using unset HELLO

We can set an env var temporarily when just running a command

HELLO='world' ./bin/print_message

Within a bash script we can set env without writing export

#!/usr/bin/env .bash

HELLO='world'

echo $HELLO

Printing Vars

We can print an env var using echo eg. echo $HELLO

Scoping of ENV Vars

When you open up new bash terminals in VSCode it will not be awae of env vars that you have set in another window.

If you want to Env Vars to persist all future bash terminals that are open you need to set env vars in your bash profile eg. .bash_profile

Persisting Env Vars in Gitpod

We can persist env vars into gitpod by storing them in Gitpod Secrets Storage

gp env HELLO='world'

All future workspaces launched will set the env vars for all bash terminals opened in those workspaces.

You can also set en vars in the .gitpod.yml but this can only contain non-sensitive env vars.

Gitpod Lifecycle

Week 1 Getting Comfortable with Terraform and Terraform Cloud

Task 4 Create Terrahouse Module
Task 5 Static Website Hosting
  • Finish Task 4

  • Finish Task 5

  • State management

  • Changesets

  • Launching and Stop a Gitpod Workspace

  • Configuration launch scripts eg. .Gitpod.yml files


Week 2 Launching and Connecting our Terra house to TerraTowns

Task 6 Setting up Terratowns
Task 7 Terraform cloud and Multi Home Refactor
  • Finish Task 6
  • Finish Task 7

Reference

Use Control + Shift + m to toggle the tab key moving focus. Alternatively, use esc then tab to move to the next interactive element on the page. No file chosen Attach files by dragging & dropping, selecting or pasting them. Editing terraform-beginner-bootcamp-2023/README.md at main · NickGoko/terraform-beginner-bootcamp-2023