Skip to content

Commit

Permalink
Merge branch 'master' into bucket_lifecycle_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisBRENON authored Sep 12, 2022
2 parents f0df1c0 + 4aa3030 commit 0283a06
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ The format is based on
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.3.0](https://github.com/terraform-google-modules/terraform-google-cloud-storage/compare/v3.2.0...v3.3.0) (2022-07-15)


### Features

* add name and url outputs on simple_bucket module ([#175](https://github.com/terraform-google-modules/terraform-google-cloud-storage/issues/175)) ([d76ffa3](https://github.com/terraform-google-modules/terraform-google-cloud-storage/commit/d76ffa3f2f147042527d98333397355a387d6701))
* Add option to enable default_event_based_hold argument ([#178](https://github.com/terraform-google-modules/terraform-google-cloud-storage/issues/178)) ([2ab4888](https://github.com/terraform-google-modules/terraform-google-cloud-storage/commit/2ab4888d135014b4c74c296da7e2e381aa58f766))

## [3.2.0](https://github.com/terraform-google-modules/terraform-google-cloud-storage/compare/v3.1.0...v3.2.0) (2022-03-04)


Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Functional examples are included in the
| bucket\_viewers | Map of lowercase unprefixed name => comma-delimited IAM-style per-bucket viewers. | `map(string)` | `{}` | no |
| cors | Set of maps of mixed type attributes for CORS values. See appropriate attribute types here: https://www.terraform.io/docs/providers/google/r/storage_bucket.html#cors | `set(any)` | `[]` | no |
| creators | IAM-style members who will be granted roles/storage.objectCreators on all buckets. | `list(string)` | `[]` | no |
| default\_event\_based\_hold | Enable event based hold to new objects added to specific bucket. Defaults to false. Map of lowercase unprefixed name => boolean | `map(bool)` | `{}` | no |
| encryption\_key\_names | Optional map of lowercase unprefixed name => string, empty strings are ignored. | `map(string)` | `{}` | no |
| folders | Map of lowercase unprefixed name => list of top level folder objects. | `map(list(string))` | `{}` | no |
| force\_destroy | Optional map of lowercase unprefixed name => boolean, defaults to false. | `map(bool)` | `{}` | no |
Expand Down
5 changes: 5 additions & 0 deletions examples/multiple_buckets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "cloud_storage" {
matches_storage_class = "MULTI_REGIONAL,STANDARD,DURABLE_REDUCED_AVAILABILITY"
}
}]

bucket_lifecycle_rules = {
"one" = [{
action = {
Expand All @@ -53,5 +54,9 @@ module "cloud_storage" {
age = "90"
}
}]

default_event_based_hold = {
"one" = true
}

}
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ resource "google_storage_bucket" "buckets" {
false,
)
}
default_event_based_hold = lookup(
var.default_event_based_hold,
lower(each.value),
false,
)
# Having a permanent encryption block with default_kms_key_name = "" works but results in terraform applying a change every run
# There is no enabled = false attribute available to ask terraform to ignore the block
dynamic "encryption" {
Expand Down
2 changes: 2 additions & 0 deletions modules/simple_bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Functional examples are included in the
| Name | Description |
|------|-------------|
| bucket | The created storage bucket |
| name | Bucket name. |
| url | Bucket URL. |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Expand Down
10 changes: 10 additions & 0 deletions modules/simple_bucket/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ output "bucket" {
description = "The created storage bucket"
value = google_storage_bucket.bucket
}

output "name" {
description = "Bucket name."
value = google_storage_bucket.bucket.name
}

output "url" {
description = "Bucket URL."
value = google_storage_bucket.bucket.url
}
2 changes: 1 addition & 1 deletion modules/simple_bucket/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ terraform {
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-cloud-storage:simple_bucket/v3.2.0"
module_name = "blueprints/terraform/terraform-google-cloud-storage:simple_bucket/v3.3.0"
}

}
2 changes: 2 additions & 0 deletions test/integration/multiple_buckets/multiple_buckets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ func TestMultipleBuckets(t *testing.T) {
bucket_lifecycle := op.Get("metadata.lifecycle.rule").Array()[1]
assert.Equal("Delete", bucket_lifecycle.Get("action.type").String(), "bucket lifecycle action is Delete")
assert.Equal("90", bucket_lifecycle.Get("condition.age").String(), "bucket lifecycle condition is age 90")
assert.True(op.Get("metadata.defaultEventBasedHold").Bool(), "defaultEventBasedHold is enabled")
case "two":
// bucket with suffix two
assert.False(op.Get("metadata.iamConfiguration.bucketPolicyOnly.enabled").Bool(), "bucketPolicyOnly is disabled")
assert.False(op.Get("metadata.defaultEventBasedHold").Bool(), "defaultEventBasedHold is disabled")
gcloud.Run(t, fmt.Sprintf("alpha storage ls --buckets gs://%s/dev/", bucketName), gcloudArgs)
gcloud.Run(t, fmt.Sprintf("alpha storage ls --buckets gs://%s/prod/", bucketName), gcloudArgs)
bucket_lifecycles := op.Get("metadata.lifecycle.rule").Array()
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ variable "bucket_policy_only" {
default = {}
}

variable "default_event_based_hold" {
description = "Enable event based hold to new objects added to specific bucket. Defaults to false. Map of lowercase unprefixed name => boolean"
type = map(bool)
default = {}
}

variable "admins" {
description = "IAM-style members who will be granted roles/storage.objectAdmin on all buckets."
type = list(string)
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ terraform {
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-cloud-storage/v3.2.0"
module_name = "blueprints/terraform/terraform-google-cloud-storage/v3.3.0"
}

}

0 comments on commit 0283a06

Please sign in to comment.