Merge pull request #2009 from chrisst/is-1803-dns-labels

Add labels functionality to managed DNS
This commit is contained in:
Chris Stephens 2018-09-11 13:03:56 -07:00 committed by GitHub
commit 82e19ea060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 0 deletions

View File

@ -53,6 +53,12 @@ func resourceDnsManagedZone() *schema.Resource {
Computed: true,
ForceNew: true,
},
"labels": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}
@ -72,7 +78,12 @@ func resourceDnsManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro
Description: d.Get("description").(string),
}
if _, ok := d.GetOk("labels"); ok {
zone.Labels = expandLabels(d)
}
log.Printf("[DEBUG] DNS ManagedZone create request: %#v", zone)
zone, err = config.clientDns.ManagedZones.Create(project, zone).Do()
if err != nil {
return fmt.Errorf("Error creating DNS ManagedZone: %s", err)
@ -102,6 +113,7 @@ func resourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error
d.Set("dns_name", zone.DnsName)
d.Set("description", zone.Description)
d.Set("project", project)
d.Set("labels", zone.Labels)
return nil
}
@ -120,6 +132,10 @@ func resourceDnsManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro
Description: d.Get("description").(string),
}
if _, ok := d.GetOk("labels"); ok {
zone.Labels = expandLabels(d)
}
op, err := config.clientDnsBeta.ManagedZones.Patch(project, d.Id(), zone).Do()
if err != nil {
return err

View File

@ -85,5 +85,8 @@ resource "google_dns_managed_zone" "foobar" {
name = "mzone-test-%s"
dns_name = "tf-acctest-%s.hashicorptest.com."
description = "%s"
labels = {
foo = "bar"
}
}`, suffix, suffix, description)
}

View File

@ -18,6 +18,10 @@ resource "google_dns_managed_zone" "prod" {
name = "prod-zone"
dns_name = "prod.mydomain.com."
description = "Production DNS zone"
labels = {
foo = "bar"
}
}
```
@ -37,6 +41,8 @@ The following arguments are supported:
* `project` - (Optional) The ID of the project in which the resource belongs. If it
is not provided, the provider project is used.
* `labels` - (Optional) A set of key/value label pairs to assign to the instance.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are