Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL DB Instance has attribute first_ip_address #1050

Merged
merged 4 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ func resourceSqlDatabaseInstance() *schema.Resource {
},
},

"first_ip_address": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -729,13 +734,23 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("settings", flattenSettings(instance.Settings)); err != nil {
log.Printf("[WARN] Failed to set SQL Database Instance Settings")
}

if err := d.Set("replica_configuration", flattenReplicaConfiguration(instance.ReplicaConfiguration)); err != nil {
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")
}

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 {
log.Printf("[WARN] Failed to set SQL Database CA Certificate")
}
Expand Down
8 changes: 8 additions & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
local = attributes["settings.0.activation_policy"]
if server != local && len(server) > 0 && len(local) > 0 {
Expand Down