diff --git a/builtin/providers/google/resource_sql_database_instance.go b/builtin/providers/google/resource_sql_database_instance.go index 6ca416e88..e4d1c3087 100644 --- a/builtin/providers/google/resource_sql_database_instance.go +++ b/builtin/providers/google/resource_sql_database_instance.go @@ -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) } diff --git a/website/source/docs/providers/google/r/sql_database_instance.html.markdown b/website/source/docs/providers/google/r/sql_database_instance.html.markdown index ae3a1d20a..253132c47 100644 --- a/website/source/docs/providers/google/r/sql_database_instance.html.markdown +++ b/website/source/docs/providers/google/r/sql_database_instance.html.markdown @@ -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.