全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

ksyun_instance

最近更新时间:2025-03-18 20:10:12

提供KEC实例资源。

注意:Monthly实例无法删除,将在过期后自动释放。

使用示例

data "ksyun_availability_zones" "default" {
  output_file=""
  ids=[]
}

data "ksyun_lines" "default" {
  output_file=""
  line_name="BGP"
}

resource "ksyun_vpc" "default" {
  vpc_name   = "${var.vpc_name}"
  cidr_block = "${var.vpc_cidr}"
}

resource "ksyun_subnet" "default" {
  subnet_name      = "${var.subnet_name}"
  cidr_block = "10.1.0.0/21"
  subnet_type = "Normal"
  dhcp_ip_from = "10.1.0.2"
  dhcp_ip_to = "10.1.0.253"
  vpc_id  = "${ksyun_vpc.default.id}"
  gateway_ip = "10.1.0.1"
  dns1 = "198.18.254.41"
  dns2 = "198.18.254.40"
  availability_zone = "${data.ksyun_availability_zones.default.availability_zones.0.availability_zone_name}"
}

resource "ksyun_security_group" "default" {
  vpc_id = "${ksyun_vpc.default.id}"
  security_group_name="${var.security_group_name}"
}

resource "ksyun_security_group_entry" "default" {
  description = "test1"
  security_group_id="${ksyun_security_group.default.id}"
  cidr_block="10.0.1.1/32"
  direction="in"
  protocol="ip"
  icmp_type=0
  icmp_code=0
  port_range_from=0
  port_range_to=0
}

resource "ksyun_ssh_key" "default" {
  key_name="ssh_key_tf"
  public_key=""
}

resource "ksyun_instance" "default" {
  image_id="${data.ksyun_images.centos-7_5.images.0.image_id}"
  instance_type="N3.2B"
  system_disk{
    disk_type="SSD3.0"
    disk_size=30
  }
  data_disk_gb=0
  data_disk =[
    {
      type="SSD3.0"
      size=20
      delete_with_instance=true
    }
  ]
  subnet_id="${ksyun_subnet.default.id}"
  instance_password="Xuan663222"
  keep_image_login=false
  charge_type="Daily"
  purchase_time=1
  security_group_id=["${ksyun_security_group.default.id}"]
  private_ip_address=""
  instance_name="xuan-tf-combine"
  instance_name_suffix=""
  sriov_net_support=false
  project_id=0
  data_guard_id=""
  key_id=["${ksyun_ssh_key.default.id}"]
  force_delete=true
}

Argument Reference

The following arguments are supported:

  • image_id - (Required) The ID of the image to use for the instance.

  • instance_type - (Required) The type of the instance.

  • system_disk - (Required) System disk parameters.

    • disk_type - System disk type. Valid values are Local_SSD(local SSD disk), SSD3.0 (SSD cloud disk), and EHDD(EHDD cloud disk).

    • disk_size - The size of the data disk, in GB.

  • data_disk_gb - (Optional) Local SSD disk.

  • data_disk - (Optional) The list of data disks created together with the instance.

    • type - Data disk type. Valid values are SSD3.0 (SSD cloud disk) and EHDD (EHDD cloud disk).

    • size - The size of the data disk, in GB.

    • delete_with_instance - Whether or not the data disk is deleted when the instance is terminated.

  • subnet_id - (Required) The ID of the subnet where the instance is located in the current region.

  • security_group_id - (Required) The ID of the security group to which the instance is assigned.

  • instance_password - (Optional) The password to access the instance, which is a string of 8 to 32 characters.

  • instance_name - (Optional) Instance name, which contains 2 to 64 alphanumeric characters.

  • keep_image_login - (Optional) Whether or not to keep the initial settings of the custom image.

  • charge_type - (Required) The charging type used by the instance. Valid values are Monthly, Daily, and HourlyInstantSettlement.

  • purchase_time - (Optional) Time duration that the instance is purchased for.

  • private_ip_address - (Optional) Instance private IP address, which is assigned when the instance is created.

  • sriov_net_support (Optional) Whether or not network enhancement is supported.

  • project_id - (Optional) The ID of the project to which the instance is assigned.

  • user_data - (Optional) The user data to be specified into this instance. The value must be encrypted in base64 format and cannot exceed 16 KB.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • creation_date - The time when the instance was created. The value is an ISO8601 string.

  • instance_state - Instance current status. Possible values are active, building, stopped, deleting.

参数参考

支持以下参数:

  • image_id - (必选)用于实例的镜像ID。

  • instance_type - (必选)实例的类型。

  • system_disk - (必选)系统磁盘参数。

    • disk_type - 系统磁盘类型。有效值为 Local_SSD(本地SSD磁盘)、SSD3.0(SSD云磁盘)和 EHDD(EHDD云磁盘)。

    • disk_size - 数据磁盘的大小,以GB为单位。

  • data_disk_gb - (可选)本地SSD磁盘。

  • data_disk - (可选)与实例一起创建的数据磁盘列表。

  • type - 数据磁盘类型。有效值为 SSD3.0(SSD云磁盘)和 EHDD(EHDD云磁盘)。

  • size - 数据磁盘的大小,以GB为单位。

  • delete_with_instance - 实例终止时是否删除数据磁盘。

  • subnet_id - (必选)实例在当前区域所在子网的ID。

  • security_group_id - (必选)实例分配的安全组ID。

  • instance_password - (可选)访问实例的密码,为8到32个字符的字符串。

  • instance_name - (可选)实例名称,包含2到64个字母数字字符。

  • keep_image_login - (可选)是否保留自定义镜像的初始设置。

  • charge_type - (必选)实例使用的计费类型。有效值为 MonthlyDailyHourlyInstantSettlement

  • purchase_time - (可选)实例购买的时间期限。

  • private_ip_address - (可选)实例私有IP地址,在创建实例时分配。

  • sriov_net_support - (可选)是否支持网络增强。

  • project_id - (可选)实例分配的项目ID。

  • user_data - (可选)要指定到此实例的user_data。该值必须以base64格式加密,且不得超过16 KB。

属性参考

除了上述所有参数外,还导出以下属性:

  • creation_date - 实例创建的时间。该值为ISO8601格式的字符串。

  • instance_state - 实例当前状态。可能的值为 activebuildingstoppeddeleting

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容