Terraform module which creates redis instance and other resources on Alibaba Cloud
terraform-alicloud-redis
English | 简体中文
Terraform module which creates Redis instance and other resources on Alibaba Cloud
These types of resources are supported:
- alicloud_kvstore_instance
- alicloud_kvstore_backup_policy
- alicloud_kvstore_account
- Alicloud_cms_alarm
Name | Version |
---|---|
terraform | >= 0.13.0 |
alicloud | >= 1.56.0 |
For new instance Be careful:Create Account supports redis instances of version 4.0 or above.
module "redis" {
source = "terraform-alicloud-modules/redis/alicloud"
#################
# Redis Instance
#################
engine = "Redis"
engine_version = "5.0"
instance_name = "myInstance"
instance_class = "redis.master.mid.default"
period = 1
vswitch_id = "vsw-bp1tili2xxxxx"
security_ips = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
availability_zone = "cn-beijing-f"
security_ips = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
instance_charge_type = "PostPaid"
tags = {
Env = "Private"
Location = "Secret"
}
#################
# Redis Accounts
#################
accounts = [
{
account_name = "user1"
account_password = "plan111111"
account_privilege = "RoleReadOnly"
account_type = "Normal"
},
{
account_name = "user2"
account_password = "plan222222"
},
]
#################
# Redis backup_policy
#################
backup_policy_backup_time = "02:00Z-03:00Z"
backup_policy_backup_period = ["Monday", "Wednesday", "Friday"]
#############
# cms_alarm
#############
alarm_rule_name = "CmsAlarmForRedis"
alarm_rule_statistics = "Average"
alarm_rule_period = 300
alarm_rule_operator = "<="
alarm_rule_threshold = 35
alarm_rule_triggered_count = 2
alarm_rule_contact_groups = ["AccCms"]
}
For existing instance Be careful:Create Account supports redis instances of version 4.0 or above.
module "redis" {
source = "terraform-alicloud-modules/redis/alicloud"
#################
# Redis Instance
#################
existing_instance_id = "r-2zea81b836xxxxx"
#################
# Redis Accounts
#################
create_account = true
accounts = [
{
account_name = "user1"
account_password = "plan111111"
account_privilege = "RoleReadOnly"
account_type = "Normal"
},
{
account_name = "user2"
account_password = "plan222222"
},
]
#################
# Redis backup_policy
#################
backup_policy_backup_time = "02:00Z-03:00Z"
backup_policy_backup_period = ["Monday", "Wednesday", "Friday"]
#############
# cms_alarm
#############
alarm_rule_name = "CmsAlarmForRedis"
alarm_rule_statistics = "Average"
alarm_rule_period = 300
alarm_rule_operator = "<="
alarm_rule_threshold = 35
alarm_rule_triggered_count = 2
alarm_rule_contact_groups = ["AccCms"]
}
- complete
- using-existing-redis-instance
- using-submodule-complete-redis-2.8
- using-submodule-complete-redis-4.0
- using-submodule-complete-redis-5.0
This module provides rich sub-modules to support different Redis version and usage scenario, like:
- Redis 2.8 for Community Cluster
- Redis 4.0 for Community Read-Write split
- Enhanced performance Redis 5.0 for Enterprise Standard edition
- Enhanced performance Redis 5.0 for Enterprise Read-Write split
- Enhanced performance Redis 5.0 for Enterprise Cluster
See more modules.
From the version v1.3.0, the module has removed the following provider
setting:
provider "alicloud" {
profile = var.profile != "" ? var.profile : null
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
region = var.region != "" ? var.region : null
skip_region_validation = var.skip_region_validation
configuration_source = "terraform-alicloud-modules/redis"
}
If you still want to use the provider
setting to apply this module, you can specify a supported version, like 1.2.0:
module "redis" {
source = "terraform-alicloud-modules/redis/alicloud"
version = "1.2.0"
region = "cn-hangzhou"
profile = "Your-Profile-Name"
alarm_rule_name = "CmsAlarmForRedis"
alarm_rule_statistics = "Average"
alarm_rule_period = 300
alarm_rule_operator = "<="
}
If you want to upgrade the module to 1.3.0 or higher in-place, you can define a provider which same region with previous region:
provider "alicloud" {
region = "cn-hangzhou"
profile = "Your-Profile-Name"
}
module "redis" {
source = "terraform-alicloud-modules/redis/alicloud"
alarm_rule_name = "CmsAlarmForRedis"
alarm_rule_statistics = "Average"
alarm_rule_period = 300
alarm_rule_operator = "<="
}
or specify an alias provider with a defined region to the module using providers
:
provider "alicloud" {
region = "cn-hangzhou"
profile = "Your-Profile-Name"
alias = "hz"
}
module "redis" {
source = "terraform-alicloud-modules/redis/alicloud"
providers = {
alicloud = alicloud.hz
}
alarm_rule_name = "CmsAlarmForRedis"
alarm_rule_statistics = "Average"
alarm_rule_period = 300
alarm_rule_operator = "<="
}
and then run terraform init
and terraform apply
to make the defined provider effect to the existing module state.
More details see How to use provider in the module
Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)
Apache 2 Licensed. See LICENSE for full details.