Merge branch 'master' into fast/gke2
This commit is contained in:
commit
93acd595fe
|
@ -30,9 +30,9 @@ locals {
|
|||
subnet = k
|
||||
role = "roles/compute.networkUser"
|
||||
members = concat(
|
||||
formatlist("group:%s", try(v.iam_groups, [])),
|
||||
formatlist("user:%s", try(v.iam_users, [])),
|
||||
formatlist("serviceAccount:%s", try(v.iam_service_accounts, []))
|
||||
formatlist("group:%s", lookup(v, "iam_groups", [])),
|
||||
formatlist("user:%s", lookup(v, "iam_users", [])),
|
||||
formatlist("serviceAccount:%s", lookup(v, "iam_service_accounts", []))
|
||||
)
|
||||
}
|
||||
]
|
||||
|
@ -73,7 +73,8 @@ locals {
|
|||
local._factory_descriptions, var.subnet_descriptions
|
||||
)
|
||||
subnet_iam_members = concat(
|
||||
local._factory_iam_members, local._subnet_iam_members
|
||||
[for k in local._factory_iam_members : k if length(k.members) > 0],
|
||||
local._subnet_iam_members
|
||||
)
|
||||
subnet_flow_logs = merge(
|
||||
local._factory_flow_logs, local._subnet_flow_logs
|
||||
|
|
|
@ -94,17 +94,18 @@ module "pubsub" {
|
|||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [name](variables.tf#L62) | PubSub topic name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L67) | Project used for resources. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L68) | PubSub topic name. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L73) | Project used for resources. | <code>string</code> | ✓ | |
|
||||
| [dead_letter_configs](variables.tf#L17) | Per-subscription dead letter policy configuration. | <code title="map(object({ topic = string max_delivery_attempts = number }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [defaults](variables.tf#L26) | Subscription defaults for options. | <code title="object({ ack_deadline_seconds = number message_retention_duration = string retain_acked_messages = bool expiration_policy_ttl = string filter = string })">object({…})</code> | | <code title="{ ack_deadline_seconds = null message_retention_duration = null retain_acked_messages = null expiration_policy_ttl = null filter = null }">{…}</code> |
|
||||
| [iam](variables.tf#L44) | IAM bindings for topic in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
||||
| [kms_key](variables.tf#L50) | KMS customer managed encryption key. | <code>string</code> | | <code>null</code> |
|
||||
| [labels](variables.tf#L56) | Labels. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [push_configs](variables.tf#L72) | Push subscription configurations. | <code title="map(object({ attributes = map(string) endpoint = string oidc_token = object({ audience = string service_account_email = string }) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [regions](variables.tf#L85) | List of regions used to set persistence policy. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [subscription_iam](variables.tf#L91) | IAM bindings for subscriptions in {SUBSCRIPTION => {ROLE => [MEMBERS]}} format. | <code>map(map(list(string)))</code> | | <code>{}</code> |
|
||||
| [subscriptions](variables.tf#L97) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | <code title="map(object({ labels = map(string) options = object({ ack_deadline_seconds = number message_retention_duration = string retain_acked_messages = bool expiration_policy_ttl = string filter = string }) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [message_retention_duration](variables.tf#L62) | Minimum duration to retain a message after it is published to the topic. | <code>string</code> | | <code>null</code> |
|
||||
| [push_configs](variables.tf#L78) | Push subscription configurations. | <code title="map(object({ attributes = map(string) endpoint = string oidc_token = object({ audience = string service_account_email = string }) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [regions](variables.tf#L91) | List of regions used to set persistence policy. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [subscription_iam](variables.tf#L97) | IAM bindings for subscriptions in {SUBSCRIPTION => {ROLE => [MEMBERS]}} format. | <code>map(map(list(string)))</code> | | <code>{}</code> |
|
||||
| [subscriptions](variables.tf#L103) | Topic subscriptions. Also define push configs for push subscriptions. If options is set to null subscription defaults will be used. Labels default to topic labels if set to null. | <code title="map(object({ labels = map(string) options = object({ ack_deadline_seconds = number message_retention_duration = string retain_acked_messages = bool expiration_policy_ttl = string filter = string }) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ resource "google_pubsub_topic" "default" {
|
|||
name = var.name
|
||||
kms_key_name = var.kms_key
|
||||
labels = var.labels
|
||||
message_retention_duration = var.message_retention_duration
|
||||
|
||||
dynamic "message_storage_policy" {
|
||||
for_each = length(var.regions) > 0 ? [var.regions] : []
|
||||
|
|
|
@ -59,6 +59,12 @@ variable "labels" {
|
|||
default = {}
|
||||
}
|
||||
|
||||
variable "message_retention_duration" {
|
||||
description = "Minimum duration to retain a message after it is published to the topic."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
description = "PubSub topic name."
|
||||
type = string
|
||||
|
|
|
@ -20,8 +20,7 @@ _VAR_SUBNETS = (
|
|||
' secondary_ip_range=null},'
|
||||
'{name = "c", region = "europe-west1", ip_cidr_range = "10.0.2.0/24",'
|
||||
' secondary_ip_range={a="192.168.0.0/24", b="192.168.1.0/24"}},'
|
||||
']'
|
||||
)
|
||||
']')
|
||||
|
||||
_VAR_DATA_FOLDER = "data"
|
||||
|
||||
|
@ -29,9 +28,10 @@ _VAR_DATA_FOLDER = "data"
|
|||
def test_subnet_factory(plan_runner):
|
||||
"Test subnet factory."
|
||||
_, resources = plan_runner(data_folder=_VAR_DATA_FOLDER)
|
||||
assert len(resources) == 5
|
||||
subnets = [r['values']
|
||||
for r in resources if r['type'] == 'google_compute_subnetwork']
|
||||
assert len(resources) == 3
|
||||
subnets = [
|
||||
r['values'] for r in resources if r['type'] == 'google_compute_subnetwork'
|
||||
]
|
||||
assert {s['name'] for s in subnets} == {'factory-subnet', 'factory-subnet2'}
|
||||
assert {len(s['secondary_ip_range']) for s in subnets} == {0, 1}
|
||||
|
||||
|
@ -40,8 +40,9 @@ def test_subnets_simple(plan_runner):
|
|||
"Test subnets variable."
|
||||
_, resources = plan_runner(subnets=_VAR_SUBNETS)
|
||||
assert len(resources) == 4
|
||||
subnets = [r['values']
|
||||
for r in resources if r['type'] == 'google_compute_subnetwork']
|
||||
subnets = [
|
||||
r['values'] for r in resources if r['type'] == 'google_compute_subnetwork'
|
||||
]
|
||||
assert {s['name'] for s in subnets} == {'a', 'b', 'c'}
|
||||
assert {len(s['secondary_ip_range']) for s in subnets} == {0, 0, 2}
|
||||
|
||||
|
@ -51,11 +52,9 @@ def test_subnet_log_configs(plan_runner):
|
|||
log_config = '{"europe-west1/a" = { flow_sampling = 0.1 }}'
|
||||
log_config_defaults = (
|
||||
'{aggregation_interval = "INTERVAL_10_MIN", flow_sampling = 0.5, '
|
||||
'metadata = "INCLUDE_ALL_METADATA"}'
|
||||
)
|
||||
'metadata = "INCLUDE_ALL_METADATA"}')
|
||||
subnet_flow_logs = '{"europe-west1/a"=true, "europe-west1/b"=true}'
|
||||
_, resources = plan_runner(subnets=_VAR_SUBNETS,
|
||||
log_configs=log_config,
|
||||
_, resources = plan_runner(subnets=_VAR_SUBNETS, log_configs=log_config,
|
||||
log_config_defaults=log_config_defaults,
|
||||
subnet_flow_logs=subnet_flow_logs)
|
||||
assert len(resources) == 4
|
||||
|
@ -63,9 +62,10 @@ def test_subnet_log_configs(plan_runner):
|
|||
for r in resources:
|
||||
if r['type'] != 'google_compute_subnetwork':
|
||||
continue
|
||||
flow_logs[r['values']['name']] = [{key: config[key] for key in config.keys()
|
||||
& {'aggregation_interval', 'flow_sampling', 'metadata'}}
|
||||
for config in r['values']['log_config']]
|
||||
flow_logs[r['values']['name']] = [{
|
||||
key: config[key] for key in config.keys() &
|
||||
{'aggregation_interval', 'flow_sampling', 'metadata'}
|
||||
} for config in r['values']['log_config']]
|
||||
assert flow_logs == {
|
||||
# enable, override one default option
|
||||
'a': [{
|
||||
|
|
Loading…
Reference in New Issue