Provides a CDDC Dedicated Propre Host resource. MyBase proprietary cluster host resources, you need to add a whitelist to purchase a proprietary version of the cluster.
For information about CDDC Dedicated Propre Host and how to use it, see What is Dedicated Propre Host.
Basic Usage
variable "name" {
default = "terraform-example"
}
provider "alicloud" {
region = "cn-hangzhou"
}
data "alicloud_instance_types" "default" {
instance_type_family = "ecs.g6e"
network_type = "Vpc"
}
data "alicloud_images" "default" {
name_regex = "^aliyun_3_x64_20G_scc*"
owners = "system"
}
data "alicloud_instance_types" "essd" {
cpu_core_count = 2
memory_size = 4
system_disk_category = "cloud_essd"
}
data "alicloud_vpcs" "default" {
name_regex = "^default-NODELETING$"
}
data "alicloud_vswitches" "default" {
vpc_id = data.alicloud_vpcs.default.ids.0
zone_id = "cn-hangzhou-i"
}
data "alicloud_security_groups" "default" {
name_regex = "tf-exampleacc-cddc-dedicated_propre_host"
}
resource "alicloud_security_group" "default" {
count = length(data.alicloud_security_groups.default.ids) > 0 ? 0 : 1
vpc_id = data.alicloud_vswitches.default.vswitches.0.vpc_id
name = "tf-exampleacc-cddc-dedicated_propre_host"
}
data "alicloud_ecs_deployment_sets" "default" {
name_regex = "tf-exampleacc-cddc-dedicated_propre_host"
}
resource "alicloud_ecs_deployment_set" "default" {
count = length(data.alicloud_ecs_deployment_sets.default.ids) > 0 ? 0 : 1
strategy = "Availability"
domain = "Default"
granularity = "Host"
deployment_set_name = "tf-exampleacc-cddc-dedicated_propre_host"
description = "tf-exampleacc-cddc-dedicated_propre_host"
}
data "alicloud_key_pairs" "default" {
name_regex = "tf-exampleacc-cddc-dedicated_propre_host"
}
resource "alicloud_key_pair" "default" {
count = length(data.alicloud_key_pairs.default.ids) > 0 ? 0 : 1
key_pair_name = "tf-exampleacc-cddc-dedicated_propre_host"
}
data "alicloud_cddc_dedicated_host_groups" "default" {
engine = "MySQL"
name_regex = "tf-exampleacc-cddc-dedicated_propre_host"
}
resource "alicloud_cddc_dedicated_host_group" "default" {
count = length(data.alicloud_cddc_dedicated_host_groups.default.ids) > 0 ? 0 : 1
engine = "MySQL"
vpc_id = data.alicloud_vpcs.default.ids.0
cpu_allocation_ratio = 101
mem_allocation_ratio = 50
disk_allocation_ratio = 200
allocation_policy = "Evenly"
host_replace_policy = "Manual"
dedicated_host_group_desc = "tf-exampleacc-cddc-dedicated_propre_host"
open_permission = true
}
locals {
alicloud_security_group_id = length(data.alicloud_security_groups.default.ids) > 0 ? data.alicloud_security_groups.default.ids.0 : concat(alicloud_security_group.default[*].id, [""])[0]
alicloud_ecs_deployment_set_id = length(data.alicloud_ecs_deployment_sets.default.ids) > 0 ? data.alicloud_ecs_deployment_sets.default.sets.0.deployment_set_id : concat(alicloud_ecs_deployment_set.default[*].id, [""])[0]
alicloud_key_pair_id = length(data.alicloud_key_pairs.default.ids) > 0 ? data.alicloud_key_pairs.default.ids.0 : concat(alicloud_key_pair.default[*].id, [""])[0]
dedicated_host_group_id = length(data.alicloud_cddc_dedicated_host_groups.default.ids) > 0 ? data.alicloud_cddc_dedicated_host_groups.default.ids.0 : concat(alicloud_cddc_dedicated_host_group.default[*].id, [""])[0]
}
resource "alicloud_cddc_dedicated_propre_host" "default" {
vswitch_id = data.alicloud_vswitches.default.ids.0
ecs_instance_name = "exampleTf"
ecs_deployment_set_id = local.alicloud_ecs_deployment_set_id
auto_renew = "false"
security_group_id = local.alicloud_security_group_id
dedicated_host_group_id = local.dedicated_host_group_id
ecs_host_name = "exampleTf"
vpc_id = data.alicloud_vpcs.default.ids.0
ecs_unique_suffix = "false"
password_inherit = "false"
engine = "mysql"
period = "1"
os_password = "YourPassword123!"
ecs_zone_id = "cn-hangzhou-i"
ecs_class_list {
disk_type = "cloud_essd"
sys_disk_type = "cloud_essd"
disk_count = "1"
system_disk_performance_level = "PL1"
data_disk_performance_level = "PL1"
disk_capacity = "40"
instance_type = "ecs.c6a.large"
sys_disk_capacity = "40"
}
payment_type = "Subscription"
image_id = "m-bp1d13fxs1ymbvw1dk5g"
period_type = "Monthly"
}
alicloud_cddc_dedicated_propre_host
or removing it from your configurationTerraform cannot destroy resource alicloud_cddc_dedicated_propre_host
. Terraform will remove this resource from the state file, however resources may remain.
The following arguments are supported:
auto_pay
- (Optional, Available since v1.215.0) Whether to pay automatically when the host is created.auto_renew
- (Optional) Whether to enable automatic renewal. Valid values:
dedicated_host_group_id
- (Optional, ForceNew, Computed) You have a dedicated cluster ID.ecs_class_list
- (Required, ForceNew) ECS specifications. See ecs_class_list
below.ecs_deployment_set_id
- (Optional, ForceNew) The ID of the cloud server deployment set.ecs_host_name
- (Optional, ForceNew) Windows system: length of 2 to 15 characters, allowing the use of upper and lower case letters, numbers. You cannot use only numbers. Other operating systems (such as Linux): the length of 2 to 64 characters, allowing the use of dot (.) to separate characters into multiple segments, each segment allows the use of upper and lower case letters, numbers, but can not use continuous dot (.). Cannot start or end with a dot (.).ecs_instance_name
- (Optional, ForceNew) The instance name. It must be 2 to 128 characters in length and must start with an uppercase or lowercase letter or a Chinese character. It cannot start with http:// or https. Can contain Chinese, English, numbers, half-width colons (:), underscores (_), half-width periods (.), or dashes (-). The default value is the InstanceId of the instance.ecs_unique_suffix
- (Optional) Whether to automatically add an ordered suffix for HostName and InstanceName when creating multiple instances. The ordered suffix starts from 001 and cannot exceed 999. Value Description:
ecs_zone_id
- (Required, ForceNew) The ID of the zone.engine
- (Required, ForceNew) Database type, value:
image_id
- (Optional, ForceNew) The ID of the custom image.ecs_class_list
The ecs_class_list supports the following:
data_disk_performance_level
- (Optional, ForceNew) Data disk PL level.disk_capacity
- (Optional, ForceNew) The capacity of the data disk.disk_count
- (Optional, ForceNew) Number of mounted data disks.disk_type
- (Optional, ForceNew) Data disk type, value range:
instance_type
- (Required, ForceNew) ECS specifications.sys_disk_capacity
- (Required, ForceNew) System disk capacity.sys_disk_type
- (Required, ForceNew) System disk type, value:
system_disk_performance_level
- (Optional, ForceNew) System disk PL level.The following attributes are exported:
id
- The ID of the resource supplied above.The value is formulated as <dedicated_host_group_id>:<ecs_instance_id>
.ecs_instance_id
- ECS instance ID.The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 5 mins) Used when create the Dedicated Propre Host.CDDC Dedicated Propre Host can be imported using the id, e.g.
$ terraform import alicloud_cddc_dedicated_propre_host.example <dedicated_host_group_id>:<ecs_instance_id>