Amazon Web Services(AWS)-Terminal User Interface App-Part2
In the previous part, we had added EC2 and IAM services to the AWS-TUI. In this part, let's add S3(Simple Storage Services) and Cloud Trail services. Also, I will integrate S3 and CloudTrail to store CloudTrail Logs to the S3 bucket.
S3 is a global service and used to store object data like images, videos, etc.
S3 gives us up to 99,999999999% guarantee that our data won’t be lost. S3 also gives a 99,999% guarantee that our data will be available at any time.
Also, one of the advantages of S3 is that we can access S3 from multiple devices at the same time.
Here, aws_run.py is the entry-point of this app.
$ python3 aws_run.py
AWS S3 Services:
S3 directory contains the file s3_services.py. This file provides lots of useful functions to work with S3 service.
- Create New Bucket: createNewBucket function provides the option to create a new S3 bucket. It accepts bucket name(bucket name should be unique in the entire region), region-name, and constraint name as an input.
- Upload File to Bucket: uploadFileToBucket function provides a way to upload a new file to the S3 bucket. It accepts local file location, location inside S3 where we want to upload the file and ACL.
- Delete File from Bucket: By using the deleteFileFromBucket function, we can delete the file from the S3 bucket. This function accepts the file path inside the S3 bucket as an input.
- Delete Bucket: This function has two sub-functions. To delete the empty bucket and the non-empty bucket.
- Empty Bucket: This function will remove all of the objects from the bucket.
- Get List of Files: By using getListOfFiles function, we can display a list of all files stored inside the S3 bucket.
- Get Bucket Access Control List: This function will return the access control list(ACL) of a bucket.
- Put Bucket Access Control List: Sets the permissions on an existing bucket using access control lists (ACL). In this app, there are two methods provided to put bucket ACL. I. Put Bucket ACL by ID. II. Put Bucket ACL by Email. Using email addresses to specify a grantee is only supported in the limited AWS Regions.
- Get Object Access Control List: Returns the access control list (ACL) of an object. To use this operation, you must have READ_ACP access to the object.
- Put Object Access Control List: Uses the ACL subresource to set the access control list (ACL) permissions for an object that already exists in a bucket. You must have WRITE_ACP permission to set the ACL of an object. In this app, there are two methods provided to put object ACL. I. Put Object ACL by ID. II. Put Object ACL by Email. Using email addresses to specify a grantee is only supported in the limited AWS Regions.
AWS CloudTrail Servcies:
This service is so powerful and very useful in monitoring that, whatever we do on the cloud, it keeps all of the records(logs). These records are known as events. CloudTrail has all of the logs such as who logged in, who entered the wrong password, who terminated the instance, etc.
CloudTrail directory contains the file cloudtrail_services.py. This file provides lots of useful functions to work with CloudTrail service.
- Get All Event Logs: This function gives us all of the event logs.
- Get Last Event Log: By using the use of this function, we can get all of the details of the last event performed on the cloud.
- Create Trail: Create-Trail used to integrate S3 with CloudTrail. This function creates a trail and stores all of the event details in the S3 bucket.
- Get Trail Details: Returns all of the details of the trails like trail name, name of the used S3 bucket, etc.
- Get Required Trail Details: Returns the trail details that we choose to display. Sometimes, we don’t want all of the trail details. At that time, to get the required details, we can use this option.
- Delete Trail: Removes the specified trail permanently.
Here is the link for the source code of this app: https://github.com/cankush625/AWS-TUI
Until now, Part-2 of the upcoming many parts of the AWS-TUI app is developed. As I’m currently learning and implementing regularly these concepts in this app, this app will continue to upgrade day by day.