in alicloud/resource_alicloud_rds_ddr_instance.go [21:483]
func resourceAlicloudRdsDdrInstance() *schema.Resource {
return &schema.Resource{
Create: resourceAlicloudRdsDdrInstanceCreate,
Read: resourceAlicloudRdsDdrInstanceRead,
Update: resourceAlicloudRdsDdrInstanceUpdate,
Delete: resourceAlicloudRdsDdrInstanceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(90 * time.Minute),
Update: schema.DefaultTimeout(30 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
},
Schema: map[string]*schema.Schema{
"engine": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
ValidateFunc: validation.StringInSlice([]string{string(MySQL), string(SQLServer)}, false),
},
"engine_version": {
Type: schema.TypeString,
Required: true,
},
"instance_type": {
Type: schema.TypeString,
Required: true,
},
"instance_storage": {
Type: schema.TypeInt,
Required: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if v, ok := d.GetOk("storage_auto_scale"); ok && v.(string) == "Enable" {
return true
}
return false
},
},
"payment_type": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"PayAsYouGo", "Subscription"}, false),
Required: true,
},
"period": {
Type: schema.TypeInt,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36}),
Optional: true,
DiffSuppressFunc: PostPaidDiffSuppressFunc,
},
"monitoring_period": {
Type: schema.TypeInt,
ValidateFunc: validation.IntInSlice([]int{5, 60, 300}),
Optional: true,
Computed: true,
},
"auto_renew": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
DiffSuppressFunc: PostPaidDiffSuppressFunc,
},
"auto_renew_period": {
Type: schema.TypeInt,
ValidateFunc: validation.IntBetween(1, 12),
Optional: true,
Computed: true,
DiffSuppressFunc: PostPaidAndRenewDiffSuppressFunc,
},
"zone_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
"vswitch_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// If it is a new resource, do not suppress.
if d.Id() == "" {
return false
}
// If it is not a new resource and it is a multi-zone deployment, it needs to be suppressed.
return len(strings.Split(new, ",")) > 1
},
},
"private_ip_address": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"instance_name": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(2, 256),
},
"connection_string": {
Type: schema.TypeString,
Computed: true,
},
"connection_string_prefix": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(8, 64),
Computed: true,
},
"port": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"security_ips": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Optional: true,
},
"db_instance_ip_array_name": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: securityIpsDiffSuppressFunc,
},
"db_instance_ip_array_attribute": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: securityIpsDiffSuppressFunc,
},
"security_ip_type": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: securityIpsDiffSuppressFunc,
},
"whitelist_network_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Classic", "VPC", "MIX"}, false),
DiffSuppressFunc: securityIpsDiffSuppressFunc,
},
"modify_mode": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Cover", "Append", "Delete"}, false),
DiffSuppressFunc: securityIpsDiffSuppressFunc,
},
"security_group_ids": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Optional: true,
},
"security_ip_mode": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{NormalMode, SafetyMode}, false),
Optional: true,
Computed: true,
},
"parameters": {
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"value": {
Type: schema.TypeString,
Required: true,
},
},
},
Set: parameterToHashDdr,
Optional: true,
Computed: true,
},
"pg_hba_conf": {
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
},
"mask": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"database": {
Type: schema.TypeString,
Required: true,
},
"priority_id": {
Type: schema.TypeInt,
Required: true,
},
"address": {
Type: schema.TypeString,
Required: true,
},
"user": {
Type: schema.TypeString,
Required: true,
},
"method": {
Type: schema.TypeString,
Required: true,
},
"option": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
},
},
Optional: true,
Computed: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Get("engine").(string) != string(PostgreSQL)
},
},
"force_restart": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"tags": tagsSchema(),
"maintain_time": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"auto_upgrade_minor_version": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"Auto", "Manual"}, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Get("engine").(string) != "MySQL"
},
},
"db_instance_storage_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"local_ssd", "cloud_ssd", "cloud_essd", "cloud_essd2", "cloud_essd3"}, false),
},
"sql_collector_status": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Enabled", "Disabled"}, false),
Computed: true,
},
"sql_collector_config_value": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntInSlice([]int{30, 180, 365, 1095, 1825}),
Computed: true,
},
"resource_group_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"ssl_action": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"Open", "Close", "Update"}, false),
Optional: true,
Computed: true,
},
"tde_status": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"Enabled"}, false),
Optional: true,
ForceNew: true,
},
"ssl_status": {
Type: schema.TypeString,
Computed: true,
},
"encryption_key": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Get("engine").(string) != "MySQL" && d.Get("engine").(string) != "SQLServer"
},
},
"ca_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"server_cert": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"server_key": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"client_ca_enabled": {
Type: schema.TypeInt,
Optional: true,
},
"client_ca_cert": {
Type: schema.TypeString,
Optional: true,
},
"client_crl_enabled": {
Type: schema.TypeInt,
Optional: true,
},
"client_cert_revocation_list": {
Type: schema.TypeString,
Optional: true,
},
"acl": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"replication_acl": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"zone_id_slave_a": {
Type: schema.TypeString,
Computed: true,
},
"zone_id_slave_b": {
Type: schema.TypeString,
Computed: true,
},
"upgrade_db_instance_kernel_version": {
Type: schema.TypeBool,
Optional: true,
},
"upgrade_time": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Immediate", "MaintainTime", "SpecifyTime"}, false),
DiffSuppressFunc: kernelVersionDiffSuppressFunc,
},
"switch_time": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: kernelVersionDiffSuppressFunc,
},
"target_minor_version": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: kernelVersionDiffSuppressFunc,
Computed: true,
},
"storage_auto_scale": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"Enable", "Disable"}, false),
Optional: true,
},
"storage_threshold": {
Type: schema.TypeInt,
ValidateFunc: validation.IntInSlice([]int{10, 20, 30, 40, 50}),
DiffSuppressFunc: StorageAutoScaleDiffSuppressFunc,
Optional: true,
},
"storage_upper_bound": {
Type: schema.TypeInt,
ValidateFunc: validation.IntAtLeast(0),
DiffSuppressFunc: StorageAutoScaleDiffSuppressFunc,
Optional: true,
},
"ha_config": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"Auto", "Manual"}, false),
},
"manual_ha_time": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if v, ok := d.GetOk("ha_config"); ok && v.(string) == "Manual" {
return false
}
return true
},
},
"released_keep_policy": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"None", "Lastest", "All"}, false),
},
"fresh_white_list_readins": {
Type: schema.TypeString,
Optional: true,
},
"deletion_protection": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
"tcp_connection_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"SHORT", "LONG"}, false),
},
"vpc_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"category": {
Type: schema.TypeString,
Computed: true,
},
"effective_time": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"Immediate", "MaintainTime"}, false),
},
"restore_type": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"BackupSet", "BackupTime"}, false),
},
"backup_set_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"restore_time": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"source_region": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"source_db_instance_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}
}