provider/google: add failover parameter to sql database instance (#14336)
* provider/google: add failover parameter to sql database instance * provider/google: update sql database instance docs
This commit is contained in:
parent
56f89e20d7
commit
3df593315f
|
@ -270,6 +270,11 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"failover_target": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"master_heartbeat_period": &schema.Schema{
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
|
@ -526,6 +531,10 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
|
|||
mySqlReplicaConfiguration := &sqladmin.MySqlReplicaConfiguration{}
|
||||
_replicaConfiguration := _replicaConfigurationList[0].(map[string]interface{})
|
||||
|
||||
if vp, okp := _replicaConfiguration["failover_target"]; okp {
|
||||
replicaConfiguration.FailoverTarget = vp.(bool)
|
||||
}
|
||||
|
||||
if vp, okp := _replicaConfiguration["ca_certificate"]; okp {
|
||||
mySqlReplicaConfiguration.CaCertificate = vp.(string)
|
||||
}
|
||||
|
@ -835,6 +844,10 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
|
|||
mySqlReplicaConfiguration := instance.ReplicaConfiguration.MysqlReplicaConfiguration
|
||||
_replicaConfiguration := _replicaConfigurationList[0].(map[string]interface{})
|
||||
|
||||
if vp, okp := _replicaConfiguration["failover_target"]; okp && vp != nil {
|
||||
_replicaConfiguration["failover_target"] = instance.ReplicaConfiguration.FailoverTarget
|
||||
}
|
||||
|
||||
if vp, okp := _replicaConfiguration["ca_certificate"]; okp && vp != nil {
|
||||
_replicaConfiguration["ca_certificate"] = mySqlReplicaConfiguration.CaCertificate
|
||||
}
|
||||
|
|
|
@ -408,66 +408,73 @@ func testAccCheckGoogleSqlDatabaseInstanceEquals(n string,
|
|||
return fmt.Errorf("Error settings.pricing_plan mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
if instance.ReplicaConfiguration != nil &&
|
||||
instance.ReplicaConfiguration.MysqlReplicaConfiguration != nil {
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.CaCertificate
|
||||
local = attributes["replica_configuration.0.ca_certificate"]
|
||||
if instance.ReplicaConfiguration != nil {
|
||||
server = strconv.FormatBool(instance.ReplicaConfiguration.FailoverTarget)
|
||||
local = attributes["replica_configuration.0.failover_target"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.ca_certificate mismatch, (%s, %s)", server, local)
|
||||
return fmt.Errorf("Error replica_configuration.failover_target mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.ClientCertificate
|
||||
local = attributes["replica_configuration.0.client_certificate"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.client_certificate mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
if instance.ReplicaConfiguration.MysqlReplicaConfiguration != nil {
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.CaCertificate
|
||||
local = attributes["replica_configuration.0.ca_certificate"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.ca_certificate mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.ClientKey
|
||||
local = attributes["replica_configuration.0.client_key"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.client_key mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.ClientCertificate
|
||||
local = attributes["replica_configuration.0.client_certificate"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.client_certificate mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = strconv.FormatInt(instance.ReplicaConfiguration.MysqlReplicaConfiguration.ConnectRetryInterval, 10)
|
||||
local = attributes["replica_configuration.0.connect_retry_interval"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.connect_retry_interval mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.ClientKey
|
||||
local = attributes["replica_configuration.0.client_key"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.client_key mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.DumpFilePath
|
||||
local = attributes["replica_configuration.0.dump_file_path"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.dump_file_path mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = strconv.FormatInt(instance.ReplicaConfiguration.MysqlReplicaConfiguration.ConnectRetryInterval, 10)
|
||||
local = attributes["replica_configuration.0.connect_retry_interval"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.connect_retry_interval mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = strconv.FormatInt(instance.ReplicaConfiguration.MysqlReplicaConfiguration.MasterHeartbeatPeriod, 10)
|
||||
local = attributes["replica_configuration.0.master_heartbeat_period"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.master_heartbeat_period mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.DumpFilePath
|
||||
local = attributes["replica_configuration.0.dump_file_path"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.dump_file_path mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.Password
|
||||
local = attributes["replica_configuration.0.password"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.password mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = strconv.FormatInt(instance.ReplicaConfiguration.MysqlReplicaConfiguration.MasterHeartbeatPeriod, 10)
|
||||
local = attributes["replica_configuration.0.master_heartbeat_period"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.master_heartbeat_period mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.SslCipher
|
||||
local = attributes["replica_configuration.0.ssl_cipher"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.ssl_cipher mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.Password
|
||||
local = attributes["replica_configuration.0.password"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.password mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.Username
|
||||
local = attributes["replica_configuration.0.username"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.username mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.SslCipher
|
||||
local = attributes["replica_configuration.0.ssl_cipher"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.ssl_cipher mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = strconv.FormatBool(instance.ReplicaConfiguration.MysqlReplicaConfiguration.VerifyServerCertificate)
|
||||
local = attributes["replica_configuration.0.verify_server_certificate"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.verify_server_certificate mismatch, (%s, %s)", server, local)
|
||||
server = instance.ReplicaConfiguration.MysqlReplicaConfiguration.Username
|
||||
local = attributes["replica_configuration.0.username"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.username mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
|
||||
server = strconv.FormatBool(instance.ReplicaConfiguration.MysqlReplicaConfiguration.VerifyServerCertificate)
|
||||
local = attributes["replica_configuration.0.verify_server_certificate"]
|
||||
if server != local && len(server) > 0 && len(local) > 0 {
|
||||
return fmt.Errorf("Error replica_configuration.verify_server_certificate mismatch, (%s, %s)", server, local)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,11 @@ to work, cannot be updated, and supports:
|
|||
* `dump_file_path` - (Optional) Path to a SQL file in GCS from which slave
|
||||
instances are created. Format is `gs://bucket/filename`.
|
||||
|
||||
* `failover_target` - (Optional) Specifies if the replica is the failover target.
|
||||
If the field is set to true the replica will be designated as a failover replica.
|
||||
If the master instance fails, the replica instance will be promoted as
|
||||
the new master instance.
|
||||
|
||||
* `master_heartbeat_period` - (Optional) Time in ms between replication
|
||||
heartbeats.
|
||||
|
||||
|
|
Loading…
Reference in New Issue