-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Conjugato
committed
May 26, 2023
1 parent
839a94c
commit a440ef9
Showing
7 changed files
with
188 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Contributing | ||
|
||
This guide outlines how you can contribute. | ||
|
||
## How to Contribute | ||
|
||
1. Fork the repository and clone it to your local machine. | ||
2. Create a new branch for your contribution: | ||
|
||
```shell | ||
git checkout -b my-contribution | ||
``` | ||
|
||
3. Make your changes, following the coding conventions and best practices. | ||
4. Write tests to ensure the correctness of your changes. | ||
5. Commit your changes: | ||
|
||
```shell | ||
git commit -m "Add my contribution" | ||
``` | ||
|
||
6. Push your changes to be reviewed | ||
|
||
```shell | ||
git push origin my-contribution | ||
``` | ||
|
||
7. Open a pull request from your forked repository to the main project repository. | ||
8. Provide a descriptive title and detailed description of your changes in the pull request. | ||
9. Be responsive to any feedback or requests for modifications to your contribution. | ||
10. Once approved, your contribution will be merged into the main project repository. | ||
|
||
## Coding Conventions | ||
|
||
Please follow these coding conventions to maintain a consistent and readable codebase: | ||
|
||
* Use meaningful variable and function names. | ||
* Write clear and concise comments. | ||
* Follow the established indentation style. | ||
* Use appropriate spacing and line breaks for readability. | ||
* Keep the codebase clean and free from unnecessary or commented-out code. | ||
* Write comprehensive tests for your code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Pull Request Description | ||
|
||
Please provide a brief description of your pull request. Explain the changes you made and why they are necessary. | ||
|
||
## Related Issue(s) | ||
|
||
If your pull request is related to any existing issue(s), mention them here and provide the link(s). | ||
|
||
## Proposed Changes | ||
|
||
List the changes made in your pull request. Be as detailed as possible. | ||
|
||
## Checklist | ||
|
||
- [ ] I have tested my changes thoroughly. | ||
- [ ] I have added/updated relevant documentation. | ||
- [ ] My code follows the established coding conventions. | ||
- [ ] I have added necessary tests and ensured existing tests pass. | ||
- [ ] I have reviewed my changes and confirmed they are correct and ready for merging. | ||
|
||
## Additional Information | ||
|
||
Provide any additional information or context that might be helpful for the reviewers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,53 @@ | ||
# Terraform Module: cloud-storage-monitoring | ||
Basic module to monitor object count in buckets. | ||
|
||
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
|
||
This Terraform module creates a bucket monitoring solution to periodically query specified bucket paths and return the total object count. If an object count for a given subfolder is greater than the threshold specified in the module a log will be created that is picked up by an alert policy. | ||
|
||
## Features | ||
|
||
- Creates a build trigger for each bucket that executes a script | ||
- Creates a scheduler task for each bucket to trigger the build trigger | ||
- Creates a single alert policy to watch for logs generated by the build trigger | ||
|
||
## Usage | ||
|
||
```terraform | ||
module "cloud_storage_monitor" { | ||
source = "./modules/cloud-storage-monitoring" | ||
name = "storage-monitor-v1" | ||
bucket_paths = [ | ||
"<BUCKET>/some/folder", | ||
"my-bucket-a/some/folder", | ||
"my-bucket-b/some/folder", | ||
] | ||
cron_schedule = "*/30 * * * *" | ||
cron_time_zone = "Australia/Melbourne" | ||
region = "us-east1" | ||
threshold = "1000" | ||
timeout = "7200s" | ||
service_account = data.google_compute_default_service_account.default.email | ||
service_account = "<EMAIL>" | ||
notification_channels = [ | ||
# Add notification channel ids here | ||
] | ||
} | ||
``` | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|-------------------------|---------------------------------------------------------|--------|-------------|----------| | ||
| name | Service name | string | - | yes | | ||
| bucket_paths | List of CIDR blocks for public subnets | list | - | yes | | ||
| cron_schedule | Cron schedule (e.g. */10 * * * *, every 10m ) | string | - | yes | | ||
| cron_timezone | Cron time zone (e.g. Australia/Melbourne) | string | - | yes | | ||
| region | GCP Region (e.g. us-east1) global not supported | string | - | yes | | ||
| threshold | Threshold limit before log is created | string | - | yes | | ||
| timeout | Time limit before script closes | string | - | yes | | ||
| service_account | Service acount email | string | - | yes | | ||
| notification_channels | Notification channel IDs | list | - | yes | | ||
|
||
|
||
data "google_compute_default_service_account" "default" {} | ||
## License | ||
|
||
data "google_project" "current" {} | ||
``` | ||
This module is licensed under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module "cloud_storage_monitor" { | ||
source = "./modules/cloud-storage-monitoring" | ||
|
||
name = "storage-monitor-v1" | ||
bucket_paths = [ | ||
"my-bucket-a/some/folder", | ||
"my-bucket-b/path/to/folder", | ||
"my-bucket-c", | ||
] | ||
cron_schedule = "*/30 * * * *" | ||
cron_time_zone = "Australia/Melbourne" | ||
region = "us-east1" | ||
threshold = "1000" | ||
timeout = "7200s" | ||
service_account = "<EMAIL>" | ||
notification_channels = [ | ||
google_monitoring_notification_channel.email.id | ||
] | ||
} | ||
|
||
resource "google_monitoring_notification_channel" "email" { | ||
display_name = "Test Notification Channel" | ||
type = "email" | ||
labels = { | ||
email_address = "[email protected]" | ||
} | ||
force_delete = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "4.66.0" | ||
} | ||
} | ||
} | ||
|
||
provider "google" { | ||
# Configuration options | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters