Automation, AWS, Cloud Computing, DevOps

3 Mins Read

aws-autotag

Amazon is adding many services and has many resources under services. It has Compute services, Database services, Analytics services, Monitoring services etc.People of an organization are experimenting on all those services on a daily basis to understand the concepts behind those services. As this experiment or bringing the process to production, they forget to clean up the resources or think about the price of particular service. Due to such situations, suddenly at the end of the month, we notice the price of our AWS account goes high and we will be confused to know which IAM users has charged more and utilized our AWS resources. This is a serious problem for any organizations to control the spawning of resources however, we can monitor the resources based on the tags and get to know how much each IAM users charged ;).

The aws-autotag project is focussed on tagging with owner tag for the resources which is launched or created on an AWS Account for all regions.Other benefits of the project are, IAM users forgot to add a tag to the resource which will create chaos and this project will tag the resources and overcome that situation.

This project utilizes following AWS Resources( AWS Lambda, AWS S3, AWS Cloudtrail, AWS SNS(Optional ). AWS Lambda is serverless compute engine which runs our code without launching any server and relieves us from setting up the environment.You can get more details of AWS Lambda here. 

Let’s start setting up the environment for aws-autotag.

  1. Login into AWS Console.
  2. Choose region as Oregon.
  3. Go to AWS CloudTrail and create a new trail to send all logs files to a single Bucket.
  4. This will create an AWS Cloudtrail “Trail” and also creates an AWS S3 Bucket, which starts pushing logs files to specified S3 bucket.
  5. Download the role which will used in further Lambda Lab.
    • https://s3-ap-northeast-1.amazonaws.com/srihari-bucket/aws-autotag/Lambda-Role.docx
  6. Create a Lambda Function
    • Click Next to Select Blueprint.
    • Select S3 for configure Trigger
      •  Add Event source type as S3
      •  Add the Bucket name which you created
      •  Add Object Created (ALL) in Event type field
      •  Add the prefix as given: AWSLogs/<ACCOUNT-ID>/CloudTrail/
      •  Add Suffix as .gz
      • Check Enable trigger
      • Click on Next
    • Enter your function name and Runtime will be NodeJS.
    • Choose code entry type as Upload a .ZIP file and upload updated aws-autotag.zip file.
    • Select Choose an existing role for Role and select Create New IAM Role for IAM Role and Click on Edit and update the role with given role.
    • Update Timeout as 10sec and click Next and then Create Function.

 

8

1

3

 

 

 

 

WRITTEN BY CloudThat

SHARE

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!