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