Skip to content

Commit

Permalink
Add field cloud_logging_config to resource google_dns_managed_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Sep 27, 2022
1 parent 9f27f27 commit 1a94517
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mmv1/products/dns/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ objects:
description: |
The fully qualified URL of the service directory namespace that should be
associated with the zone. Ignored for `public` visibility zones.
- !ruby/object:Api::Type::NestedObject
name: 'cloudLoggingConfig'
description: 'Cloud logging configuration'
properties:
- !ruby/object:Api::Type::Boolean
name: 'enableLogging'
description: 'If set, enable query logging for this ManagedZone. False by default, making logging opt-in.'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Managing Zones':
Expand Down
5 changes: 5 additions & 0 deletions mmv1/products/dns/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ overrides: !ruby/object:Overrides::ResourceOverrides
vars:
zone_name: "peering-zone"
network_name: "network"
- !ruby/object:Provider::Terraform::Examples
name: "dns_managed_zone_cloud_logging"
primary_resource_id: "cloud-logging-enabled-zone"
properties:
description: !ruby/object:Overrides::Terraform::PropertyOverride
description: |
Expand Down Expand Up @@ -145,6 +148,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
reverseLookup: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/object_to_bool.go.erb
custom_expand: templates/terraform/custom_expand/bool_to_object.go.erb
cloudLoggingConfig: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
virtual_fields:
- !ruby/object:Api::Type::Boolean
name: 'force_destroy'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# [START dns_managed_zone_cloud_logging]
resource "google_dns_managed_zone" "<%= ctx[:primary_resource_id] %>" {
name = "example-zone"
dns_name = "services.example.com."
description = "Example cloud logging enabled DNS zone"
labels = {
foo = "bar"
}

cloud_logging_config {
enable_logging = true
}
}
# [END dns_managed_zone_cloud_logging]
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,44 @@ func TestAccDNSManagedZone_privateForwardingUpdate(t *testing.T) {
})
}

func TestAccDNSManagedZone_cloudLoggingConfigUpdate(t *testing.T) {
t.Parallel()

zoneSuffix := randString(t, 10)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDNSManagedZoneDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDnsManagedZone_cloudLoggingConfig_basic(zoneSuffix),
},
{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDnsManagedZone_cloudLoggingConfig_update(zoneSuffix, true),
},
{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDnsManagedZone_cloudLoggingConfig_update(zoneSuffix, false),
},
{
ResourceName: "google_dns_managed_zone.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

<% unless version.nil? || version == 'ga' -%>
func TestAccDNSManagedZone_reverseLookup(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -404,6 +442,36 @@ resource "google_compute_network" "network-1" {
`, suffix, first_nameserver, first_forwarding_path, second_nameserver, second_forwarding_path, suffix)
}

func testAccDnsManagedZone_cloudLoggingConfig_basic(suffix string) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foobar" {
name = "mzone-test-%s"
dns_name = "tf-acctest-%s.hashicorptest.com."
description = "Example DNS zone"
labels = {
foo = "bar"
}
}
`, suffix, suffix)
}

func testAccDnsManagedZone_cloudLoggingConfig_update(suffix string, enableCloudLogging bool) string {
return fmt.Sprintf(`
resource "google_dns_managed_zone" "foobar" {
name = "mzone-test-%s"
dns_name = "tf-acctest-%s.hashicorptest.com."
description = "Example DNS zone"
labels = {
foo = "bar"
}

cloud_logging_config {
enable_logging = %t
}
}
`, suffix, suffix, enableCloudLogging)
}

<% unless version.nil? || version == 'ga' -%>
func testAccDnsManagedZone_reverseLookup(suffix string) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 1a94517

Please sign in to comment.