alicloud_instance

更新时间:
复制 MD 格式

Provides a ECS instance resource.

-> NOTE: Available since v1.0.0

-> NOTE: From version v1.213.0, you can specify launch_template_id and launch_template_version to use a launch template. This eliminates the need to configure a large number of parameters every time you create instances.

Example Usage


terraform {
  required_providers {
    alicloud = {
      source = "aliyun/alicloud"
    }
  }
}

variable "name" {
  default = "terraform-example"
}

variable "instance_type" {
  default = "ecs.g7.large"
}

variable "image_id" {
  default = "ubuntu_18_04_64_20G_alibase_20190624.vhd"
}

# Create a new ECS instance for a VPC
resource "alicloud_security_group" "group" {
  security_group_name = var.name
  description         = "foo"
  vpc_id              = alicloud_vpc.vpc.id
}

resource "alicloud_kms_key" "key" {
  description            = "Hello KMS"
  pending_window_in_days = "7"
  status                 = "Enabled"
}

data "alicloud_zones" "default" {
  available_disk_category     = "cloud_essd"
  available_resource_creation = "VSwitch"
  available_instance_type     = var.instance_type
}

# Create a new ECS instance for VPC
resource "alicloud_vpc" "vpc" {
  vpc_name   = var.name
  cidr_block = "172.16.0.0/16"
}

resource "alicloud_vswitch" "vswitch" {
  vpc_id       = alicloud_vpc.vpc.id
  cidr_block   = "172.16.0.0/24"
  zone_id      = data.alicloud_zones.default.zones.0.id
  vswitch_name = var.name
}

resource "alicloud_instance" "instance" {
  # cn-beijing
  availability_zone = data.alicloud_zones.default.zones.0.id
  security_groups   = alicloud_security_group.group.*.id

  # series III
  instance_type              = var.instance_type
  system_disk_category       = "cloud_essd"
  system_disk_name           = var.name
  system_disk_description    = "test_foo_system_disk_description"
  image_id                   = var.image_id
  instance_name              = var.name
  vswitch_id                 = alicloud_vswitch.vswitch.id
  internet_max_bandwidth_out = 10
  data_disks {
    name        = "disk2"
    size        = 20
    category    = "cloud_essd"
    description = "disk2"
    encrypted   = true
    kms_key_id  = alicloud_kms_key.key.id
  }
}

Need more examples? VIEW MORE EXAMPLES

Module Support

You can use the existing ecs-instance module to create several ECS instances one-click.

Argument Reference

The following arguments are supported:

  • image_id - (Optional) The Image to use for the instance. ECS instance's image can be replaced via changing image_id. If you do not use launch_template_id or launch_template_name to specify a launch template, you must specify image_id. How the change is applied is controlled by the provider argument features.ecs_instance.replace_on_image_update:

    • false (default): The instance is stopped if it is running, its system disk is replaced with a new one created from the new image, and the instance is started again. It keeps its ID, its private IP address and its data disks, system_disk_id changes, and any key pair is attached again afterwards.
    • true: The change is planned as forces replacement, so the existing instance is destroyed and a new one is created from the new image.

    -> NOTE: The system disk is created anew from the image either way, so its data never survives an image_id change. Setting replace_on_image_update to true gives up the instance ID, the private IP address and the data disks as well, and requires the instance to be destroyable: a prevent_destroy lifecycle rule turns the planned replacement into an error, the provider refuses to destroy an instance whose instance_charge_type is PrePaid unless force_delete is true, and ECS rejects the deletion itself while deletion_protection is true. See the features.ecs_instance documentation for the cases in which a change cannot be planned as a replacement.

  • instance_type - (Optional) The type of instance to start. When it is changed, the instance will reboot to make the change take effect. If you do not use launch_template_id or launch_template_name to specify a launch template, you must specify instance_type.

  • is_outdated - (Optional) Whether to use outdated instance type. Note: The parameter is immutable after resource creation. It only controls the I/O optimization option sent when creating the instance.

  • network_interface_id - (Optional, ForceNew, Available since v1.284.0) The ID of the Primary ENI.

    -> NOTE: From version 1.284.0, network_interface_id can be set.

  • security_groups - (Optional) A list of security group ids to associate with.

    -> NOTE: If you do not use launch_template_id or launch_template_name to specify a launch template, you must specify security_groups.

  • availability_zone - (Optional, ForceNew) The Zone to start the instance in. It is ignored and will be computed when set vswitch_id.

  • instance_name - (Optional) The name of the ECS. This instance_name can have a string of 2 to 128 characters, must contain only alphanumeric characters or hyphens, such as "-",".","_", and must not begin with a hyphen, and must not begin with http:// or https://. NOTE: From version 1.243.0, the default value ECS-Instance will be removed.

  • system_disk_category - (Optional, ForceNew, String) Valid values: all, local_disk, ephemeral_ssd, cloud_efficiency, cloud_ssd, cloud_essd, cloud, cloud_auto, cloud_essd_entry, cloud_essd_xc0, cloud_essd_xc1. only is used to some none I/O optimized instance. cloud_auto is Available since v1.184.0. cloud_essd_xc0 and cloud_essd_xc1 are Available since v2.2.0 and only supported in government cloud (政务云) regions.

  • system_disk_name - (Optional, Available since v1.101.0) The name of the system disk. The name must be 2 to 128 characters in length and can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-). It must start with a letter and cannot start with http:// or https://.

  • system_disk_description - (Optional, Available since v1.101.0) The description of the system disk. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

  • system_disk_size - (Optional) Size of the system disk, measured in GiB. Value range: [20, 500]. The specified value must be equal to or greater than max{20, Imagesize}. Default value: max{40, ImageSize}.

  • system_disk_performance_level (Optional) The performance level of the ESSD used as the system disk, Valid values: PL0, PL1, PL2, PL3, Default to PL1;For more information about ESSD, See Encryption Context.

  • system_disk_auto_snapshot_policy_id - (Optional, Available since v1.73.0, Modifiable in 1.169.0) The ID of the automatic snapshot policy applied to the system disk. NOTE: If you want to use system_disk_auto_snapshot_policy_id, We recommend you to use the resource alicloud_ecs_auto_snapshot_policy_attachment.

  • system_disk_storage_cluster_id - (Optional, ForceNew, Available since v1.177.0) The ID of the dedicated block storage cluster. If you want to use disks in a dedicated block storage cluster as system disks when you create instances, you must specify this parameter. For more information about dedicated block storage clusters.

  • system_disk_encrypted - (Optional, ForceNew, Available since v1.177.0) Specifies whether to encrypt the system disk. Valid values: true,false. Default value: false.

    • true: Encrypts the system disk.
    • false: Does not encrypt the system disk.
  • system_disk_kms_key_id - (Optional, ForceNew, Available since v1.177.0) The ID of the Key Management Service (KMS) key to be used for the system disk.

  • system_disk_encrypt_algorithm - (Optional, ForceNew, Available since v1.177.0) The algorithm to be used to encrypt the system disk. Valid values are aes-256, sm4-128. Default value is aes-256.

  • system_disk_provisioned_iops - (Optional, Int, Available since v1.250.0) The provisioned read/write IOPS of the ESSD AutoPL disk to use as the system disk.

  • system_disk_bursting_enabled - (Optional, Bool, Available since v1.250.0) Specifies whether to enable the performance burst feature for the system disk. Valid values:

    • true: Enables the performance burst feature for the system disk.
    • false: Disables the performance burst feature for the system disk.
  • description - (Optional) Description of the instance, This description can have a string of 2 to 256 characters, It cannot begin with http:// or https://. Default value is null.

  • internet_charge_type - (Optional) Internet charge type of the instance, Valid values are PayByBandwidth, PayByTraffic. At present, 'PrePaid' instance cannot change the value to "PayByBandwidth" from "PayByTraffic". NOTE: From version 1.243.0, the default value PayByTraffic will be removed.

  • internet_max_bandwidth_out - (Optional) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). Value range: [0, 100]. NOTE: From version 1.243.0, the default value 0 will be removed.

  • host_name - (Optional) Host name of the ECS, which is a string of at least two characters. “hostname” cannot start or end with “.” or “-“. In addition, two or more consecutive “.” or “-“ symbols are not allowed. On Windows, the host name can contain a maximum of 15 characters, which can be a combination of uppercase/lowercase letters, numerals, and “-“. The host name cannot contain dots (“.”) or contain only numeric characters. When it is changed, the instance will reboot to make the change take effect. On other OSs such as Linux, the host name can contain a maximum of 64 characters, which can be segments separated by dots (“.”), where each segment can contain uppercase/lowercase letters, numerals, or “_“. When it is changed, the instance will reboot to make the change take effect.

  • password - (Optional, Sensitive) Password to an instance is a string of 8 to 30 characters. It must contain uppercase/lowercase letters and numerals, but cannot contain special symbols. When it is changed, the instance will reboot to make the change take effect.

  • kms_encrypted_password - (Optional, Available since v1.57.1) An KMS encrypts password used to an instance. If the password is filled in, this field will be ignored. When it is changed, the instance will reboot to make the change take effect.

  • kms_encryption_context - (Optional, MapString, Available since v1.57.1) An KMS encryption context used to decrypt kms_encrypted_password before creating or updating an instance with kms_encrypted_password. See Encryption Context. It is valid when kms_encrypted_password is set. When it is changed, the instance will reboot to make the change take effect.

  • vpc_id - (Optional, Available since v1.227.1) The ID of the VPC.

  • vswitch_id - (Optional) The virtual switch ID to launch in VPC. This parameter must be set unless you can create classic network instances. When it is changed, the instance will reboot to make the change take effect.

  • instance_charge_type - (Optional) Valid values are PrePaid, PostPaid. NOTE: From version 1.243.0, the default value PostPaid will be removed. NOTE: Since 1.9.6, it can be changed each other between PostPaid and PrePaid. However, since some limitation about CPU core count in one month, there strongly recommends that Don't change instance_charge_type frequentlly in one month.

  • resource_group_id - (Optional, Available since v1.57.0, Modifiable in 1.115.0) The Id of resource group which the instance belongs.

  • period_unit - (Optional) The duration unit that you will buy the resource. It is valid when instance_charge_type is 'PrePaid'. Valid value: ["Week", "Month"]. Default to "Month".

  • period - (Optional) The duration that you will buy the resource, in month. It is valid and required when instance_charge_type is PrePaid. Valid values:

    • [1-9, 12, 24, 36, 48, 60] when period_unit in "Month"
    • [1-3] when period_unit in "Week"

    -> NOTE: The attribute period is only used to create Subscription instance or modify the PayAsYouGo instance to Subscription. Once effect, it will not be modified that means running terraform apply will not effect the resource.

  • renewal_status - (Optional) Whether to renew an ECS instance automatically or not. It is valid when instance_charge_type is PrePaid. Default to "Normal". Valid values:

    • AutoRenewal: Enable auto renewal.
    • Normal: Disable auto renewal.
    • NotRenewal: No renewal any longer. After you specify this value, Alibaba Cloud stop sending notification of instance expiry, and only gives a brief reminder on the third day before the instance expiry.
  • auto_renew_period - (Optional) Auto renewal period of an instance, in the unit of month. It is valid when instance_charge_type is PrePaid. Default to 1. Valid value:

    • [1, 2, 3, 6, 12] when period_unit in "Month"
    • [1, 2, 3] when period_unit in "Week"
  • tags - (Optional) A mapping of tags to assign to the resource.

    • Key: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
    • Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
  • volume_tags - (Optional) A mapping of tags to assign to the devices created by the instance at launch time.

    • Key: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It cannot be a null string.
    • Value: It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://". It can be a null string.
  • user_data - (Optional) User-defined data to customize the startup behaviors of an ECS instance and to pass data into an ECS instance. It supports to setting a base64-encoded value, and it is the recommended usage. From version 1.60.0, it can be updated in-place. If updated, the instance will reboot to make the change take effect. Note: Not all changes will take effect, and it depends on cloud-init module type.

  • key_name - (Optional) The name of key pair that can login ECS instance successfully without password. If it is specified, the password would be invalid. NOTE: From version 1.268.0, key_name can be modified. If you want to use key_name, We recommend you to use the resource alicloud_ecs_key_pair_attachment.

    -> NOTE: When modifying key_name, if the instance status is Running, the ECS instance will be rebooted; If the instance status is Stopped, the ECS instance status will be changed to Running.

  • include_data_disks - (Optional) Whether to change instance disks charge type when changing instance charge type.

  • dry_run - (Optional) Specifies whether to send a dry-run request. Default to false.

    • true: Only a dry-run request is sent and no instance is created. The system checks whether the required parameters are set, and validates the request format, service permissions, and available ECS instances. If the validation fails, the corresponding error code is returned. If the validation succeeds, the DryRunOperation error code is returned.
    • false: A request is sent. If the validation succeeds, the instance is created.
  • additional_attributes - (Optional, Set, Available since v2.1.0) A set of additional attributes that the provider requests when reading the instance through the DescribeInstances API. It only affects the data returned during terraform refresh and terraform import, and changing it does not trigger any API call that modifies the instance. Configured values are merged into the default set of META_OPTIONS, NETWORK_PRIMARY_ENI_IP, LOGIN_AS_NON_ROOT, DISK_HIGH_DENSITY_MODE and CPU_OPTIONS_TOPOLOGY_TYPE that the provider always requests, so existing reads keep working. Other useful values include DDH_CLUSTER, PRIVATE_DNS_OPTIONS, CURRENT_OS_NVME_SUPPORTED and MANAGED_HOST_ID.

    -> NOTE: The provider always merges its five default attributes into every DescribeInstances query and the API accepts at most 10 values, so at most 5 additional values can be set here. MANAGED_HOST_ID is requested only when configured here and makes the API return the managed host ID inside AdditionalInfo; the state value of managed_host_id is refreshed from the response only when managed_host_id is configured.

  • private_ip - (Optional) Instance private IP address can be specified when you creating new instance. It is valid when vswitch_id is specified. When it is changed, the instance will reboot to make the change take effect.

  • credit_specification - (Optional, Available since v1.57.1) Performance mode of the t5 burstable instance. Valid values: 'Standard', 'Unlimited'.

    -> NOTE: credit_specification is only supported by burstable instance families (e.g. t5, t6). For an existing or imported instance whose instance type does not support credit specification, this field is empty in the state and configuring it does not take effect; no change will be applied, which avoids the Credit.NotFound error from the API.

  • spot_strategy - (Optional, ForceNew) The spot strategy of a Pay-As-You-Go instance, and it takes effect only when parameter instance_charge_type is 'PostPaid'. Value range:

    • NoSpot: A regular Pay-As-You-Go instance.
    • SpotWithPriceLimit: A price threshold for a spot instance
    • SpotAsPriceGo: A price that is based on the highest Pay-As-You-Go instance

    Default to NoSpot. Note: Currently, the spot instance only supports domestic site account.

  • spot_price_limit - (Optional, Float, ForceNew) The hourly price threshold of a instance, and it takes effect only when parameter 'spot_strategy' is 'SpotWithPriceLimit'. Three decimals is allowed at most.

  • deletion_protection - (Optional, Bool) Whether enable the deletion protection or not. It does not work when the instance is spot. Default value: false.

    • true: Enable deletion protection.
    • false: Disable deletion protection.

    -> NOTE: deletion_protection is valid only when instance_charge_type is set to PostPaid.

  • force_delete - (Optional, Available since v1.18.0) If it is true, the PrePaid instance will be change to PostPaid and then deleted forcibly. However, because of changing instance charge type has CPU core count quota limitation, so strongly recommand that "Don't modify instance charge type frequentlly in one month".

  • auto_release_time - (Optional, Available since v1.70.0) The automatic release time of the PostPaid instance. The time follows the ISO 8601 standard and is in UTC time. Format: yyyy-MM-ddTHH:mm:ssZ. It must be at least half an hour later than the current time and less than 3 years since the current time. Setting it to null can cancel automatic release feature, and the ECS instance will not be released automatically.

  • security_enhancement_strategy - (Optional, ForceNew) The security enhancement strategy.

    • Active: Enable security enhancement strategy, it only works on system images.
    • Deactive: Disable security enhancement strategy, it works on all images.

    -> NOTE: The ECS API does not return security_enhancement_strategy, so the provider cannot read it back into the state. For an imported instance (or an instance created without this field), the state value is empty; in this case, configuring or changing security_enhancement_strategy is ignored and will not force the instance to be recreated.

  • data_disks - (Optional, ForceNew, Available since v1.23.1) The list of data disks created with instance. Note: The parameter is immutable after resource creation. This resource only configures these disks during instance creation; it does not update or refresh the inline disk settings. See data_disks below.

  • network_interfaces - (Optional, ForceNew, Available since v1.212.0) The list of network interfaces created with instance. Note: The parameter is immutable after resource creation. See network_interfaces below.

  • status - (Optional 1.85.0) The instance status. Valid values: ["Running", "Stopped"]. You can control the instance start and stop through this parameter. Default to Running.

  • hpc_cluster_id - (Optional, ForceNew, Available since v1.144.0) The ID of the Elastic High Performance Computing (E-HPC) cluster to which to assign the instance.

  • secondary_private_ips - (Optional, Available since v1.144.0) A list of Secondary private IP addresses which is selected from within the CIDR block of the vSwitch.

  • secondary_private_ip_address_count - (Optional, Available since v1.145.0) The number of private IP addresses to be automatically assigned from within the CIDR block of the vswitch. NOTE: To assign secondary private IP addresses, you must specify secondary_private_ips or secondary_private_ip_address_count but not both.

  • deployment_set_id - (Optional, Available since v1.176.0) The ID of the deployment set to which to deploy the instance. NOTE: From version 1.176.0, instance's deploymentSetId can be removed when 'deployment_set_id' = "".

  • operator_type - (Optional, Available since v1.164.0) The operation type. It is valid when instance_charge_type is PrePaid. Default value: upgrade. Valid values: upgrade, downgrade. NOTE: When the new instance type specified by the instance_type parameter has lower specifications than the current instance type, you must set operator_type to downgrade.

  • stopped_mode - (Optional, Available since v1.170.0) The stop mode of the pay-as-you-go instance. Valid values: StopCharging,KeepCharging, Not-applicable. Default value: If the prerequisites required for enabling the economical mode are met, and you have enabled this mode in the ECS console, the default value is StopCharging. For more information, see "Enable the economical mode" in Economical mode. Otherwise, the default value is KeepCharging. Note: Not-applicable: Economical mode is not applicable to the instance.`

    • KeepCharging: standard mode. Billing of the instance continues after the instance is stopped, and resources are retained for the instance.
    • StopCharging: economical mode. Billing of some resources of the instance stops after the instance is stopped. When the instance is stopped, its resources such as vCPUs, memory, and public IP address are released. You may be unable to restart the instance if some types of resources are out of stock in the current region.
  • maintenance_time - (Optional, Available since v1.181.0) The time of maintenance. See maintenance_time below.

  • maintenance_action - (Optional, Available since v1.181.0) The maintenance action. Valid values: Stop, AutoRecover and AutoRedeploy.

    • Stop : stops the instance.
    • AutoRecover : automatically recovers the instance.
    • AutoRedeploy : fails the instance over, which may cause damage to the data disks attached to the instance.
  • maintenance_notify - (Optional, Available since v1.181.0) Specifies whether to send an event notification before instance shutdown. Valid values: true, false. Default value: false.

    • true : sends an event notification.
    • false : does not send an event notification.
  • spot_duration - (Optional, Available since v1.188.0) The retention time of the preemptive instance in hours. Valid values: 0, 1, 2, 3, 4, 5, 6. Retention duration 2~6 is under invitation test, please submit a work order if you need to open. If the value is 0, the mode is no protection period. Default value is 1. Note: The parameter is immutable after resource creation. This resource sends it only when creating the instance.

  • spot_interruption_behavior - (Optional, ForceNew, Available since v1.275.0) The interruption mode of the spot instance. Default value: Terminate. Valid values:

    • Terminate: The instance is released.
    • Stop: The instance is stopped in economical mode.
  • http_tokens - (Optional, Available since v1.192.0) Specifies whether to forcefully use the security-enhanced mode (IMDSv2) to access instance metadata. Default value: optional. Valid values:

    • optional: does not forcefully use the security-enhanced mode (IMDSv2).
    • required: forcefully uses the security-enhanced mode (IMDSv2). After you set this parameter to required, you cannot access instance metadata in normal mode.
  • http_endpoint - (Optional, Available since v1.192.0) Specifies whether to enable the access channel for instance metadata. Valid values: enabled, disabled. Default value: enabled.

  • http_put_response_hop_limit - (Optional, ForceNew) NOTE:: This parameter is not available for use yet. The HTTP PUT response hop limit for accessing instance metadata. Valid values: 1 to 64. Default value: 1.

  • instance_metadata_tags - (Optional, Available since v1.291.0) Specifies whether to expose the tags of the instance in the instance metadata. Valid values: enabled, disabled. Default value: disabled.

  • ipv6_address_count - (Optional, ForceNew, Available since v1.193.0) The number of IPv6 addresses to randomly generate for the primary ENI. Valid values: 1 to 10. NOTE: You cannot specify both the ipv6_addresses and ipv6_address_count parameters.

  • ipv6_addresses - (Optional, Available since v1.193.0) A list of IPv6 address to be assigned to the primary ENI. Support up to 10. NOTE: From version 1.241.0, ipv6_addresses can be modified.

  • dedicated_host_id - (Optional, ForceNew, Available since v1.201.0) The ID of the dedicated host on which to create the instance. If you set the DedicatedHostId parameter, the spot_strategy and spot_price_limit parameters cannot be set. This is because preemptible instances cannot be created on dedicated hosts.

  • managed_host_id - (Optional, ForceNew, Available since v2.1.0) The ID of the managed host on which to create the instance, such as mh-f2d3647ca21****. The managed host refers to the physical machine in the intelligent fully-managed resource pool. NOTE: You cannot specify both the managed_host_id and dedicated_host_id parameters.

    -> NOTE: The managed host of an instance cannot be changed after creation. Modifying it in the configuration triggers a replacement of the instance. The API returns the managed host ID only when additional_attributes contains MANAGED_HOST_ID, and the value is refreshed into the state only while managed_host_id is configured.

  • launch_template_id - (Optional, ForceNew, Available since v1.213.1) The ID of the launch template. For more information, see DescribeLaunchTemplates.To use a launch template to create an instance, you must use the launch_template_id or launch_template_name parameter to specify the launch template.

  • launch_template_name - (Optional, ForceNew, Available since v1.213.1) The name of the launch template.

  • launch_template_version - (Optional, ForceNew, Available since v1.213.1) The version of the launch template. If you set launch_template_id or launch_template_name parameter but do not set the version number of the launch template, the default template version is used.

  • enable_jumbo_frame - (Optional, Bool, Available since v1.223.2) Specifies whether to enable the Jumbo Frames feature for the instance. Valid values: true, false.

  • enable_network_encryption - (Optional, Bool, Available since v1.294.0) Specifies whether to enable network encryption for the instance. Valid values: true, false.

    -> NOTE: VPC traffic encryption is currently in private preview. To use this feature, submit a ticket to request access.

  • enable_high_density_mode - (Optional, Bool, Available since v1.283.0) Specifies whether to enable the high density mode for the instance. Valid values: true, false.

    -> NOTE: Modifying enable_high_density_mode requires the instance to be stopped.

  • network_interface_traffic_mode - (Optional, ForceNew, Available since v1.227.1) The communication mode of the Primary ENI. Default value: Standard. Valid values:

    • Standard: Uses the TCP communication mode.
    • HighPerformance: Uses the remote direct memory access (RDMA) communication mode with Elastic RDMA Interface (ERI) enabled.
  • network_card_index - (Optional, ForceNew, Int, Available since v1.227.1) The index of the network card for Primary ENI.

  • queue_pair_number - (Optional, ForceNew, Int, Available since v1.227.1) The number of queues supported by the ERI.

  • source_dest_check - (Optional, ForceNew, Bool, Available since v1.284.0) Specifies whether to enable the source and destination IP address check feature. We recommend that you enable the feature to improve network security. Valid values: true, false.

  • password_inherit - (Optional, Bool, Available since v1.232.0) Specifies whether to use the password preset in the image. Default value: false. Valid values:

    • true: Uses the preset password.
    • false: Does not use the preset password.

    -> NOTE: If you set password_inherit to true, make sure that you have not specified password or kms_encrypted_password and the selected image has a preset password.

  • private_pool_options_match_criteria - (Optional, Available since v1.253.0) The type of the private pool. Default value: None. Valid values:

    • Open: Open private pool.
    • Target: Specified private pool. NOTE: If private_pool_options_match_criteria is set to Target, private_pool_options_id is required.
    • None: No private pool. The capacity in private pools is not used.
  • private_pool_options_id - (Optional, Available since v1.253.0) The ID of the private pool.

  • image_options - (Optional, Set, Available since v1.237.0) The options of images. Note: The parameter is immutable after resource creation. See image_options below.

  • cpu_options - (Optional, Set, Available since v1.267.0) The options of cpu. See cpu_options below.

  • allocate_public_ip - (Optional, Bool, Deprecated since v1.7.0) Field allocate_public_ip has been deprecated from provider version 1.7.0. Setting internet_max_bandwidth_out larger than 0 will allocate public ip for instance.

  • internet_max_bandwidth_in - (Optional, Int, Deprecated since v1.121.2) Maximum incoming bandwidth from the public network, measured in Mbps (Mega bit per second). Value range: [1, 200]. If this value is not specified, then automatically sets it to 200 Mbps.

  • role_name - (Optional, Deprecated since v1.275.0) The name of the Resource Access Management (RAM) role. NOTE: From version 1.250.0, If you want to use role_name, We recommend you to use the resource alicloud_ecs_ram_role_attachment. Field role_name has been deprecated from provider version 1.275.0. New resource alicloud_ecs_ram_role_attachment instead. From version 1.276.0, role_name can be modified.

    -> NOTE: System disk category cloud has been outdated and it only can be used none I/O Optimized ECS instances. Recommend cloud_efficiency and cloud_ssd disk.

    -> NOTE: From version 1.5.0, instance's charge type can be changed to PrePaid by specifying period and period_unit, but it is irreversible.

    -> NOTE: From version 1.5.0, instance's private IP address can be specified when creating VPC network instance.

    -> NOTE: From version 1.5.0, instance's vswitch and private IP can be changed in the same availability zone. When they are changed, the instance will reboot to make the change take effect.

    -> NOTE: From version 1.7.0, setting "internet_max_bandwidth_out" larger than 0 can allocate a public IP for an instance. Setting "internet_max_bandwidth_out" to 0 can release allocated public IP for VPC instance(For Classic instnace, its public IP cannot be release once it allocated, even thougth its bandwidth out is 0). However, at present, 'PrePaid' instance cannot narrow its max bandwidth out when its 'internet_charge_type' is "PayByBandwidth".

    -> NOTE: From version 1.7.0, instance's type can be changed. When it is changed, the instance will reboot to make the change take effect.

data_disks

The data_disks supports the following:

  • name - (Optional, ForceNew) The name of the data disk.
  • size - (Required, ForceNew) The size of the data disk.
    • cloud:[5, 2000]
    • cloud_efficiency:[20, 32768]
    • cloud_ssd:[20, 32768]
    • cloud_essd:[20, 32768]
    • ephemeral_ssd: [5, 800]
  • category - (Optional, ForceNew, String) The category of the disk. Defaults to cloud_efficiency. Valid values:
    • all: All disk categories.
    • local_disk: The local disk.
    • cloud: The general cloud disk.
    • cloud_efficiency: The efficiency cloud disk.
    • cloud_ssd: The SSD cloud disk.
    • cloud_essd: The ESSD cloud disk.
    • ephemeral_ssd: The local SSD disk.
    • cloud_auto: The AutoPL cloud disk.
    • cloud_essd_entry (Available since v1.232.0) : The ESSD Entry disk.
    • cloud_regional_disk_auto (Available since v1.274.0) : The Regional ESSD.
    • elastic_ephemeral_disk_standard (Available since v1.274.0) : The standard elastic ephemeral disk.
    • elastic_ephemeral_disk_premium (Available since v1.274.0) : The premium elastic ephemeral disk.
    • cloud_essd_xc0 (Available since v2.2.0) : The ESSD XC0 disk, only supported in government cloud (政务云) regions.
    • cloud_essd_xc1 (Available since v2.2.0) : The ESSD XC1 disk, only supported in government cloud (政务云) regions.
  • performance_level - (Optional, ForceNew) The performance level of the ESSD used as data disk:
    • PL0: A single ESSD can deliver up to 10,000 random read/write IOPS.
    • PL1: A single ESSD can deliver up to 50,000 random read/write IOPS.
    • PL2: A single ESSD can deliver up to 100,000 random read/write IOPS.
    • PL3: A single ESSD can deliver up to 1,000,000 random read/write IOPS. Default to PL1.
  • encrypted -(Optional, Bool, ForceNew) Encrypted the data in this disk. Default value: false.
  • kms_key_id - (Optional, Available since v1.90.1) The KMS key ID corresponding to the Nth data disk.
  • snapshot_id - (Optional, ForceNew) The snapshot ID used to initialize the data disk. If the size specified by snapshot is greater that the size of the disk, use the size specified by snapshot as the size of the data disk.
  • auto_snapshot_policy_id - (Optional, ForceNew, Available since v1.73.0) The ID of the automatic snapshot policy applied to the system disk.
  • delete_with_instance - (Optional, ForceNew) Delete this data disk when the instance is destroyed. It only works on cloud, cloud_efficiency, cloud_essd, cloud_ssd disk. If the category of this data disk was ephemeral_ssd, please don't set this param. Default value: true.
  • description - (Optional, ForceNew) The description of the data disk.
  • device - (Optional, ForceNew, Available since v1.183.0) The mount point of the data disk.
  • provisioned_iops - (Optional, ForceNew, Int, Available since v1.250.0) The provisioned read/write IOPS of the ESSD AutoPL disk to use as the data disk.
  • bursting_enabled - (Optional, ForceNew, Bool, Available since v1.250.0) Specifies whether to enable the performance burst feature for the system disk. Valid values:
    • true: Enables the performance burst feature for the data disk.
    • false: Disables the performance burst feature for the data disk.

network_interfaces

The network_interfaces supports the following.

  • network_interface_id - (Optional, ForceNew) The ID of the Secondary ENI.
  • vswitch_id - (Optional, ForceNew, Available since v1.223.2) The ID of the vSwitch to which to connect Secondary ENI N.
  • network_interface_traffic_mode - (Optional, ForceNew, Available since v1.223.2) The communication mode of the Secondary ENI. Default value: Standard. Valid values:
    • Standard: Uses the TCP communication mode.
    • HighPerformance: Uses the remote direct memory access (RDMA) communication mode with Elastic RDMA Interface (ERI) enabled.
  • network_card_index - (Optional, ForceNew, Int, Available since v1.227.1) The index of the network card for Secondary ENI.
  • queue_pair_number - (Optional, ForceNew, Int, Available since v1.227.1) The number of queues supported by the ERI.
  • source_dest_check - (Optional, ForceNew, Bool, Available since v1.284.0) Specifies whether to enable the source and destination IP address check feature. We recommend that you enable the feature to improve network security. Valid values: true, false.
  • security_group_ids - (Optional, ForceNew, List, Available since v1.223.2) The ID of security group N to which to assign Secondary ENI N.

maintenance_time

The maintenance_time supports the following:

  • start_time - (Optional) The start time of maintenance. The time must be on the hour at exactly 0 minute and 0 second. The start_time and end_time parameters must be specified at the same time. The end_time value must be 1 to 23 hours later than the start_time value. Specify the time in the HH:mm:ss format. The time must be in UTC+8.
  • end_time - (Optional) The end time of maintenance. The time must be on the hour at exactly 0 minute and 0 second. The start_time and end_time parameters must be specified at the same time. The end_time value must be 1 to 23 hours later than the start_time value. Specify the time in the HH:mm:ss format. The time must be in UTC+8.

image_options

The image_options supports the following:

  • login_as_non_root - (Optional, ForceNew) Whether to allow the instance logging in with the ecs-user user.

cpu_options

The cpu_options supports the following:

  • core_count - (Optional, Int) The maximum number of partitions in the storage set.

  • threads_per_core - (Optional, Int) The number of threads per CPU core.

  • topology_type - (Optional) The CPU topology type of the instance. Valid values: ContinuousCoreToHTMapping, DiscreteCoreToHTMapping.

  • accelerators - (Optional, List, ForceNew, Available since v1.294.0) The CPU accelerators to enable on the instance, such as the Intel vQAT (QuickAssist Technology) accelerator. Valid values are determined by the API and not yet documented; currently vqat is the only valid value, and invalid values are rejected by the API at apply time.

    -> NOTE: accelerators can only be set at instance creation and is not reported back by the API. It is only supported by specific instance types, for example the standard 8th-generation Intel instance families (ecs.g8i, ecs.c8i, ecs.r8i, ecs.hfc8i, ecs.hfg8i) at 2xlarge size and above. Invalid accelerator values are rejected by the API with InvalidParameter.CpuOptionsAccelerators, and unsupported instance types with InvalidInstanceType.NotSupportCpuOptionsAccelerators.

Attributes Reference

The following attributes are exported:

  • id - The instance ID.
  • public_ip - The instance public ip.
  • cpu - The number of vCPUs.
  • memory - The memory size of the instance. Unit: MiB.
  • os_type - The type of the operating system of the instance.
  • os_name - The name of the operating system of the instance.
  • system_disk_id - (Available since v1.210.0) The ID of system disk.
  • primary_ip_address - The primary private IP address of the ENI.
  • deployment_set_group_no - The group number of the instance in a deployment set when the deployment set is use.
  • create_time - (Available since v1.232.0) The time when the instance was created.
  • start_time - (Available since v1.232.0) The time when the instance was last started.
  • expired_time - (Available since v1.232.0) The expiration time of the instance.

Timeouts

-> NOTE: Available since v1.46.0.

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 10 mins) Used when creating the instance (until it reaches the initial Running status). Note: There are extra at most 2 minutes used to retry to avoid some needless API errors, and it is not in the timeouts configure.
  • update - (Defaults to 10 mins) Used when stopping and starting the instance when necessary during update - e.g. when changing instance type, password, image, vswitch and private IP.
  • delete - (Defaults to 20 mins) Used when terminating the instance. Note: There are extra at most 5 minutes used to retry to avoid some needless API errors, and it is not in the timeouts configure.

Import

Instance can be imported using the id, e.g.

$ terraform import alicloud_instance.example i-abc12345678