Added iam for DNS managed zone to dns module
This commit is contained in:
parent
a68a3b55cb
commit
ddfab0a0e4
|
@ -20,8 +20,11 @@ module "private-dns" {
|
|||
"A localhost" = { records = ["127.0.0.1"] }
|
||||
"A myhost" = { ttl = 600, records = ["10.0.0.120"] }
|
||||
}
|
||||
iam = {
|
||||
"roles/dns.admin" = ["group:dns-administrators@myorg.com"]
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=3 inventory=private-zone.yaml
|
||||
# tftest modules=1 resources=4 inventory=private-zone.yaml
|
||||
```
|
||||
|
||||
### Forwarding Zone
|
||||
|
@ -114,8 +117,11 @@ module "public-dns" {
|
|||
recordsets = {
|
||||
"A myhost" = { ttl = 300, records = ["127.0.0.1"] }
|
||||
}
|
||||
iam = {
|
||||
"roles/dns.admin" = ["group:dns-administrators@myorg.com"]
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=3 inventory=public-zone.yaml
|
||||
# tftest modules=1 resources=4 inventory=public-zone.yaml
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
@ -124,18 +130,19 @@ module "public-dns" {
|
|||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [domain](variables.tf#L54) | Zone domain, must end with a period. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L72) | Zone name, must be unique within the project. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L83) | Project id for the zone. | <code>string</code> | ✓ | |
|
||||
| [name](variables.tf#L78) | Zone name, must be unique within the project. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L89) | Project id for the zone. | <code>string</code> | ✓ | |
|
||||
| [client_networks](variables.tf#L21) | List of VPC self links that can see this zone. | <code>list(string)</code> | | <code>[]</code> |
|
||||
| [description](variables.tf#L28) | Domain description. | <code>string</code> | | <code>"Terraform managed."</code> |
|
||||
| [dnssec_config](variables.tf#L34) | DNSSEC configuration for this zone. | <code title="object({ non_existence = optional(string, "nsec3") state = string key_signing_key = optional(object( { algorithm = string, key_length = number }), { algorithm = "rsasha256", key_length = 2048 } ) zone_signing_key = optional(object( { algorithm = string, key_length = number }), { algorithm = "rsasha256", key_length = 1024 } ) })">object({…})</code> | | <code title="{ state = "off" }">{…}</code> |
|
||||
| [enable_logging](variables.tf#L59) | Enable query logging for this zone. | <code>bool</code> | | <code>false</code> |
|
||||
| [forwarders](variables.tf#L66) | Map of {IPV4_ADDRESS => FORWARDING_PATH} for 'forwarding' zone types. Path can be 'default', 'private', or null for provider default. | <code>map(string)</code> | | <code>{}</code> |
|
||||
| [peer_network](variables.tf#L77) | Peering network self link, only valid for 'peering' zone types. | <code>string</code> | | <code>null</code> |
|
||||
| [recordsets](variables.tf#L88) | Map of DNS recordsets in \"type name\" => {ttl, [records]} format. | <code title="map(object({ ttl = optional(number, 300) records = optional(list(string)) geo_routing = optional(list(object({ location = string records = list(string) }))) wrr_routing = optional(list(object({ weight = number records = list(string) }))) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [service_directory_namespace](variables.tf#L123) | Service directory namespace id (URL), only valid for 'service-directory' zone types. | <code>string</code> | | <code>null</code> |
|
||||
| [type](variables.tf#L129) | Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory','reverse-managed'. | <code>string</code> | | <code>"private"</code> |
|
||||
| [zone_create](variables.tf#L139) | Create zone. When set to false, uses a data source to reference existing zone. | <code>bool</code> | | <code>true</code> |
|
||||
| [iam](variables.tf#L72) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>null</code> |
|
||||
| [peer_network](variables.tf#L83) | Peering network self link, only valid for 'peering' zone types. | <code>string</code> | | <code>null</code> |
|
||||
| [recordsets](variables.tf#L94) | Map of DNS recordsets in \"type name\" => {ttl, [records]} format. | <code title="map(object({ ttl = optional(number, 300) records = optional(list(string)) geo_routing = optional(list(object({ location = string records = list(string) }))) wrr_routing = optional(list(object({ weight = number records = list(string) }))) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [service_directory_namespace](variables.tf#L129) | Service directory namespace id (URL), only valid for 'service-directory' zone types. | <code>string</code> | | <code>null</code> |
|
||||
| [type](variables.tf#L135) | Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory','reverse-managed'. | <code>string</code> | | <code>"private"</code> |
|
||||
| [zone_create](variables.tf#L145) | Create zone. When set to false, uses a data source to reference existing zone. | <code>bool</code> | | <code>true</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -178,6 +178,16 @@ resource "google_dns_managed_zone" "public" {
|
|||
}
|
||||
}
|
||||
|
||||
resource "google_dns_managed_zone_iam_binding" "iam_bindings" {
|
||||
for_each = coalesce(var.iam, {})
|
||||
project = var.project_id
|
||||
managed_zone = (var.type == "public"
|
||||
? google_dns_managed_zone.public[0].name
|
||||
: google_dns_managed_zone.non-public[0].name)
|
||||
role = each.key
|
||||
members = each.value
|
||||
}
|
||||
|
||||
data "google_dns_keys" "dns_keys" {
|
||||
count = var.zone_create && (var.dnssec_config == {} || var.type != "public") ? 0 : 1
|
||||
managed_zone = local.zone.id
|
||||
|
|
|
@ -69,6 +69,12 @@ variable "forwarders" {
|
|||
default = {}
|
||||
}
|
||||
|
||||
variable "iam" {
|
||||
description = "IAM bindings in {ROLE => [MEMBERS]} format."
|
||||
type = map(list(string))
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
description = "Zone name, must be unique within the project."
|
||||
type = string
|
||||
|
|
|
@ -48,3 +48,4 @@ values:
|
|||
counts:
|
||||
google_dns_managed_zone: 1
|
||||
google_dns_record_set: 2
|
||||
google_dns_managed_zone_iam_binding: 1
|
||||
|
|
|
@ -32,7 +32,8 @@ counts:
|
|||
google_dns_keys: 1
|
||||
google_dns_managed_zone: 1
|
||||
google_dns_record_set: 1
|
||||
google_dns_managed_zone_iam_binding: 1
|
||||
modules: 1
|
||||
resources: 3
|
||||
resources: 4
|
||||
|
||||
outputs: {}
|
||||
|
|
Loading…
Reference in New Issue