When you operate complex applications in AWS, you will sooner or later create some additional resources like volumes or load balancers. You might need to attach some tags to these resources. This repository contains installation of AWS Lambda function which will go through all your resources, identify them based on a configured tag which should contain ta specific value. For every resource it find it will make sure that the desired tags are attached.
## Prerequisites and dependencies
- The Lambda deployment is written using Terraform
- Generating of the lambda function from the template and packing it into ZIP archive expects
bash
andzip
being available. - This deployment might not work on Windows machine. Tested only on Linux and macOS
This Lambda fucntion was originally developed for tagging Kubernetes cluster and their resources. But it should work with other applications as well.
The configuration is done through Terraform variables. Example tfvars file is part of this repo and is named example.tfvars
. Change the variables to match your environment / requirements before running terraform apply ...
.
Option | Explanation | Example |
---|---|---|
aws_region |
AWS region which should be used | eu-east-1 |
lambda_name |
Will be used to name the tagging lambda, its roles etc. | my-k8s |
search_tag_key |
The Key of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags. | kubernetes.io/cluster/aws-k8s |
search_tag_value |
The Valur of the tag which determines resources belonging to the application. All resources with matching tag and its value will be tagged with additional tags. | owned |
tags |
Tags which should be applied to all resources | { Hello = "World" } |
To deploy the tagging lambda,
- Export AWS credentials into environment variables
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
- Apply Terraform configuration with tagging lambda:
terraform init
terraform apply --var-file example.tfvars
To delete tagging lambda,
- Export AWS credentials into environment variables
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
- Destroy Terraform configuration:
terraform destroy --var-file example.tfvars
Although it can be run on its own, the main value is that it can be included into another Terraform configuration.
module "tagging-lambda" {
source = "scholzj/tagging-lambda/aws"
aws_region = "us-east-1"
name = "my-application"
search_tag_key = "kubernetes.io/cluster/aws-k8s"
search_tag_value = "owned"
# Tags
tags = {
Hello = "World"
}
}
An example of how to include this can be found in the examples dir.
- EC2 instances
- Network interfaces
- EBS Volumes
- Security Groups
- Internet Gateways
- DHCP Option sets
- Subnets
- Route tables
- VPCs
- Network ACLs
- Autoscaling Groups
- Elastic Loadbalancers