Auto tag AWS resources with Lambda

Automating AWS resource Tagging 

Why Tagging resources?

Tagging AWS resources is very important when you want to automate some tasks based on the tags, like you want to install patch automatically based on the tags from SSM association or you want to get a list of resources based on the tags. There are many aspects where tagging the resources will be required. 

In this blog, I will be showing on automatically adding a tag CreatedBy to the S3 bucket. You can leverage the same logic to other AWS resources.

Architectural design

S3 tag Automation design









 

AWS resources:

  • EventBridge
  • Lambda
  • Trail (CloudTrail)
In Cloud, event plays very important role in automation, Amazon EventBridge is a serverless event bus that makes it easier to build event-driven applications at scale using events generated from your applications, integrated Software-as-a-Service (SaaS) applications, and AWS services.

Steps:

  • Lambda Role required below permission
    • S3 bucket tagging permission
    • AWSLambdaBasicExecutionRole (Managed policy)
  • Create EventBridge rule with below configuration


Done, so we have configured trigger for lambda and when a new S3 bucket is created, automatically bucket tag will be applied. This tag helps to understand on who created the resources by seeing the tag.

Hope this blog helps in your use case!!!  Happing Coding

Comments

  1. This blog helped me in setting up automation in my organization, thanks for sharing










    ReplyDelete

Post a Comment

Popular posts from this blog

Connect to Linux EC2 Instance if Key pair is lost after Initial Launch

Setup Grafana on AWS EKS and integrate with AWS Cloudwatch

Start or Stop services in multiple Windows EC2 Instances using AWS Systems Manager

Concourse CI Installation and Configuration in Windows

Install SSM Agent in Amazon EC2 Instance

Deploy AWS infrastructure using Terraform and GitHub Actions

Automate Permission Boundary Attachment to IAM roles and Users

AWS Route 53 Inbound Resolver to resolve DNS for Multi Account Organization

Import Existing Resources using Terraform

Hosting AWS VPC Interface Endpoints in Shared Model