# 1) Install Terraform & Configure AWS (15 min) We’ll install Terraform and set up your AWS credentials on **Ubuntu 24.04**. ### A. Install Terraform ```bash sudo apt-get update ``` Updates the local package index so your system knows about the latest software versions. ```bash sudo apt-get install -y gnupg software-properties-common wget ``` Installs essential tools: - **gnupg** → handles security keys - **software-properties-common** → helps manage repositories - **wget** → used to download files ```bash wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp.gpg ``` Downloads and stores HashiCorp’s official GPG key for verifying Terraform packages. ```bash echo "deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list ``` Adds the HashiCorp package repository to your system so Terraform can be installed and updated. ```bash sudo apt update && sudo apt install -y terraform ``` Refreshes package list again and installs the latest Terraform release. ```bash terraform -v ``` Verifies Terraform is installed by printing its version. ### B. Install AWS CLI v2 ```bash sudo apt-get install -y unzip ``` Installs **unzip**, required to extract the AWS CLI package. ```bash curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" ``` Downloads the AWS CLI v2 installer. ```bash unzip awscliv2.zip ``` Extracts the AWS CLI installer files. ```bash sudo ./aws/install ``` Runs the AWS CLI installer to make it available system-wide. ```bash aws --version ``` Checks that AWS CLI is installed successfully. ### C. Configure AWS credentials ```bash aws configure ``` Starts interactive setup for AWS CLI. Enter: - **AWS Access Key ID**: (from your IAM user) - **AWS Secret Access Key**: (from your IAM user) - **Default region name**: `ap-south-1` (Mumbai, for this lab) - **Default output format**: `json` This creates config files (~/.aws/config and ~/.aws/credentials) so both AWS CLI and Terraform can connect securely to AWS.