Instance

class Instance : KotlinCustomResource

Provides a ECS instance resource.

NOTE: Available since v1.0.0

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.kms.Key;
import com.pulumi.alicloud.kms.KeyArgs;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.ecs.inputs.InstanceDataDiskArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var vpc = new Network("vpc", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("172.16.0.0/16")
.build());
var group = new SecurityGroup("group", SecurityGroupArgs.builder()
.description("foo")
.vpcId(vpc.id())
.build());
var key = new Key("key", KeyArgs.builder()
.description("Hello KMS")
.pendingWindowInDays("7")
.status("Enabled")
.build());
final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
var vswitch = new Switch("vswitch", SwitchArgs.builder()
.vpcId(vpc.id())
.cidrBlock("172.16.0.0/24")
.zoneId(default_.zones()[0].id())
.vswitchName(name)
.build());
var instance = new Instance("instance", InstanceArgs.builder()
.availabilityZone(default_.zones()[0].id())
.securityGroups(group.stream().map(element -> element.id()).collect(toList()))
.instanceType("ecs.n4.large")
.systemDiskCategory("cloud_efficiency")
.systemDiskName(name)
.systemDiskDescription("test_foo_system_disk_description")
.imageId("ubuntu_18_04_64_20G_alibase_20190624.vhd")
.instanceName(name)
.vswitchId(vswitch.id())
.internetMaxBandwidthOut(10)
.dataDisks(InstanceDataDiskArgs.builder()
.name("disk2")
.size(20)
.category("cloud_efficiency")
.description("disk2")
.encrypted(true)
.kmsKeyId(key.id())
.build())
.build());
}
}

Module Support

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

Import

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

$ pulumi import alicloud:ecs/instance:Instance example i-abc12345678

Properties

Link copied to clipboard

It has been deprecated from version "1.7.0". Setting "internet_max_bandwidth_out" larger than 0 can allocate a public ip address for an instance.

Link copied to clipboard
val autoReleaseTime: Output<String>?

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.

Link copied to clipboard
val autoRenewPeriod: Output<Int>?

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:

Link copied to clipboard

The Zone to start the instance in. It is ignored and will be computed when set vswitch_id.

Link copied to clipboard
val cpu: Output<Int>

The number of vCPUs.

Link copied to clipboard

Performance mode of the t5 burstable instance. Valid values: 'Standard', 'Unlimited'.

Link copied to clipboard

The list of data disks created with instance. See data_disks below.

Link copied to clipboard
val dedicatedHostId: Output<String>?

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.

Link copied to clipboard

Whether enable the deletion protection or not. It does not work when the instance is spot. Default value: false.

Link copied to clipboard

The group number of the instance in a deployment set when the deployment set is use.

Link copied to clipboard
val deploymentSetId: Output<String>?

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' = "".

Link copied to clipboard
val description: Output<String>?

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.

Link copied to clipboard
val dryRun: Output<Boolean>?

Specifies whether to send a dry-run request. Default to false.

Link copied to clipboard
val forceDelete: Output<Boolean>?

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".

Link copied to clipboard
val hostName: Output<String>

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.

Link copied to clipboard
val hpcClusterId: Output<String>?

The ID of the Elastic High Performance Computing (E-HPC) cluster to which to assign the instance.

Link copied to clipboard
val httpEndpoint: Output<String>

Specifies whether to enable the access channel for instance metadata. Valid values: enabled, disabled. Default value: enabled.

Link copied to clipboard

The HTTP PUT response hop limit for accessing instance metadata. Valid values: 1 to 64. Default value: 1.

Link copied to clipboard
val httpTokens: Output<String>

Specifies whether to forcefully use the security-enhanced mode (IMDSv2) to access instance metadata. Default value: optional. Valid values:

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val imageId: Output<String>

The Image to use for the instance. ECS instance's image can be replaced via changing image_id. When it is changed, the instance will reboot to make the change take effect.

Link copied to clipboard

Whether to change instance disks charge type when changing instance charge type.

Link copied to clipboard

Valid values are PrePaid, PostPaid, The default is PostPaid. 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.

Link copied to clipboard
val instanceName: Output<String>?
Link copied to clipboard
val instanceType: Output<String>

The type of instance to start. When it is changed, the instance will reboot to make the change take effect.

Link copied to clipboard

Internet charge type of the instance, Valid values are PayByBandwidth, PayByTraffic. Default is PayByTraffic. At present, 'PrePaid' instance cannot change the value to "PayByBandwidth" from "PayByTraffic".

Link copied to clipboard

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.

Link copied to clipboard

Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). Value range: 0, 100. Default to 0 Mbps.

Link copied to clipboard
val ioOptimized: Output<String>?

It has been deprecated on instance resource. All the launched alicloud instances will be I/O optimized.

Link copied to clipboard
val ipv6AddressCount: Output<Int>

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.

Link copied to clipboard
val ipv6Addresses: Output<List<String>>

A list of IPv6 address to be assigned to the primary ENI. Support up to 10.

Link copied to clipboard
val isOutdated: Output<Boolean>?

Whether to use outdated instance type. Default to false.

Link copied to clipboard
val keyName: Output<String>

The name of key pair that can login ECS instance successfully without password. If it is specified, the password would be invalid.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

The maintenance action. Valid values: Stop, AutoRecover and AutoRedeploy.

Link copied to clipboard

Specifies whether to send an event notification before instance shutdown. Valid values: true, false. Default value: false.

Link copied to clipboard

The time of maintenance. See maintenance_time below.

Link copied to clipboard
val memory: Output<Int>

The memory size of the instance. Unit: MiB.

Link copied to clipboard

The ID of the ENI.

Link copied to clipboard
val operatorType: Output<String>?

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.

Link copied to clipboard
val osName: Output<String>

The name of the operating system of the instance.

Link copied to clipboard
val osType: Output<String>

The type of the operating system of the instance.

Link copied to clipboard
val password: Output<String>?

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.

Link copied to clipboard
val period: Output<Int>?

The duration that you will buy the resource, in month. It is valid when instance_charge_type is PrePaid. Valid values:

Link copied to clipboard
val periodUnit: Output<String>?

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".

Link copied to clipboard

The primary private IP address of the ENI.

Link copied to clipboard
val privateIp: Output<String>

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.

Link copied to clipboard
val publicIp: Output<String>

The instance public ip.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val renewalStatus: Output<String>?

Whether to renew an ECS instance automatically or not. It is valid when instance_charge_type is PrePaid. Default to "Normal". Valid values:

Link copied to clipboard
val resourceGroupId: Output<String>?

The Id of resource group which the instance belongs.

Link copied to clipboard
val roleName: Output<String>

Instance RAM role name. The name is provided and maintained by RAM. You can use alicloud.ram.Role to create a new one.

Link copied to clipboard

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.

Link copied to clipboard

A list of Secondary private IP addresses which is selected from within the CIDR block of the VSwitch.

Link copied to clipboard

The security enhancement strategy.

Link copied to clipboard
val securityGroups: Output<List<String>>

A list of security group ids to associate with.

Link copied to clipboard
val spotDuration: Output<Int>

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.

Link copied to clipboard
val spotPriceLimit: Output<Double>?

The hourly price threshold of a instance, and it takes effect only when parameter 'spot_strategy' is 'SpotWithPriceLimit'. Three decimals is allowed at most.

Link copied to clipboard
val spotStrategy: Output<String>

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

Link copied to clipboard
val status: Output<String>

The instance status. Valid values: "Running", "Stopped". You can control the instance start and stop through this parameter. Default to Running.

Link copied to clipboard
val stoppedMode: Output<String>

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.`

Link copied to clipboard

The ID of the automatic snapshot policy applied to the system disk.

Link copied to clipboard

Valid values are ephemeral_ssd, cloud_efficiency, cloud_ssd, cloud_essd, cloud, cloud_auto. only is used to some none I/O optimized instance. Default to cloud_efficiency. Valid values cloud_auto Available since 1.184.0+.

Link copied to clipboard

The description of the system disk. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

Link copied to clipboard

The algorithm to be used to encrypt the system disk. Valid values are aes-256, sm4-128. Default value is aes-256.

Link copied to clipboard

Specifies whether to encrypt the system disk. Valid values: true,false. Default value: false.

Link copied to clipboard
val systemDiskId: Output<String>

(Available since v1.210.0) The ID of system disk.

Link copied to clipboard

The ID of the Key Management Service (KMS) key to be used for the system disk.

Link copied to clipboard
val systemDiskName: Output<String>?

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://.

Link copied to clipboard

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.

Link copied to clipboard
val systemDiskSize: Output<Int>?

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}.

Link copied to clipboard

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, see What is Dedicated Block Storage Cluster?.

Link copied to clipboard
val tags: Output<Map<String, String>>?

A mapping of tags to assign to the resource.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userData: Output<String>?
Link copied to clipboard
val volumeTags: Output<Map<String, Any>>

A mapping of tags to assign to the devices created by the instance at launch time.

Link copied to clipboard
val vswitchId: Output<String>?

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.