Skip to content

Commit

Permalink
Terraform: Cloud DNS logging (#573)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @drebes
  • Loading branch information
modular-magician authored and rileykarson committed Apr 1, 2019
1 parent 9d1ea62 commit af99e22
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
30 changes: 29 additions & 1 deletion google-beta/resource_dns_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func resourceDnsPolicy() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"enable_logging": {
Type: schema.TypeBool,
Optional: true,
},
"networks": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -148,6 +152,12 @@ func resourceDnsPolicyCreate(d *schema.ResourceData, meta interface{}) error {
} else if v, ok := d.GetOkExists("enable_inbound_forwarding"); ok || !reflect.DeepEqual(v, enableInboundForwardingProp) {
obj["enableInboundForwarding"] = enableInboundForwardingProp
}
enableLoggingProp, err := expandDnsPolicyEnableLogging(d.Get("enable_logging"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enable_logging"); ok || !reflect.DeepEqual(v, enableLoggingProp) {
obj["enableLogging"] = enableLoggingProp
}
nameProp, err := expandDnsPolicyName(d.Get("name"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -214,6 +224,9 @@ func resourceDnsPolicyRead(d *schema.ResourceData, meta interface{}) error {
if err := d.Set("enable_inbound_forwarding", flattenDnsPolicyEnableInboundForwarding(res["enableInboundForwarding"], d)); err != nil {
return fmt.Errorf("Error reading Policy: %s", err)
}
if err := d.Set("enable_logging", flattenDnsPolicyEnableLogging(res["enableLogging"], d)); err != nil {
return fmt.Errorf("Error reading Policy: %s", err)
}
if err := d.Set("name", flattenDnsPolicyName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading Policy: %s", err)
}
Expand All @@ -229,7 +242,7 @@ func resourceDnsPolicyUpdate(d *schema.ResourceData, meta interface{}) error {

d.Partial(true)

if d.HasChange("alternative_name_server_config") || d.HasChange("description") || d.HasChange("enable_inbound_forwarding") || d.HasChange("networks") {
if d.HasChange("alternative_name_server_config") || d.HasChange("description") || d.HasChange("enable_inbound_forwarding") || d.HasChange("enable_logging") || d.HasChange("networks") {
obj := make(map[string]interface{})
alternativeNameServerConfigProp, err := expandDnsPolicyAlternativeNameServerConfig(d.Get("alternative_name_server_config"), d, config)
if err != nil {
Expand All @@ -249,6 +262,12 @@ func resourceDnsPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
} else if v, ok := d.GetOkExists("enable_inbound_forwarding"); ok || !reflect.DeepEqual(v, enableInboundForwardingProp) {
obj["enableInboundForwarding"] = enableInboundForwardingProp
}
enableLoggingProp, err := expandDnsPolicyEnableLogging(d.Get("enable_logging"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("enable_logging"); ok || !reflect.DeepEqual(v, enableLoggingProp) {
obj["enableLogging"] = enableLoggingProp
}
networksProp, err := expandDnsPolicyNetworks(d.Get("networks"), d, config)
if err != nil {
return err
Expand All @@ -268,6 +287,7 @@ func resourceDnsPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
d.SetPartial("alternative_name_server_config")
d.SetPartial("description")
d.SetPartial("enable_inbound_forwarding")
d.SetPartial("enable_logging")
d.SetPartial("networks")
}

Expand Down Expand Up @@ -377,6 +397,10 @@ func flattenDnsPolicyEnableInboundForwarding(v interface{}, d *schema.ResourceDa
return v
}

func flattenDnsPolicyEnableLogging(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenDnsPolicyName(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -465,6 +489,10 @@ func expandDnsPolicyEnableInboundForwarding(v interface{}, d TerraformResourceDa
return v, nil
}

func expandDnsPolicyEnableLogging(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandDnsPolicyName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
2 changes: 2 additions & 0 deletions google-beta/resource_dns_policy_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ resource "google_dns_policy" "example-policy" {
name = "example-policy-%{random_suffix}"
enable_inbound_forwarding = true
enable_logging = true
alternative_name_server_config {
target_name_servers {
ipv4_address = "172.16.1.10"
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/dns_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ resource "google_dns_policy" "example-policy" {
name = "example-policy"
enable_inbound_forwarding = true
enable_logging = true
alternative_name_server_config {
target_name_servers {
ipv4_address = "172.16.1.10"
Expand Down Expand Up @@ -116,6 +118,11 @@ The following arguments are supported:
virtual IP address will be allocated from each of the sub-networks
that are bound to this policy.

* `enable_logging` -
(Optional)
Controls whether logging is enabled for the networks bound to this policy.
Defaults to no logging if not set.

* `networks` -
(Optional)
List of network names specifying networks to which this policy is applied. Structure is documented below.
Expand Down

0 comments on commit af99e22

Please sign in to comment.