extend gcs module tests to cover new variables
This commit is contained in:
parent
9e32b32b3d
commit
120e1be1d9
|
@ -56,6 +56,15 @@ variable "location" {
|
||||||
default = "EU"
|
default = "EU"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "logging_config" {
|
||||||
|
description = "Per-bucket logging."
|
||||||
|
type = map(object({
|
||||||
|
log_bucket = string
|
||||||
|
log_object_prefix = string
|
||||||
|
}))
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
variable "names" {
|
variable "names" {
|
||||||
description = "Bucket name suffixes."
|
description = "Bucket name suffixes."
|
||||||
type = list(string)
|
type = list(string)
|
||||||
|
@ -72,6 +81,15 @@ variable "project_id" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "retention_policies" {
|
||||||
|
description = "Per-bucket retention policy."
|
||||||
|
type = map(object({
|
||||||
|
retention_period = number
|
||||||
|
is_locked = bool
|
||||||
|
}))
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
variable "storage_class" {
|
variable "storage_class" {
|
||||||
description = "Bucket storage class."
|
description = "Bucket storage class."
|
||||||
type = string
|
type = string
|
||||||
|
@ -83,21 +101,3 @@ variable "versioning" {
|
||||||
type = map(bool)
|
type = map(bool)
|
||||||
default = {}
|
default = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "retention_policies" {
|
|
||||||
description = "Per-bucket retention policy."
|
|
||||||
type = map(object({
|
|
||||||
retention_period = number
|
|
||||||
is_locked = bool
|
|
||||||
}))
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "logging_config" {
|
|
||||||
description = "Per-bucket logging."
|
|
||||||
type = map(object({
|
|
||||||
log_bucket = string
|
|
||||||
log_object_prefix = string
|
|
||||||
}))
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,12 +17,14 @@
|
||||||
module "test" {
|
module "test" {
|
||||||
source = "../../../../modules/gcs"
|
source = "../../../../modules/gcs"
|
||||||
project_id = "my-project"
|
project_id = "my-project"
|
||||||
names = ["bucket-a", "bucket-b"]
|
bucket_policy_only = var.bucket_policy_only
|
||||||
prefix = var.prefix
|
force_destroy = var.force_destroy
|
||||||
iam_members = var.iam_members
|
iam_members = var.iam_members
|
||||||
iam_roles = var.iam_roles
|
iam_roles = var.iam_roles
|
||||||
labels = var.labels
|
labels = var.labels
|
||||||
bucket_policy_only = var.bucket_policy_only
|
logging_config = var.logging_config
|
||||||
force_destroy = var.force_destroy
|
names = ["bucket-a", "bucket-b"]
|
||||||
|
prefix = var.prefix
|
||||||
|
retention_policies = var.retention_policies
|
||||||
versioning = var.versioning
|
versioning = var.versioning
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,36 @@ variable "labels" {
|
||||||
default = { environment = "test" }
|
default = { environment = "test" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "logging_config" {
|
||||||
|
type = map(object({
|
||||||
|
log_bucket = string
|
||||||
|
log_object_prefix = string
|
||||||
|
}))
|
||||||
|
default = {
|
||||||
|
bucket-a = { log_bucket = "foo", log_object_prefix = null }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
variable "prefix" {
|
variable "prefix" {
|
||||||
type = string
|
type = string
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "project_id" {
|
||||||
|
type = string
|
||||||
|
default = "my-project"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "retention_policies" {
|
||||||
|
type = map(object({
|
||||||
|
retention_period = number
|
||||||
|
is_locked = bool
|
||||||
|
}))
|
||||||
|
default = {
|
||||||
|
bucket-b = { retention_period = 5, is_locked = false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
variable "storage_class" {
|
variable "storage_class" {
|
||||||
type = string
|
type = string
|
||||||
default = "MULTI_REGIONAL"
|
default = "MULTI_REGIONAL"
|
||||||
|
|
|
@ -55,6 +55,18 @@ def test_map_values(plan_runner):
|
||||||
assert versioning == {
|
assert versioning == {
|
||||||
'bucket-a': [{'enabled': True}], 'bucket-b': [{'enabled': False}]
|
'bucket-a': [{'enabled': True}], 'bucket-b': [{'enabled': False}]
|
||||||
}
|
}
|
||||||
|
logging_config = dict((r['values']['name'], r['values']['logging'])
|
||||||
|
for r in resources)
|
||||||
|
assert logging_config == {
|
||||||
|
'bucket-a': [{'log_bucket': 'foo'}],
|
||||||
|
'bucket-b': []
|
||||||
|
}
|
||||||
|
retention_policies = dict((r['values']['name'], r['values']['retention_policy'])
|
||||||
|
for r in resources)
|
||||||
|
assert retention_policies == {
|
||||||
|
'bucket-a': [],
|
||||||
|
'bucket-b': [{'is_locked': False, 'retention_period': 5}]
|
||||||
|
}
|
||||||
for r in resources:
|
for r in resources:
|
||||||
assert r['values']['labels'] == {
|
assert r['values']['labels'] == {
|
||||||
'environment': 'test', 'location': 'eu',
|
'environment': 'test', 'location': 'eu',
|
||||||
|
|
Loading…
Reference in New Issue