forked from GoogleCloudPlatform/cloud-foundation-fabric
-
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
Showing
23 changed files
with
847 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Google Cloud Logging Buckets Module | ||
|
||
This module manages [logging buckets](https://cloud.google.com/logging/docs/storage#logs-buckets) for a project, folder, organization or billing account. | ||
|
||
Note that some logging buckets are automatically created for a given folder, project, organization, and billing account cannot be deleted. Creating a resource of this type will acquire and update the resource that already exists at the desired location. These buckets cannot be removed so deleting this resource will remove the bucket config from your terraform state but will leave the logging bucket unchanged. The buckets that are currently automatically created are "_Default" and "_Required". | ||
|
||
See also the `logging_sinks` argument within the [project](../project/), [folder](../folder/) and [organization](../organization) modules. | ||
|
||
## Examples | ||
|
||
### Create custom logging bucket in a project | ||
|
||
```hcl | ||
module "bucket" { | ||
source = "./modules/logging-bucket" | ||
parent_type = "project" | ||
parent = var.project_id | ||
id = "mybucket" | ||
} | ||
# tftest:modules=1:resources=1 | ||
``` | ||
|
||
|
||
### Change retention period of a folder's _Default bucket | ||
|
||
```hcl | ||
module "folder" { | ||
source = "./modules/folder" | ||
parent = "folders/657104291943" | ||
name = "my folder" | ||
} | ||
module "bucket-default" { | ||
source = "./modules/logging-bucket" | ||
parent_type = "folder" | ||
parent = module.folder.id | ||
id = "_Default" | ||
retention = 10 | ||
} | ||
# tftest:modules=2:resources=2 | ||
``` | ||
|
||
|
||
<!-- BEGIN TFDOC --> | ||
## Variables | ||
|
||
| name | description | type | required | default | | ||
|---|---|:---: |:---:|:---:| | ||
| id | Name of the logging bucket. | <code title="">string</code> | ✓ | | | ||
| parent | ID of the parentresource containing the bucket in the format 'project_id' 'folders/folder_id', 'organizations/organization_id' or 'billing_account_id'. | <code title="">string</code> | ✓ | | | ||
| parent_type | Parent object type for the bucket (project, folder, organization, billing_account). | <code title="">string</code> | ✓ | | | ||
| *description* | Human-readable description for the logging bucket. | <code title="">string</code> | | <code title="">null</code> | | ||
| *location* | Location of the bucket. | <code title="">string</code> | | <code title="">global</code> | | ||
| *retention* | Retention time in days for the logging bucket. | <code title="">number</code> | | <code title="">30</code> | | ||
|
||
## Outputs | ||
|
||
| name | description | sensitive | | ||
|---|---|:---:| | ||
| id | None | | | ||
<!-- END TFDOC --> |
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,51 @@ | ||
/** | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
resource "google_logging_project_bucket_config" "bucket" { | ||
count = var.parent_type == "project" ? 1 : 0 | ||
project = var.parent | ||
location = var.location | ||
retention_days = var.retention | ||
bucket_id = var.id | ||
description = var.description | ||
} | ||
|
||
resource "google_logging_folder_bucket_config" "bucket" { | ||
count = var.parent_type == "folder" ? 1 : 0 | ||
folder = var.parent | ||
location = var.location | ||
retention_days = var.retention | ||
bucket_id = var.id | ||
description = var.description | ||
} | ||
|
||
resource "google_logging_organization_bucket_config" "bucket" { | ||
count = var.parent_type == "organization" ? 1 : 0 | ||
organization = var.parent | ||
location = var.location | ||
retention_days = var.retention | ||
bucket_id = var.id | ||
description = var.description | ||
} | ||
|
||
resource "google_logging_billing_account_bucket_config" "bucket" { | ||
count = var.parent_type == "billing_account" ? 1 : 0 | ||
billing_account = var.parent | ||
location = var.location | ||
retention_days = var.retention | ||
bucket_id = var.id | ||
description = var.description | ||
} |
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 @@ | ||
/** | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "id" { | ||
value = try( | ||
google_logging_project_bucket_config.bucket.0.id, | ||
google_logging_folder_bucket_config.bucket.0.id, | ||
google_logging_organization_bucket_config.bucket.0.id, | ||
google_logging_billing_account_bucket_config.bucket.0.id, | ||
) | ||
} |
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,48 @@ | ||
/** | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "parent_type" { | ||
description = "Parent object type for the bucket (project, folder, organization, billing_account)." | ||
type = string | ||
} | ||
|
||
variable "parent" { | ||
description = "ID of the parentresource containing the bucket in the format 'project_id' 'folders/folder_id', 'organizations/organization_id' or 'billing_account_id'." | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
description = "Location of the bucket." | ||
type = string | ||
default = "global" | ||
} | ||
|
||
variable "id" { | ||
description = "Name of the logging bucket." | ||
type = string | ||
} | ||
|
||
variable "description" { | ||
description = "Human-readable description for the logging bucket." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "retention" { | ||
description = "Retention time in days for the logging bucket." | ||
type = number | ||
default = 30 | ||
} |
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
Oops, something went wrong.