Skip to content

Commit 20f8104

Browse files
author
Lars Wander
committed
provider/google: Add support for reading SQL instance assigned IP Addresses
1 parent 0214319 commit 20f8104

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎builtin/providers/google/resource_sql_database_instance.go‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ func resourceSqlDatabaseInstance() *schema.Resource {
170170
},
171171
},
172172
},
173+
"ip_address": &schema.Schema{
174+
Type: schema.TypeList,
175+
Computed: true,
176+
Elem: &schema.Resource{
177+
Schema: map[string]*schema.Schema{
178+
"ip_address": &schema.Schema{
179+
Type: schema.TypeString,
180+
Computed: true,
181+
},
182+
"time_to_retire": &schema.Schema{
183+
Type: schema.TypeString,
184+
Optional: true,
185+
Computed: true,
186+
},
187+
},
188+
},
189+
},
173190
"replica_configuration": &schema.Schema{
174191
Type: schema.TypeList,
175192
Optional: true,
@@ -700,6 +717,19 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
700717
}
701718
}
702719

720+
_ipAddresses := make([]interface{}, len(instance.IpAddresses))
721+
722+
for i, ip := range instance.IpAddresses {
723+
_ipAddress := make(map[string]interface{})
724+
725+
_ipAddress["ip_address"] = ip.IpAddress
726+
_ipAddress["time_to_retire"] = ip.TimeToRetire
727+
728+
_ipAddresses[i] = _ipAddress
729+
}
730+
731+
d.Set("ip_address", _ipAddresses)
732+
703733
if v, ok := d.GetOk("master_instance_name"); ok && v != nil {
704734
d.Set("master_instance_name", instance.MasterInstanceName)
705735
}

‎website/source/docs/providers/google/r/sql_database_instance.html.markdown‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,11 @@ The following attributes are exported:
148148
The `settings` block exports:
149149

150150
* `version` - Used to make sure changes to the `settings` block are atomic.
151+
152+
The `ip_address` block exports a list of IPv4 addresses assigned to this
153+
instance, with the following properties:
154+
155+
* `ip_address` - The IPv4 address assigned.
156+
157+
* `time_to_retire` - The time this IP address will be retired, in RFC 3339
158+
format.

0 commit comments

Comments
 (0)