Merge pull request #5245 from lwander/f-gcp-sql-address

provider/google: Add support for reading SQL instance assigned IP Addresses
This commit is contained in:
Lars Wander 2016-02-22 10:55:04 -05:00
commit 252db7bacd
2 changed files with 38 additions and 0 deletions

View File

@ -170,6 +170,23 @@ func resourceSqlDatabaseInstance() *schema.Resource {
},
},
},
"ip_address": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"time_to_retire": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
},
"replica_configuration": &schema.Schema{
Type: schema.TypeList,
Optional: true,
@ -700,6 +717,19 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
}
}
_ipAddresses := make([]interface{}, len(instance.IpAddresses))
for i, ip := range instance.IpAddresses {
_ipAddress := make(map[string]interface{})
_ipAddress["ip_address"] = ip.IpAddress
_ipAddress["time_to_retire"] = ip.TimeToRetire
_ipAddresses[i] = _ipAddress
}
d.Set("ip_address", _ipAddresses)
if v, ok := d.GetOk("master_instance_name"); ok && v != nil {
d.Set("master_instance_name", instance.MasterInstanceName)
}

View File

@ -148,3 +148,11 @@ The following attributes are exported:
The `settings` block exports:
* `version` - Used to make sure changes to the `settings` block are atomic.
The `ip_address` block exports a list of IPv4 addresses assigned to this
instance, with the following properties:
* `ip_address` - The IPv4 address assigned.
* `time_to_retire` - The time this IP address will be retired, in RFC 3339
format.