AWS Fundamentals: IAM, GitHub, and AWS CLI
Published: 2023-10-01 12:00:00

### Introduction

In this article, we will create an Admin user in AWS. We will also install the AWS CLI to create AWS Billing Alarms and Budgets.

You can do many things with the AWS CLI, but I want to start with something to get a simple understanding of it.

We will use gitpod to install the AWS CLI to make it accessible for everyone following along.

### Create a new Admin user

Create a new user in the IAM Users Console by searching IAM or going to [https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/users](https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/users)

![](https://cdn-images-1.medium.com/max/4216/1*_9fVr6pXQdjureIjrpNySw.png)

Click **Add users**

![](https://cdn-images-1.medium.com/max/5812/1*Ad8Hl1mgJIsHvGh8jrUpTA.png)

In step 1, Enable **AWS Management Console** access, choose I **want to create an IAM user**, choose your password preferences, then click **Next**.

![](https://cdn-images-1.medium.com/max/5412/1*oAuZRzEAHn-OjWId46PN3Q.png)

Step 2 is used to set the user’s permissions. We want to add the user to an Administrator group.

![](https://cdn-images-1.medium.com/max/2000/1*oh4y1AcVC7r34-bUCQwTNQ.png)

If you don’t have a group, create one by clicking **Create group**.

![](https://cdn-images-1.medium.com/max/2000/1*YQ575lLhg1xewGOPCWYdnw.png)

* Give the group a name, such as Admin and check **AdministratorAccess**

![](https://cdn-images-1.medium.com/max/3192/1*tKB1kyp-IIeF2C8lHXs_5A.png)

* Click **Create user group** at the bottom.

![](https://cdn-images-1.medium.com/max/2000/1*PI--tduu9RwNXjSuY7metw.png)

Check the Admin group you want to add the user to.

![](https://cdn-images-1.medium.com/max/2000/1*mtZeIARckX6qA5EXTc4Qog.png)

Click Next, then **Create User**.

![](https://cdn-images-1.medium.com/max/2000/1*quTjncScuzycivYhXi325w.png)

### Create IAM User Access Key

Click the user name of the IAM user, then click the **Security Credentials** tab.

![](https://cdn-images-1.medium.com/max/2000/1*AVpn-_FJ0pcpsb-D-pGskQ.png)

Now click **Create Access Key**.

![](https://cdn-images-1.medium.com/max/2000/1*vA439yP5ZvngVE0N4WOg5Q.png)

Choose **Command Line Interface (CLI)** then click **Next**.

![](https://cdn-images-1.medium.com/max/4424/1*occEv0dQJiG__3Xm-Exh4w.png)

Click **Create access key**

![](https://cdn-images-1.medium.com/max/4436/1*5Wa8aMHVjXw2wfPR5fxTSg.png)

This will give you an access key and a secret access key. Keep these in a safe place.

### Create a GitHub Account

We will use GitHub to store our code. Visit GitHub to create a new account.
[**GitHub: Let's build from here**](https://github.com/)

At the top right, click the plus icon. Then click **New Repository**

![](https://cdn-images-1.medium.com/max/2000/1*CgLiq-HW5-ux9aCqtjUdvw.png)

Give the repository a name and set the visibility

![](https://cdn-images-1.medium.com/max/3056/1*k8iEYc8nOvRHNep89EE16Q.png)

Click **Create Repository**

### Create a Gitpod account

Gitpod gives you an online dev environment. You will run our code here. You can also follow along on your personal computer as well just skip this part.

Sign up for a free Gitpod account here:
[**Gitpod: Always ready to code.**](https://www.gitpod.io/)
>  It may ask you what editor you want to use if you haven’t chosen a default. We will be using Visual Studio Code.

Download the chrome extension for Gitpod.
[**Gitpod - Always ready to code**](https://chrome.google.com/webstore/detail/gitpod-always-ready-to-co/dodmmooeoklaejobgleioelladacbeki)

Go back to your Github repository and reload the page. You should now see a green Gitpod button.

![](https://cdn-images-1.medium.com/max/2000/1*1JYQmQTGc111QVlVGsUYKw.png)

Click **Gitpod **and you should see the following screen

![](https://cdn-images-1.medium.com/max/2528/1*lP2J_e4BC4kR15gEWWPe3g.png)

Click **Continue with Github**
>  It may ask you what editor you want to use if you haven’t chosen a default. We will be using Visual Studio Code.

You should now have an environment with VS Code similar to the following.

![](https://cdn-images-1.medium.com/max/6448/1*_QqS1CgkNIkJh4pv427TPg.png)

### Install the AWS CLI

We will use the Linux instructions for installing the CLI, but you may refer to your operating system’s instructions in the AWS CLI documentation.
[**Installing or updating the latest version of the AWS CLI**](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)

Download the AWS CLI

    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

Unzip the CLI tool

    unzip awscliv2.zip

Install the AWS CLI.

    sudo ./aws/install

Check the AWS version installed

    aws --version

![](https://cdn-images-1.medium.com/max/2380/1*vaLC5leRpy0xMhbUhYCrqg.png)

### Set AWS environment variables

Now we can use the keys we created earlier and set them to environment variables so that we may work with the AWS CLI.

    gp env AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
    gp env AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
    gp env AWS_DEFAULT_REGION=us-east-1

You can verify that env are saved within gitpod by going here: [https://gitpod.io/user/variables](https://gitpod.io/user/variables)

Check that we are getting the expected user with the following command:

    aws sts get-caller-identity

We can also save our AWS account id to the gitpod environment variables

    gp env AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)

### Create a Billing Alarm (via the CLI)

Refer to the AWS CLI docs to create a SNS Topic by running this command in the terminal

    aws sns create-topic --name example-billing-alarm
[**create-topic - AWS CLI 1.27.79 Command Reference**](https://docs.aws.amazon.com/cli/latest/reference/sns/create-topic.html#examples)

This will give you a topic arn to use in the next command

Refer to the AWS CLI docs to subscribe to a topic using the topic arn from the previous command’s output.

    aws sns subscribe \
        --topic-arn arn:aws:sns:us-east-2:123456789012:example-billing-alarm \
        --protocol email \
        --notification-endpoint my-email@example.com
[**subscribe - AWS CLI 2.10.3 Command Reference**](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sns/subscribe.html)

Verify the alarm was created in the AWS Console:

[https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#alarmsV2](https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#alarmsV2)

It may take a few minutes before the alarm is created.

## Create an AWS budget (via the CLI)

Create folders aws and json, and go to the json folder using the following command in the terminal

    mkdir -p aws/json && cd aws/json

Go to the AWS CLI create budget documentation: [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/create-budget.html#examples](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/budgets/create-budget.html#examples)

Copy the budget.json and notifications-with-subscribers.json examples into the json folder.

To create a new file you may click the **New File…** button.

![](https://cdn-images-1.medium.com/max/2000/1*iWePQXF-HQcQjpF56xXpJQ.png)

Run this command in your terminal to create the budget

    aws budgets create-budget \
        --account-id $AWS_ACCOUNT_ID \
        --budget file://aws/json/budget.json \
        --notifications-with-subscribers file://aws/json/notifications-with-subscribers.json

Verify your budget was created in the AWS console:

[https://us-east-1.console.aws.amazon.com/billing/home#/budgets/overview](https://us-east-1.console.aws.amazon.com/billing/home#/budgets/overview)

Congratulations on creating a new IAM user, Github, and Gitpod account. You are now familiar with the AWS CLI, which we will use more in the future.