Create an inventory of AWS Services using Python
Tags: aws, python
Published: 2022-10-02 17:08:18


![AWS Services](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96jmbys3ufrahh58dxpq.png)


Welcome to my Python project!

I am learning Python and adding this to my learning experience in AWS! Writing a simple Python program, a combination of Python lists by name/index and functions like print, append, insert, and remove the variables.



## Objectives

- Create a list of AWS services using Python script - 
  _project_14.py_

- The list should be empty initially.

- Populate the list using append and/or insert.

- Print the list and the length of the list.

- Remove two specific services from the list by name or by index.

- Print the new list and the new length of the list.




## Pre-requisites

- AWS user account with admin access, not a root account.

- Cloud9 IDE comes with Python installed.




## Resources Used:

[Certified Entry-Level Python Programmer Certification by ACloudGuru](https://auth.acloud.guru/login?state=hKFo2SBJZ1hEb0t0WFNQaHl1Z24xd0lQY2cweGlWREJkcEdieaFupWxvZ2luo3RpZNkgVWlSNDJKRlJ4a3RvbGlNREhDUjdjMExrVGFnNmk5MWOjY2lk2SBPS0ZnOXVvUE1DTmVsdmx2S1ZEZlBLNzY2RFJkQVlENQ&client=OKFg9uoPMCNelvlvKVDfPK766DRdAYD5&protocol=oauth2&response_type=code%20token%20id_token&redirect_uri=https%3A%2F%2Flearn.acloud.guru%2Flogin%2Fcallback&audience=https%3A%2F%2Facloudguru.auth0.com%2Fapi%2Fv2%2F&nonce=mVZ-QL_cQbZ3.ChSAwLCBjcG4ZK._V6Y&scope=openid%20profile%20email&auth0Client=eyJuYW1lIjoiYXV0aDAuanMiLCJ2ZXJzaW9uIjoiOS4xMy40In0%3D)

I have also found these sites to be very helpful in understanding the basics of Python.

For number conversion tools to convert binary, decimal, hexadecimal and octal numbers to each other, used [binaryhexconverter](https://www.binaryhexconverter.com/).

For Python Tutorials on Bitwise Operators (AND | OR | XOR | Complement/NOT | Left Shift | Right Shift), used YouTube Videos 
of [Amulya’s Academy](https://www.youtube.com/c/AmulsAcademy).



---


_Let’s get started!_

You can find the complete code on my [GitHub Repository](https://github.com/awsmine/Python_LUIT/blob/main/project_14.py).

I have used Cloud9 as IDE to write, run, and debug the Python code with just a browser. While working on this project, I stored the files generated in my Cloud9 IDE to GitHub repository outside of this EC2 VM, so that I would not loose my code if anything happens to this VM on AWS.



# Steps of Implementing the Objectives



## Create a list of AWS services using Python script
 — **project_14.py**

The list should be empty initially.


```
#!/usr/bin/env python3.7
# create a variable to hold a place in memory for the list of AWS services
aws_services = []
```

## Populate the list using append and/or insert.

1. Using an _**‘append’**_ method, I have used the following AWS services to create a list for demonstration purposes.

- AWS Batch

- Amazon CloudWatch

- Amazon DynamoDB

- Amazon Elastic Compute Cloud (EC2)

- AWS Lambda

- Amazon Simple Storage Service (S3)

```
# using 'append' method, add an object to the list
aws_services.append('Batch')
aws_services.append('CloudWatch')
aws_services.append('DynamoDB')
aws_services.append('EC2')
aws_services.append('Lambda')
aws_services.append('S3')
```

2. Using an **‘insert’** method, I have used the following AWS services to create a **list by index**


![AWS Services list by index](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztqtgfh277xc0mi8qck8.png)

```
# using 'insert' method, add an object to the list by index
aws_services.insert(0, 'Athena')
aws_services.insert(1, 'Aurora')
aws_services.insert(5, 'FSx')
```

**Print the list and the length of the list.**

```
# print the list and the length of the list
length = len(aws_services)
print("This is the list of AWS services:", aws_services, " and the length of the list is: ", length)
```

**Remove two specific services from the list by name and/or by index.**

```
# remove 2 services from the list by name
aws_services.remove('Athena')
aws_services.remove('S3')
 
# remove 2 services from the list by index
del aws_services[3]
del aws_services[4]
```

**Print the new list and the new length of the list.**

```
# create variables to hold a place in memory for the list and new length of AWS services
new_list = list(aws_services)
new_length = len(new_list) 

# print the new list and new length of the list
print("This is the new list of AWS services: ", new_list, " and new length of the list: ", new_length)
```

## What we have done so far

Created a python script for a list of AWS Services by first populating it by append/insert methods, printing the list and the length of the list, removing specific services by name/index, and lastly printing the new list and the length of the new list.

It was fun working with Python and doing this project. I will post more articles as I learn to code my projects with Python.