Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitsuya0828/resource-label-checker
A tool that periodically checks whether cloud resources are given a common label and notifies the results to Slack
https://github.com/kitsuya0828/resource-label-checker
aws gcp golang slack
Last synced: about 1 month ago
JSON representation
A tool that periodically checks whether cloud resources are given a common label and notifies the results to Slack
- Host: GitHub
- URL: https://github.com/kitsuya0828/resource-label-checker
- Owner: Kitsuya0828
- License: mit
- Created: 2023-08-01T14:08:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-04T04:39:15.000Z (over 1 year ago)
- Last Synced: 2023-08-14T15:31:39.520Z (over 1 year ago)
- Topics: aws, gcp, golang, slack
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# resource-label-checker
**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.
## Setup
```bash
git clone https://github.com/Kitsuya0828/resource-label-checker.git
cd resource-label-checker
go mod download
```## Run Locally
Set the environment variables indicated in `gcp.env.template` or `aws.env.template` appropriately before running the program.### Google Cloud
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](https://cloud.google.com/asset-inventory/docs/apis?hl=ja), the resource types to be excluded from the search can be selected from [Supported resource types](https://cloud.google.com/asset-inventory/docs/supported-asset-types?hl=ja#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`).
```bash
cd gcp
go run .
```### AWS
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](https://docs.aws.amazon.com/config/latest/developerguide/WhatIsConfig.html), the resource types that can be included in the search are listed in [resourceType](https://docs.aws.amazon.com/config/latest/APIReference/API_ListDiscoveredResources.html#config-ListDiscoveredResources-request-resourceType) and you can edit the `included-resources:` field.
Note that you must be able to run `config:ListDiscoveredResources` action and `config:BatchGetResourceConfig` action.
```bash
cd aws
go run .
```## Deploy
Sample Terraform code can be found in [Kitsuya0828/resource\-label\-checker\-terraform](https://github.com/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.
```go
func main() {
// Run() // Run locally or on ECS Fargate
lambda.Start(Run) // Run on AWS Lambda
}
```