alicloud_redis_tair_instance
Provides a Tair (Redis OSS-Compatible) And Memcache (KVStore) Tair Instance resource.
Describe the creation, deletion and query of tair instances.
For information about Tair (Redis OSS-Compatible) And Memcache (KVStore) Tair Instance and how to use it, see What is Tair Instance.
-> NOTE: Available since v1.206.0.
-> NOTE: Destroying a Subscription instance fails with an error since v1.294.0. To destroy it, convert the instance to PayAsYouGo by setting payment_type = "PayAsYouGo" and re-applying, or unsubscribe it in the Alibaba Cloud console. To remove the instance from the state only, run terraform state rm.
-> NOTE: Refreshing an instance calls the DescribeRoleZoneInfo operation to read the additional bandwidth purchased for its data shards, so the RAM policy used by Terraform must allow kvstore:DescribeRoleZoneInfo in addition to the instance query permissions.
Example Usage
Basic Usage
terraform {
required_providers {
alicloud = {
source = "aliyun/alicloud"
}
}
}
provider "alicloud" {
region = "cn-hangzhou"
}
variable "name" {
default = "tf-example"
}
data "alicloud_kvstore_zones" "default" {
product_type = "Tair_rdb"
}
data "alicloud_vpcs" "default" {
name_regex = "default-NODELETING"
}
data "alicloud_vswitches" "default" {
vpc_id = data.alicloud_vpcs.default.ids.0
zone_id = data.alicloud_kvstore_zones.default.zones.0.id
}
locals {
vswitch_id = data.alicloud_vswitches.default.ids.0
zone_id = data.alicloud_kvstore_zones.default.zones.0.id
}
data "alicloud_resource_manager_resource_groups" "default" {
}
resource "alicloud_redis_tair_instance" "default" {
payment_type = "PayAsYouGo"
instance_type = "tair_rdb"
zone_id = local.zone_id
instance_class = "tair.rdb.2g"
shard_count = "2"
vswitch_id = local.vswitch_id
vpc_id = data.alicloud_vpcs.default.ids.0
tair_instance_name = var.name
}
Need more examples? VIEW MORE EXAMPLES
Argument Reference
The following arguments are supported:
-
additional_bandwidth- (Optional, Set, Available since v2.2.0) The additional bandwidth to add to each data shard of the instance. Unit: MB/s. Setting this block adjusts the shard bandwidth to the specification default plus the configured value, which also changes the totalbandwidthof the instance. Seeadditional_bandwidthbelow. NOTE: The purchased bandwidth is read back from theDescribeRoleZoneInfoAPI as each data node'sCurrentBandWidthminus itsDefaultBandWidth(the specification default) for the shards managed by this resource, so bandwidth changed outside Terraform is detected on refresh. Removing a block does not release the purchased bandwidth of that shard; set itsbandwidthto0explicitly to release it. NOTE: The additional bandwidth is purchased for a limited order duration (the API default is 1 day) and must be renewed with theRenewAdditionalBandwidthoperation before it expires; this resource does not manage the renewal or the order duration. The additional bandwidth is charged on a pay-as-you-go basis. -
bandwidth_burst- (Optional, Bool, Available since v2.2.0) Specifies whether to enable Elastic Burst for the instance. After it is enabled, the instance can temporarily burst beyond the default bandwidth limit during bandwidth auto scaling. NOTE: This attribute is write-only and cannot be read back; Terraform keeps the configured value in the state. -
auto_renew- (Optional) Specifies whether to enable auto-renewal for the instance. Default value: false. Valid values: true(enables auto-renewal), false(disables auto-renewal). -
auto_renew_period- (Optional) The subscription duration that is supported by auto-renewal. Unit: months. Valid values: 1, 2, 3, 6, and 12. This parameter is required only if the AutoRenew parameter is set to true. -
backup_id- (Optional, Available since v1.233.1) You can set the BackupId parameter to the backup set ID of the source instance. The system uses the data stored in the backup set to create an instance. You can call the DescribeBackups operation to query backup set IDs. If the source instance is a cluster instance, set the BackupId parameter to the backup set IDs of all shards of the source instance, separated by commas (,).If your instance is a cloud-native cluster instance, we recommend that you use DescribeClusterBackupList to query the backup set ID of the cluster instance. Then, set the ClusterBackupId request parameter to the backup set ID to clone the cluster instance. This eliminates the need to specify the backup set ID of each shard.
-
cluster_backup_id- (Optional, Available since v1.224.0) This parameter is supported for specific new cluster instances. You can query the backup set ID by calling the DescribeClusterBackupList operation. If this parameter is supported, you can specify the backup set ID. In this case, you do not need to specify the BackupId parameter. If this parameter is not supported, set the BackupId parameter to the IDs of backup sets in all shards of the source instance, separated by commas (,). -
config- (Optional, MapString) The configuration of the Tair (Redis OSS-Compatible) instance. It is a map of Redis configuration parameters, such asmaxmemory-policyandappendonly. Available parameters can refer to the latest docs Instance configurations table. This attribute is applied via theModifyInstanceConfigAPI and only takes effect when the instance is in the running state, so it is recommended to set or update it after the instance is created. -
connection_string_prefix- (Optional, Available since v1.235.0) The prefix of the endpoint the instance, which must consist of lowercase letters and numbers and start with a lowercase letter. -
effective_time- (Optional) The time when to change the configurations. Default value: Immediately. Valid values: Immediately (The configurations are immediately changed), MaintainTime (The configurations are changed within the maintenance window). -
encryption_key- (Optional, Available since v1.273.0) The custom key ID. You can call DescribeEncryptionKeyList to obtain it.-> NOTE: * If this parameter is not specified, a key is automatically generated by Key Management Service.
-> NOTE: * To create a custom key, you can call the CreateKey operation of Key Management Service.
-> NOTE: This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action.
-
encryption_name- (Optional, Available since v1.273.0) The encryption algorithm. The default value is AES-CTR-256.-> NOTE: This parameter is available only when the
TDEStatusparameter is set toEnabled.-> NOTE: This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action.
-
engine_version- (Optional, Computed) The database version. Default value:1.0. The valid values depend on the Tair instance series:- tair_rdb: Tair memory-enhanced instances are compatible with Redis 5.0, Redis 6.0, and Redis 7.0. Set the value to
5.0,6.0, or7.0. - tair_scm: Tair persistent memory-optimized instances are compatible with Redis 6.0. Set the value to
1.0. - tair_essd: Tair disk-based instances (ESSD/SSD) are compatible with Redis 6.0. Set the value to
1.0to create an ESSD-based instance or2.0to create an SSD-based instance.
- tair_rdb: Tair memory-enhanced instances are compatible with Redis 5.0, Redis 6.0, and Redis 7.0. Set the value to
-
force_upgrade- (Optional) Specifies whether to forcefully change the configurations of the instance. Default value: true. Valid values: false (The system does not forcefully change the configurations), true (The system forcefully changes the configurations). -
global_instance_id- (Optional, Available since v1.233.1) The ID of a distributed (Global Distributed Cache) instance, which indicates whether to use the newly created instance as a sub-instance of a distributed instance. You can use this method to create a distributed instance.-
Enter true if you want the new instance to be the first child instance.
-
If you want the new instance to be used as the second and third sub-instances, enter the distributed instance ID.
-
Not as a distributed instance, you do not need to enter any values.
-
-
instance_class- (Required) The instance type of the instance. For more information, see Instance types. -
instance_type- (Required, ForceNew) The storage medium of the instance. Valid values: tair_rdb, tair_scm, tair_essd. -
intranet_bandwidth- (Optional, Computed, Int, Available since v1.233.1) Instance intranet bandwidth -
maintain_end_time- (Optional, Computed, Available since v1.286.0) The end time of the maintenance window of the Tair instance. The time is in theHH:mmZformat (UTC). The interval between the start time and the end time must be at least 1 hour. Example:06:00Z. -
maintain_start_time- (Optional, Computed, Available since v1.286.0) The start time of the maintenance window of the Tair instance. The time is in theHH:mmZformat (UTC). Example:02:00Z. -
modify_mode- (Optional, Available since v1.233.1) The modification method when modifying the IP whitelist. The value includes Cover (default): overwrite the original whitelist; Append: Append the whitelist; Delete: Delete the whitelist. -
node_type- (Optional, Computed) The node type. For cloud-native instances, input MASTER_SLAVE (master-replica) or STAND_ALONE (standalone). For classic instances, input double (master-replica) or single (standalone). -
param_no_loose_sentinel_enabled- (Optional, Computed, Available since v1.233.1) sentinel compatibility mode, applicable to non-cluster instances. For more information about parameters, see yes or no in the https://www.alibabacloud.com/help/en/redis/user-guide/use-the-sentinel-compatible-mode-to-connect-to-an-apsaradb-for-redis-instance, valid values: yes, no. The default value is no. -
param_no_loose_sentinel_password_free_access- (Optional, Computed, Available since v1.237.0) Whether to allow Sentinel commands to be executed without secrets when Sentinel mode is enabled. Value: yes: enabled. After the command is enabled, you can directly run the Sentinel command in the VPC without enabling the password-free feature. no: the default value, disabled. For parameters, see https://help.aliyun.com/zh/redis/user-guide/use-the-sentinel-compatible-mode-to-connect-to-an-apsaradb-for-redis-instance -
param_no_loose_sentinel_password_free_commands- (Optional, Computed, Available since v1.239.0) After sentinel mode and the# no_loose_sentinel-password-free-access parameter are enabled, you can use this parameter to add additional secret-free command lists (empty by default). After setting, you can execute the corresponding command on any connection without secret, please operate carefully. Commands are written in lowercase letters, and multiple commands are separated by commas (,). See https://help.aliyun.com/zh/redis/user-guide/parameter-support for details -
param_repl_mode- (Optional, Computed, Available since v1.233.1) The value is semisync or async. The default value is async.The default data synchronization mode is asynchronous replication. To modify the data synchronization mode, refer to https://www.alibabacloud.com/help/en/redis/user-guide/modify-the-synchronization-mode-of-a-persistent-memory-optimized-instance.
-
param_semisync_repl_timeout- (Optional, Computed, Available since v1.233.1) The degradation threshold time of the semi-synchronous replication mode. This parameter value is required only when semi-synchronous replication is enabled. The unit is milliseconds, and the range is 10ms to 60000ms. The default value is 500ms. Please refer to: https://www.alibabacloud.com/help/en/redis/user-guide/modify-the-synchronization-mode-of-a-persistent-memory-optimized-instance. -
param_sentinel_compat_enable- (Optional, Computed, Available since v1.233.1) sentinel compatibility mode, applicable to instances in the cluster architecture proxy connection mode or read/write splitting architecture. For more information about the parameters, see https://www.alibabacloud.com/help/en/redis/user-guide/use-the-sentinel-compatible-mode-to-connect-to-an-apsaradb-for-redis-instance. The value is 0 or 1. The default value is 0. -
password- (Optional) The password that is used to connect to the instance. The password must be 8 to 32 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include ! @ # $ % ^ & * ( ) _ + - = -
password_wo- (Optional, Available since v2.2.0) The write-only password of the account. It is only sent to the server when the resource is created or thepassword_wo_versionchanges and is never stored in the state or plan. -
password_wo_version- (Optional, Available since v2.2.0) The version of the write-only password. The write-only password is re-sent to the server only when this argument changes, so it must be changed wheneverpassword_wochanges. -
payment_type- (Optional, Computed) Payment type: Subscription (prepaid), PayAsYouGo (postpaid). Default Subscription. -
period- (Optional, Int) The subscription duration. Unit: months. Valid values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24,36, and 60. This parameter is required only if you set the PaymentType parameter to Subscription. -
port- (Optional, ForceNew, Computed, Int) The Tair service port. The service port of the instance. Valid values: 1024 to 65535. Default value: 6379. -
read_only_count- (Optional, Int) Number of read-only nodes in the primary zone. Valid values: 0 to 5. This parameter is only applicable to the following conditions:If the instance is in the cloud disk version standard architecture, you can set this parameter to a value greater than 0 to enable the read/write splitting architecture.
If the instance is a cloud disk version read/write splitting architecture instance, you can use this parameter to customize the number of read-only nodes, or set this parameter to 0 to disable the read/write splitting architecture and switch the instance to the standard architecture.
-
recover_config_mode- (Optional, Available since v1.233.1) Whether to restore the account, kernel parameters, and whitelist (config) information from the original backup set when creating an instance using a specified backup set. The default value is empty, indicating that the account, kernel parameters, and whitelist information are not restored from the original backup set. This parameter is only applicable to Cloud Native instances, and the account, kernel parameters, and whitelist information must have been saved in the original backup set. -
replica_count- (Optional, Computed, Int, Available since v2.2.0) The number of replica nodes in the primary zone. This parameter is available only when you create a cloud-native cluster instance in the multi-replica mode. Valid values:1to4. If you create a multi-zone instance, you can use this parameter together with theslave_replica_countparameter to customize the numbers of replica nodes in the primary and secondary zones. The sum of the values of this parameter and theslave_replica_countparameter cannot exceed4. Removing this parameter from the configuration keeps the current value instead of resetting it; set a new value explicitly to change the number of replica nodes. -
resource_group_id- (Optional, Computed) The ID of the resource group to which the instance belongs. -
role_arn- (Optional, Available since v1.273.0) The Alibaba Cloud Resource Name (ARN) of the role to be authorized. After authorization, you can use the related Key Management Service (KMS) features. Format:acs:ram::$accountID:role/$roleName.-> NOTE: *
$accountID: Your Alibaba Cloud account ID. To view it, log on to the Alibaba Cloud console, move the pointer over your profile picture in the upper-right corner, and click Security Settings.-> NOTE: *
$roleName: The RAM role name. The value is fixed asAliyunRdsInstanceEncryptionDefaultRole.-> NOTE: This parameter only applies during resource update. If modified in isolation without other property changes, Terraform will not trigger any action.
-
secondary_zone_id- (Optional, ForceNew) The ID of the secondary zone.This parameter is returned only if the instance is deployed in two zones. -
security_group_id- (Optional) Security group id. Multiple security group IDs can be bound at once by separating them with a comma (,); the order of the IDs is not significant and does not trigger a diff. -
security_ip_group_name- (Optional, Computed, Available since v1.233.1) The name of the IP address whitelist. You cannot modify the whitelist that is generated by the system. If you do not specify this parameter, the default whitelist is modified by default. -
security_ips- (Optional, Computed, Available since v1.233.1) The IP addresses in the whitelist. Up to 1,000 IP addresses can be specified in a whitelist. Separate multiple IP addresses with a comma (,). Specify an IP address in the 0.0.0.0/0, 10.23.12.24, or 10.23.12.24/24 format. In CIDR block 10.23.12.24/24, /24 specifies the length of the prefix of an IP address. The prefix length ranges from 1 to 32. -
shard_count- (Optional, Computed, Int) The number of data nodes in the instance. When 1 is passed, it means that the instance created is a standard architecture with only one data node. You can create an instance in the standard architecture that contains only a single data node. 2 to 32: You can create an instance in the cluster architecture that contains the specified number of data nodes. Only persistent memory-optimized instances can use the cluster architecture. Therefore, you can set this parameter to an integer from 2 to 32 only if you set the InstanceType parameter to tair_scm. It is not allowed to modify the number of shards by modifying this parameter after creating a master-slave architecture instance with or without passing 1. -
slave_read_only_count- (Optional, Int) Specifies the number of read-only nodes in the secondary zone when creating a multi-zone read/write splitting instance.Note: To create a multi-zone read/write splitting instance, slaveadonlycount and SecondaryZoneId must be specified at the same time.
-
slave_replica_count- (Optional, Computed, Int, Available since v2.2.0) The number of replica nodes in the secondary zone. If you create a multi-zone instance, the sum of the values of this parameter and thereplica_countparameter cannot exceed4. The value0is not supported in this configuration:CreateTairInstancerejects it withInvalidParameter, andModifyInstanceSpecrejects it withSlaveReplicaCountCanNotBeZero(the API suggestsMigrateToOtherZoneinstead). Removing this parameter from the configuration keeps the current value instead of resetting it; set a new value explicitly to change the number of replica nodes in the secondary zone. -
src_db_instance_id- (Optional, Available since v1.233.1) If you want to create an instance based on the backup set of an existing instance, set this parameter to the ID of the source instance. preceding three parameters. After you specify the SrcDBInstanceId parameter, use the BackupId, ClusterBackupId (recommended for cloud-native cluster instances), or RestoreTime parameter to specify the backup set or the specific point in time that you want to use to create an instance. The SrcDBInstanceId parameter must be used in combination with one of the preceding three parameters. -
ssl_enabled- (Optional, Computed) Modifies SSL encryption configurations. Valid values: 1. Disable (The SSL encryption is disabled) 2. Enable (The SSL encryption is enabled) 3. Update (The SSL certificate is updated) -
storage_performance_level- (Optional, ForceNew) The storage type. Valid values: PL1, PL2, and PL3. This parameter is available only when the value of InstanceType is tair_essd, that is, when an ESSD disk instance is selected.If the ESSD instance type is 4C, 8C, or 16C, you can specify the storage type as PL1.
If the type of ESSD instance you select is 8C, 16C, 32C, or 52C, you can specify the storage type as PL2.
If the ESSD instance type is 16C, 32C, or 52C, you can specify the storage type as PL3.
-
storage_size_gb- (Optional, ForceNew, Computed, Int) Different specifications have different value ranges. When the instance_type value is tair_essd and the disk type is ESSD, this attribute takes effect and is required. When a Tair disk is an SSD, see https://help.aliyun.com/zh/redis/product-overview/capacity-storage-type. The capacity field is defined as different fixed values according to different specifications, and does not need to be specified. -
tde_status- (Optional, Computed, Available since v1.273.0) Specifies whether to enable Transparent Data Encryption (TDE). Valid value:enabled.-> NOTE: After TDE is enabled, it cannot be disabled. Evaluate the potential impact on your business before enabling this feature. For more information, see Enable Transparent Data Encryption (TDE).
-
tags- (Optional, Map) The tag of the resource -
tair_instance_name- (Optional) The name of the resource. -
vswitch_id- (Required, ForceNew) The ID of the vSwitch to which the instance is connected. -
vpc_auth_mode- (Optional, Computed, Available since v1.233.1) The VPC authentication mode. Valid values: Open (enables password authentication), Close (disables password authentication and enables password-free access). -
vpc_id- (Required, ForceNew) The ID of the virtual private cloud (VPC). -
zone_id- (Required, ForceNew) Zone ID
additional_bandwidth
The additional_bandwidth block supports the following:
node_id- (Optional, String) The data shard whose bandwidth is adjusted. Use the shard node name (r-xxx-db-0, theInsNamereported by theDescribeRoleZoneInfooperation) or its full topology ID (r-xxx-db-0#123456); a suffix such asdb-0is also accepted when exactly one data shard of the instance ends with it. Required on cluster and read/write splitting instances, and each data shard can be configured at most once. A standard instance takesbandwidthalone and must leave this argument unset, becauseEnableAdditionalBandwidthonly acceptsNodeIdfor the cluster and read/write splitting architectures.bandwidth- (Optional, Int) The additional bandwidth to add. Unit: MB/s. Must be set in everyadditional_bandwidthblock; a block without it is rejected. Valid values: non-negative integers. The maximum value is 6 times the default bandwidth of the instance (or shard) specification, capped at 192 MB/s. Set to0to release the additional bandwidth purchased for the shard.
Attributes Reference
The following attributes are exported:
id- The ID of the resource supplied above.architecture_type- The architecture of the instance. cluster, standard, rwsplit.connection_domain- The internal endpoint of the instance.create_time- The time when the instance was created. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.max_connections- The maximum number of connections supported by the instance.network_type- The network type of the instance. CLASSIC(classic network), VPC.region_id- Region Idstatus- The status of the resourcetair_instance_id- The ID of the resource.ca_cert_download_url- The download URL of the CA certificate. This attribute is populated whenssl_enabledis set toEnable.ca_cert_common_name- The common name of the CA certificate. NOTE: This is a best-effort attribute and may be empty when the upstream API does not return it.ssl_expired_time- The expiration time of the SSL certificate. NOTE: This is a best-effort attribute and may be empty when the upstream API does not return it.
Timeouts
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 60 mins) Used when create the Tair Instance.delete- (Defaults to 30 mins) Used when delete the Tair Instance.update- (Defaults to 60 mins) Used when update the Tair Instance.
Import
Tair (Redis OSS-Compatible) And Memcache (KVStore) Tair Instance can be imported using the id, e.g.
$ terraform import alicloud_redis_tair_instance.example <id>