in alibabacloudstack/resource_apsarastack_mongodb_shardinginstance.go [18:204]
func resourceAlibabacloudStackMongoDBShardingInstance() *schema.Resource {
resource := &schema.Resource{
Schema: map[string]*schema.Schema{
"engine_version": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
},
"storage_engine": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{"WiredTiger", "RocksDB"}, false),
Optional: true,
Computed: true,
ForceNew: true,
},
"instance_charge_type": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{string(PrePaid), string(PostPaid)}, false),
Optional: true,
ForceNew: true,
Computed: true,
},
"period": {
Type: schema.TypeInt,
ValidateFunc: validation.IntInSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36}),
Optional: true,
Computed: true,
DiffSuppressFunc: PostPaidDiffSuppressFunc,
},
"zone_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"vswitch_id": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Computed:true,
ValidateFunc: validation.StringLenBetween(2, 256),
Deprecated: "Field 'name' is deprecated and will be removed in a future release. Please use new field 'db_instance_description' instead.",
ConflictsWith: []string{"db_instance_description"},
},
"db_instance_description": {
Type: schema.TypeString,
Optional: true,
Computed:true,
ValidateFunc: validation.StringLenBetween(2, 256),
ConflictsWith: []string{"name"},
},
"security_ip_list": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Optional: true,
},
"security_group_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
},
"account_password": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
},
"kms_encrypted_password": {
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: kmsDiffSuppressFunc,
},
"kms_encryption_context": {
Type: schema.TypeMap,
Optional: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return d.Get("kms_encrypted_password").(string) == ""
},
Elem: schema.TypeString,
},
"tde_status": {
Type: schema.TypeString,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return old == "" && new == "disabled" || old == "enabled"
},
ValidateFunc: validation.StringInSlice([]string{"enabled", "disabled"}, false),
Optional: true,
},
"backup_period": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
Deprecated: "Field 'backup_period' is deprecated and will be removed in a future release. " +
"Please use new field 'preferred_backup_period' instead.",
ConflictsWith: []string{"preferred_backup_period"},
},
"preferred_backup_period": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Computed: true,
ConflictsWith: []string{"backup_period"},
},
"backup_time": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(BACKUP_TIME, false),
Optional: true,
Computed: true,
Deprecated: "Field 'backup_time' is deprecated and will be removed in a future release. " +
"Please use new field 'preferred_backup_time' instead.",
ConflictsWith: []string{"preferred_backup_time"},
},
"preferred_backup_time": {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice(BACKUP_TIME, false),
Optional: true,
Computed: true,
ConflictsWith: []string{"backup_time"},
},
//Computed
"retention_period": {
Type: schema.TypeInt,
Computed: true,
},
"shard_list": {
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_class": {
Type: schema.TypeString,
Required: true,
},
"node_storage": {
Type: schema.TypeInt,
Required: true,
},
//Computed
"node_id": {
Type: schema.TypeString,
Computed: true,
},
},
},
Required: true,
MinItems: 2,
MaxItems: 32,
},
"mongo_list": {
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"node_class": {
Type: schema.TypeString,
Required: true,
},
//Computed
"node_id": {
Type: schema.TypeString,
Computed: true,
},
"connect_string": {
Type: schema.TypeString,
Computed: true,
},
"port": {
Type: schema.TypeInt,
Computed: true,
},
},
},
Required: true,
MinItems: 2,
MaxItems: 32,
},
},
}
setResourceFunc(resource, resourceAlibabacloudStackMongoDBShardingInstanceCreate,
resourceAlibabacloudStackMongoDBShardingInstanceRead, resourceAlibabacloudStackMongoDBShardingInstanceUpdate, resourceAlibabacloudStackMongoDBShardingInstanceDelete)
return resource
}