mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
Add labels functionality to managed DNS
This commit is contained in:
parent
62cee9bcea
commit
c74d7d2c60
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user