in alicloud/resource_alicloud_polardb_cluster.go [20:522]
func resourceAlicloudPolarDBCluster() *schema.Resource {
return &schema.Resource{
Create: resourceAlicloudPolarDBClusterCreate,
Read: resourceAlicloudPolarDBClusterRead,
Update: resourceAlicloudPolarDBClusterUpdate,
Delete: resourceAlicloudPolarDBClusterDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(50 * time.Minute),
Update: schema.DefaultTimeout(50 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Schema: map[string]*schema.Schema{
"db_type": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
},
"db_version": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
},
"db_minor_version": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"8.0.1", "8.0.2"}, false),
ForceNew: true,
Optional: true,
Computed: true,
},
"db_node_class": {
Type: schema.TypeString,
Required: true,
},
"modify_type": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"Upgrade", "Downgrade"}, false),
Optional: true,
Default: "Upgrade",
},
"db_node_count": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(1, 16),
Computed: true,
},
"zone_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"standby_az": {
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: polardbStandbyAzDiffSuppressFunc,
},
"pay_type": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{string(PostPaid), string(PrePaid)}, false),
Optional: true,
Default: PostPaid,
},
"renewal_status": {
Type: schema.TypeString,
Optional: true,
Default: RenewNotRenewal,
ValidateFunc: StringInSlice([]string{
string(RenewAutoRenewal),
string(RenewNormal),
string(RenewNotRenewal)}, false),
DiffSuppressFunc: polardbPostPaidDiffSuppressFunc,
},
"auto_renew_period": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ValidateFunc: IntInSlice([]int{1, 2, 3, 6, 12, 24, 36}),
DiffSuppressFunc: polardbPostPaidAndRenewDiffSuppressFunc,
},
"period": {
Type: schema.TypeInt,
ValidateFunc: IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36}),
Optional: true,
DiffSuppressFunc: polardbPostPaidDiffSuppressFunc,
},
"db_cluster_ip_array": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"db_cluster_ip_array_name": {
Type: schema.TypeString,
Optional: true,
Default: "default",
},
"security_ips": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
},
"modify_mode": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"Cover", "Append", "Delete"}, false),
},
},
},
},
"security_ips": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Optional: true,
},
"connection_string": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeString,
Computed: true,
},
"vswitch_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"maintain_time": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validateMaintainTimeRange,
},
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringLenBetween(2, 256),
},
"resource_group_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
"collector_status": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"Enable", "Disabled"}, 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: parameterToHash,
Optional: true,
Computed: true,
},
"tde_status": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"Enabled", "Disabled"}, false),
Optional: true,
Default: "Disabled",
},
"encrypt_new_tables": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
Optional: true,
},
"encryption_key": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: polardbTDEAndEnabledDiffSuppressFunc,
},
"role_arn": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: polardbTDEAndEnabledDiffSuppressFunc,
Computed: true,
},
"tde_region": {
Type: schema.TypeString,
Computed: true,
},
"security_group_ids": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Optional: true,
},
"deletion_lock": {
Type: schema.TypeInt,
ValidateFunc: IntInSlice([]int{0, 1}),
Optional: true,
},
"backup_retention_policy_on_cluster_deletion": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"ALL", "LATEST", "NONE"}, false),
},
"imci_switch": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
},
"sub_category": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"Exclusive", "General"}, false),
Optional: true,
Computed: true,
},
"creation_category": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: StringInSlice([]string{"Normal", "Basic", "ArchiveNormal", "NormalMultimaster", "SENormal"}, false),
},
"creation_option": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"Normal", "CloneFromPolarDB", "CloneFromRDS", "MigrationFromRDS", "CreateGdnStandby", "RecoverFromRecyclebin"}, false),
Optional: true,
Computed: true,
},
"source_resource_id": {
Type: schema.TypeString,
Optional: true,
},
"gdn_id": {
Type: schema.TypeString,
Optional: true,
},
"clone_data_point": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{"LATEST", "BackupID", "Timestamp"}, false),
Optional: true,
},
"storage_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"PSL5", "PSL4", "ESSDPL0", "ESSDPL1", "ESSDPL2", "ESSDPL3", "ESSDAUTOPL"}, false),
Computed: true,
},
"provisioned_iops": {
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: polardbStorageTypeDiffSuppressFunc,
},
"storage_pay_type": {
Type: schema.TypeString,
ValidateFunc: StringInSlice([]string{string(PostPaid), string(PrePaid)}, false),
Optional: true,
ForceNew: true,
Computed: true,
},
"storage_space": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(20, 100000),
Computed: true,
},
"hot_standby_cluster": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF", "EQUAL"}, false),
Computed: true,
ForceNew: true,
},
"strict_consistency": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
Computed: true,
ForceNew: true,
},
"serverless_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"AgileServerless", "SteadyServerless"}, false),
},
"serverless_steady_switch": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
},
"scale_min": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 31),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"scale_max": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 32),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"scale_ro_num_min": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 15),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"scale_ro_num_max": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 15),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"allow_shut_down": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"true", "false"}, false),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"seconds_until_auto_pause": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: IntBetween(300, 86400),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
},
"scale_ap_ro_num_min": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 7),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
Computed: true,
},
"scale_ap_ro_num_max": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(0, 7),
DiffSuppressFunc: polardbServrelessTypeDiffSuppressFunc,
Computed: true,
},
"tags": tagsSchema(),
"vpc_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"create_time": {
Type: schema.TypeString,
Computed: true,
},
"upgrade_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"PROXY", "DB", "ALL"}, false),
},
"from_time_service": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"true", "false"}, false),
},
"planned_start_time": {
Type: schema.TypeString,
Optional: true,
},
"planned_end_time": {
Type: schema.TypeString,
Optional: true,
},
"proxy_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"EXCLUSIVE", "GENERAL"}, false),
DiffSuppressFunc: polardbProxyTypeDiffSuppressFunc,
},
"proxy_class": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"polar.maxscale.g2.medium.c", "polar.maxscale.g2.large.c",
"polar.maxscale.g2.xlarge.c", "polar.maxscale.g2.2xlarge.c", "polar.maxscale.g2.3xlarge.c",
"polar.maxscale.g2.4xlarge.c", "polar.maxscale.g2.8xlarge.c"}, false),
DiffSuppressFunc: polardbProxyClassDiffSuppressFunc,
},
"loose_polar_log_bin": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
DiffSuppressFunc: polardbDiffSuppressFunc,
},
"db_node_num": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(1, 16),
DiffSuppressFunc: polardbProxyTypeDiffSuppressFunc,
},
"parameter_group_id": {
Type: schema.TypeString,
Optional: true,
},
"lower_case_table_names": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: IntInSlice([]int{0, 1}),
DiffSuppressFunc: polardbDiffSuppressFunc,
},
"default_time_zone": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"-12:00", "-11:00", "-10:00", "-9:00", "-8:00", "-7:00",
"-6:00", "-5:00", "-4:00", "-3:00", "-2:00", "-1:00",
"+0:00", "+1:00", "+2:00", "+3:00", "+4:00", "+5:00",
"+6:00", "+7:00", "+8:00", "+9:00", "+10:00", "+11:00",
"+12:00", "+13:00", "SYSTEM"}, false),
DiffSuppressFunc: polardbDiffSuppressFunc,
},
"loose_xengine": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
DiffSuppressFunc: polardbXengineDiffSuppressFunc,
Computed: true,
},
"loose_xengine_use_memory_pct": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: IntBetween(10, 90),
Computed: true,
},
"hot_replica_mode": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
RequiredWith: []string{"db_node_id"},
},
"db_node_id": {
Type: schema.TypeString,
Optional: true,
},
"target_db_revision_version_code": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: polardbAndCreationDiffSuppressFunc,
},
"db_revision_version_list": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"release_type": {
Type: schema.TypeString,
Computed: true,
},
"revision_version_code": {
Type: schema.TypeString,
Computed: true,
},
"revision_version_name": {
Type: schema.TypeString,
Computed: true,
},
"release_note": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"compress_storage": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"ON", "OFF"}, false),
DiffSuppressFunc: polardbCompressStorageDiffSuppressFunc,
},
},
}
}