# Installing and Setting Up AWS CLI and Pulumi on Ubuntu 24.04

## Introduction

This document provides a step-by-step guide to installing and configuring the AWS CLI and Pulumi on Ubuntu 24.04.

## Prerequisites

* Ubuntu 24.04 installed and configured.
    
* A user account with `sudo` privileges.
    
* An active AWS account.
    

## 1\. Installing AWS CLI using pipx

**Step 1.1: Update Package Lists**

First, ensure your system's package lists are up to date:

```bash
sudo apt update
```

**Step 1.2: Install pipx (if necessary)**

Check if `pipx` is installed:

```bash
pipx --version
```

If `pipx` is not installed, install it using `apt`:

```bash
sudo apt install pipx
pipx ensurepath
source ~/.bashrc
```

**Step 1.3: Install AWS CLI using pipx**

Install the AWS CLI using `pipx`:

```bash
pipx install awscli
```

**Step 1.4: Verify Installation**

Verify the installation by checking the AWS CLI version:

```bash
aws --version
```

This command should display the installed AWS CLI version.

**Step 1.5: Configure AWS CLI**

Configure the AWS CLI with your AWS credentials. You will need your AWS Access Key ID, Secret Access Key, and Session Token (if using temporary credentials). For details on obtaining these credentials, [check out this blog](https://blog.kcnaiamh.com/creating-aws-access-keys-for-iam-and-iam-identity-center-users).

```bash
aws configure
```

You will be prompted to enter the following information:

* **AWS Access Key ID:** Your AWS Access Key ID.
    
* **AWS Secret Access Key:** Your AWS Secret Access Key.
    
* **Default region name:** The AWS region you want to use by default (e.g., `ap-southeast-1`).
    
* **Default output format:** The output format (e.g., `json`, `text`, `table`).
    

For AWS Session Token, run the following command:

```bash
aws configure set aws_session_token <YOUR_SESSION_TOKEN>
```

## 2\. Installing Pulumi

**Step 2.1: Install Pulumi using the Installation Script**

Pulumi provides an installation script that simplifies the process. Run the following command:

```bash
curl -fsSL https://get.pulumi.com | sh
```

This script will download and install Pulumi.

**Step 2.2: Add Pulumi to Your PATH**

The installation script adds Pulumi to your PATH.

However, if it doesn't, you can manually add it by adding the following line to your `~/.bashrc` file:

```bash
export PATH=$PATH:~/.pulumi/bin
```

Then, apply the changes by running:

```bash
source ~/.bashrc
```

**Step 2.3: Verify Installation**

Verify the installation by checking the Pulumi version:

```bash
pulumi version
```

This command should display the installed Pulumi version.

**Step 2.4: Configure Pulumi for AWS**

Pulumi uses your AWS CLI credentials by default. If you have already configured the AWS CLI, Pulumi will use those credentials.

If not, you can configure Pulumi to use specific AWS credentials by setting environment variables:

```bash
export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY"
export AWS_SESSION_TOKEN="YOUR_SESSION_TOKEN" # if applicable
export AWS_REGION="YOUR_AWS_REGION"
```

Replace `YOUR_ACCESS_KEY_ID`, `YOUR_SECRET_ACCESS_KEY`, `YOUR_SESSION_TOKEN`, and `YOUR_AWS_REGION` with your actual AWS credentials and region.

**Step 2.5: Create a Pulumi Account (Optional but Recommended)**

While Pulumi can work with local state files, it's highly recommended to create a Pulumi account for state management, collaboration, and other features.

* Visit the Pulumi website ([pulumi.com](http://pulumi.com)) and create an account.
    
* Log in to your Pulumi account from the command line:
    

```bash
pulumi login
```

To run Pulumi locally without login, use `--local` flag:

```bash
pulumi login --local
```

In this case all the state data will be stored locally under `~/.pulumi/` directory.

## Conclusion

You have now successfully installed and set up AWS CLI and Pulumi on your Ubuntu 24.04 system. You can now use these tools to manage your AWS resources efficiently.
