resource-label-checker is a tool that periodically checks whether cloud resources are given a common label and notifies the results to Slack.
The purpose is to effortlessly manage and analyse costs by labelling resources consistently.
git clone https://github.com/Kitsuya0828/resource-label-checker.git
cd resource-label-checker
go mod download
Set the environment variables indicated in gcp.env.template
or aws.env.template
appropriately before running the program.
By default, it checks for the presence of labels listed in the required-labels:
field in gcp/config.yml
.
In addition, because of the Cloud Asset API, the resource types to be excluded from the search can be selected from Supported resource types and appended to the excluded-resources:
field.
Note that you must be granted the cloudasset.assets.searchAllResources
permission on the desired scope (PROJECT_ID
).
cd gcp
go run .
By default, it checks for the presence of tags listed in the required-labels:
field in aws/config.yml
.
In addition, because of the AWS Config, the resource types that can be included in the search are listed in resourceType and you can edit the included-resources:
field.
Note that you must be able to run config:ListDiscoveredResources
action and config:BatchGetResourceConfig
action.
cd aws
go run .
Sample Terraform code can be found in Kitsuya0828/resource-label-checker-terraform.
The GitHub Actions workflow builds and pushes Docker images to the target Artifact Registry or ECR, but the sample workflow under the .github/
directory is currently commented out.
To run in AWS Lambda, change the comment-out in aws/main.go
as follows.
func main() {
// Run() // Run locally or on ECS Fargate
lambda.Start(Run) // Run on AWS Lambda
}