mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-09 03:28:29 +00:00
SQL DB Instance has attribute first_ip_address (#1050)
* Expose first ip address on sql db instance. Signed-off-by: Desmond Pompa Alarcon Rawls <captaingrover@gmail.com> * Use the ip_address key on the first map in ip_address list. Signed-off-by: Genevieve LEsperance <glesperance@pivotal.io> * Run first_ip_address test check if there is an ip address. Signed-off-by: Desmond Pompa Alarcon Rawls <captaingrover@gmail.com> * Add first_ip_address to sql db instance scheme. Signed-off-by: Genevieve LEsperance <glesperance@pivotal.io>
This commit is contained in:
parent
58a7ef9d03
commit
7e358d894a
|
@ -257,6 +257,11 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"first_ip_address": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -729,13 +734,23 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
|
||||||
if err := d.Set("settings", flattenSettings(instance.Settings)); err != nil {
|
if err := d.Set("settings", flattenSettings(instance.Settings)); err != nil {
|
||||||
log.Printf("[WARN] Failed to set SQL Database Instance Settings")
|
log.Printf("[WARN] Failed to set SQL Database Instance Settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := d.Set("replica_configuration", flattenReplicaConfiguration(instance.ReplicaConfiguration)); err != nil {
|
if err := d.Set("replica_configuration", flattenReplicaConfiguration(instance.ReplicaConfiguration)); err != nil {
|
||||||
log.Printf("[WARN] Failed to set SQL Database Instance Replica Configuration")
|
log.Printf("[WARN] Failed to set SQL Database Instance Replica Configuration")
|
||||||
}
|
}
|
||||||
if err := d.Set("ip_address", flattenIpAddresses(instance.IpAddresses)); err != nil {
|
|
||||||
|
ipAddresses := flattenIpAddresses(instance.IpAddresses)
|
||||||
|
if err := d.Set("ip_address", ipAddresses); err != nil {
|
||||||
log.Printf("[WARN] Failed to set SQL Database Instance IP Addresses")
|
log.Printf("[WARN] Failed to set SQL Database Instance IP Addresses")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ipAddresses) > 0 {
|
||||||
|
firstIpAddress := ipAddresses[0]["ip_address"]
|
||||||
|
if err := d.Set("first_ip_address", firstIpAddress); err != nil {
|
||||||
|
log.Printf("[WARN] Failed to set SQL Database Instance First IP Address")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := d.Set("server_ca_cert", flattenServerCaCert(instance.ServerCaCert)); err != nil {
|
if err := d.Set("server_ca_cert", flattenServerCaCert(instance.ServerCaCert)); err != nil {
|
||||||
log.Printf("[WARN] Failed to set SQL Database CA Certificate")
|
log.Printf("[WARN] Failed to set SQL Database CA Certificate")
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,6 +570,14 @@ func testAccCheckGoogleSqlDatabaseInstanceEquals(n string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(instance.IpAddresses) > 0 {
|
||||||
|
server = instance.IpAddresses[0].IpAddress
|
||||||
|
local = attributes["first_ip_address"]
|
||||||
|
if server != local {
|
||||||
|
return fmt.Errorf("Error first_ip_address mismatch, server has %s but local has %s", server, local)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server = instance.Settings.ActivationPolicy
|
server = instance.Settings.ActivationPolicy
|
||||||
local = attributes["settings.0.activation_policy"]
|
local = attributes["settings.0.activation_policy"]
|
||||||
if server != local && len(server) > 0 && len(local) > 0 {
|
if server != local && len(server) > 0 && len(local) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user