-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a module for managing the _Default logging sink in Google Cloud Logging. The default configuration for Google Cloud Logging is to enable syslog for all compute instances. This can cause a high volume of logs leading to unexpected costs. This optional module allows you to disable that behavior. Additional updates include changes to the pre-commit configuration to the latest version, updates to tflint to the latest version, cleanups for the trivy linter, and updates to readme's and changelog. On branch brent/logging-sink Changes to be committed: modified: .pre-commit-config.yaml modified: .tflint.hcl modified: CHANGELOG.md modified: README.md modified: examples/anyscale-v2-commonname/main.tf modified: main.tf modified: modules/google-anyscale-cloudstorage/main.tf new file: modules/google-anyscale-loggingsink/README.md new file: modules/google-anyscale-loggingsink/data.tf new file: modules/google-anyscale-loggingsink/main.tf new file: modules/google-anyscale-loggingsink/outputs.tf new file: modules/google-anyscale-loggingsink/variables.tf new file: modules/google-anyscale-loggingsink/versions.tf modified: variables.tf
- Loading branch information
1 parent
20bff96
commit 91c3de7
Showing
14 changed files
with
216 additions
and
8 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
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
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
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
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
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
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
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,54 @@ | ||
[![Build Status][badge-build]][build-status] | ||
[![Terraform Version][badge-terraform]](https://github.com/hashicorp/terraform/releases) | ||
[![Google Provider Version][badge-tf-google]](https://github.com/terraform-providers/terraform-provider-google/releases) | ||
# google-anyscale-loggingsink | ||
|
||
This sub-module modifies the `_Default` logging sink to disable syslog logging. The sub-module should be used from the [root module](../../README.md). | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 5.0 | | ||
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google"></a> [google](#provider\_google) | 5.38.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_logging_project_sink.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/logging_project_sink) | resource | | ||
| [google_client_config.current](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_anyscale_project_id"></a> [anyscale\_project\_id](#input\_anyscale\_project\_id) | (Optional) The ID of the project to create the resource in.<br><br>If not provided, the provider project is used.<br><br>ex:<pre>anyscale_project_id = "my-project"</pre> | `string` | `null` | no | | ||
| <a name="input_module_enabled"></a> [module\_enabled](#input\_module\_enabled) | (Optional) Determines whether to create the resources inside this module.<br><br>ex:<pre>module_enabled = true</pre> | `bool` | `true` | no | | ||
| <a name="input_sink_destination"></a> [sink\_destination](#input\_sink\_destination) | (Optional) The destination for the sink.<br><br>ex:<pre>sink_destination = "pubsub.googleapis.com/projects/my-project/topics/my-topic"</pre> | `string` | `null` | no | | ||
| <a name="input_sink_exclusion_filter"></a> [sink\_exclusion\_filter](#input\_sink\_exclusion\_filter) | (Optional) The filter for the sink.<br><br>ex:<pre>sink_filter = "resource.type=gce_instance AND logName=projects/example/logs/syslog"</pre> | `string` | `null` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
<!-- References --> | ||
[Terraform]: https://www.terraform.io | ||
[Issues]: https://github.com/anyscale/sa-terraform-google-cloudfoundation-modules/issues | ||
[badge-build]: https://github.com/anyscale/sa-terraform-google-cloudfoundation-modules/workflows/CI/CD%20Pipeline/badge.svg | ||
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20-623CE4.svg?logo=terraform | ||
[badge-tf-google]: https://img.shields.io/badge/GCP-5.+-F8991D.svg?logo=terraform | ||
[build-status]: https://github.com/anyscale/sa-terraform-google-cloudfoundation-modules/actions |
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 @@ | ||
data "google_client_config" "current" {} |
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,24 @@ | ||
locals { | ||
project_id = coalesce(var.anyscale_project_id, data.google_client_config.current.project) | ||
|
||
sink_destination = var.sink_destination != null ? var.sink_destination : "logging.googleapis.com/projects/${local.project_id}/locations/global/buckets/_Default" | ||
sink_exclusion_filter = var.sink_exclusion_filter != null ? var.sink_exclusion_filter : "resource.type=gce_instance AND logName=\"projects/${local.project_id}/logs/syslog\" " | ||
} | ||
|
||
# Update the _Default Logging Sink to disable syslog being sent to the default bucket | ||
resource "google_logging_project_sink" "default" { | ||
count = var.module_enabled ? 1 : 0 | ||
|
||
name = "_Default" | ||
destination = local.sink_destination | ||
|
||
exclusions { | ||
name = "anyscale" | ||
description = "Exclude syslog files from Anyscale clusters" | ||
filter = local.sink_exclusion_filter | ||
} | ||
unique_writer_identity = true | ||
|
||
project = var.anyscale_project_id | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# ------------------------------------------------------------------------------ | ||
# REQUIRED PARAMETERS | ||
# These variables must be set when using this module. | ||
# ------------------------------------------------------------------------------ | ||
|
||
|
||
# ------------------------------------------------------------------------------ | ||
# OPTIONAL PARAMETERS | ||
# These variables have defaults, but may be overridden. | ||
# ------------------------------------------------------------------------------ | ||
variable "module_enabled" { | ||
description = <<-EOF | ||
(Optional) Determines whether to create the resources inside this module. | ||
ex: | ||
``` | ||
module_enabled = true | ||
``` | ||
EOF | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "anyscale_project_id" { | ||
description = <<-EOF | ||
(Optional) The ID of the project to create the resource in. | ||
If not provided, the provider project is used. | ||
ex: | ||
``` | ||
anyscale_project_id = "my-project" | ||
``` | ||
EOF | ||
type = string | ||
default = null | ||
} | ||
|
||
|
||
variable "sink_destination" { | ||
description = <<-EOF | ||
(Optional) The destination for the sink. | ||
ex: | ||
``` | ||
sink_destination = "pubsub.googleapis.com/projects/my-project/topics/my-topic" | ||
``` | ||
EOF | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "sink_exclusion_filter" { | ||
description = <<-EOF | ||
(Optional) The filter for the sink. | ||
ex: | ||
``` | ||
sink_filter = "resource.type=gce_instance AND logName=projects/example/logs/syslog" | ||
``` | ||
EOF | ||
type = string | ||
default = null | ||
} |
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,14 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 5.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |
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