@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
363 lines • 17.8 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Instance = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an ECS VM instance resource within HuaweiCloud.
*
* ## Example Usage
* ### Basic Instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as huaweicloud from "@pulumi/huaweicloud";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const myaz = huaweicloud.getAvailabilityZones({});
* const myflavor = myaz.then(myaz => huaweicloud.Ecs.getFlavors({
* availabilityZone: myaz.names?[0],
* performanceType: "normal",
* cpuCoreCount: 2,
* memorySize: 4,
* }));
* const mynet = huaweicloud.Vpc.getSubnet({
* name: "subnet-default",
* });
* const myimage = huaweicloud.Ims.getImage({
* name: "Ubuntu 18.04 server 64bit",
* mostRecent: true,
* });
* const basic = new huaweicloud.ecs.Instance("basic", {
* imageId: myimage.then(myimage => myimage.id),
* flavorId: myflavor.then(myflavor => myflavor.ids?[0]),
* securityGroupIds: [secgroupId],
* availabilityZone: myaz.then(myaz => myaz.names?[0]),
* networks: [{
* uuid: mynet.then(mynet => mynet.id),
* }],
* });
* ```
* ### Instance With Associated Eip
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const myinstance = new huaweicloud.ecs.Instance("myinstance", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [secgroupId],
* availabilityZone: "cn-north-4a",
* networks: [{
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* }],
* });
* const myeip = new huaweicloud.vpc.Eip("myeip", {
* publicip: {
* type: "5_bgp",
* },
* bandwidth: {
* name: "test",
* size: 8,
* shareType: "PER",
* chargeMode: "traffic",
* },
* });
* const associated = new huaweicloud.ecs.EipAssociate("associated", {
* publicIp: myeip.address,
* instanceId: myinstance.id,
* });
* ```
* ### Instance With Attached Volume
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const myvolume = new huaweicloud.evs.Volume("myvolume", {
* availabilityZone: "cn-north-4a",
* volumeType: "SAS",
* size: 10,
* });
* const myinstance = new huaweicloud.ecs.Instance("myinstance", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [secgroupId],
* availabilityZone: "cn-north-4a",
* networks: [{
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* }],
* });
* const attached = new huaweicloud.ecs.VolumeAttach("attached", {
* instanceId: myinstance.id,
* volumeId: myvolume.id,
* });
* ```
* ### Instance With Multiple Data Disks
*
* It's possible to specify multiple `dataDisks` entries to create an instance with multiple data disks, but we can't
* ensure the volume attached order. So it's recommended to use `Instance With Attached Volume` above.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const multi_disk = new huaweicloud.ecs.Instance("multi-disk", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [secgroupId],
* availabilityZone: "cn-north-4a",
* systemDiskType: "SAS",
* systemDiskSize: 40,
* dataDisks: [
* {
* type: "SAS",
* size: 10,
* },
* {
* type: "SAS",
* size: 20,
* },
* ],
* deleteDisksOnTermination: true,
* networks: [{
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* }],
* });
* ```
* ### Instance With Multiple Networks
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const multi_net = new huaweicloud.ecs.Instance("multi-net", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [secgroupId],
* availabilityZone: "cn-north-4a",
* networks: [
* {
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* },
* {
* uuid: "3c4a0d74-24b9-46cf-9d7f-8b7a4dc2f65c",
* },
* ],
* });
* ```
* ### Instance with User Data (cloud-init)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const secgroupId = config.requireObject("secgroupId");
* const myinstance = new huaweicloud.ecs.Instance("myinstance", {
* imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743",
* flavorId: "s6.small.1",
* keyPair: "my_key_pair_name",
* securityGroupIds: [secgroupId],
* availabilityZone: "az",
* userData: `#cloud-config
* hostname: instance_1.example.com
* fqdn: instance_1.example.com`,
* networks: [{
* uuid: "55534eaa-533a-419d-9b40-ec427ea7195a",
* }],
* });
* ```
*
* ## Import
*
* Instances can be imported by their `id`. For example,
*
* ```sh
* $ pulumi import huaweicloud:Ecs/instance:Instance my_instance b11b407c-e604-4e8d-8bc4-92398320b847
* ```
*
* Note that the imported state may not be identical to your resource definition, due to some attributes missing from the API response, security or some other reason. The missing attributes include`admin_pass`, `user_data`, `metadata`, `data_disks`, `scheduler_hints`, `stop_before_destroy`, `delete_disks_on_termination`, `delete_eip_on_termination`, `network/access_network`, `bandwidth`, `eip_type`, `power_action` and arguments for pre-paid and spot price. It is generally recommended running `terraform plan` after importing an instance. You can then decide if changes should be applied to the instance, or the resource definition should be updated to align with the instance. Also you can ignore changes as below. hcl resource "huaweicloud_compute_instance" "myinstance" {
*
* ...
*
* lifecycle {
*
* ignore_changes = [
*
* user_data, data_disks,
*
* ]
*
* } }
*/
class Instance extends pulumi.CustomResource {
/**
* Get an existing Instance resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new Instance(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Instance. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Instance.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["accessIpV4"] = state ? state.accessIpV4 : undefined;
resourceInputs["accessIpV6"] = state ? state.accessIpV6 : undefined;
resourceInputs["adminPass"] = state ? state.adminPass : undefined;
resourceInputs["agencyName"] = state ? state.agencyName : undefined;
resourceInputs["agentList"] = state ? state.agentList : undefined;
resourceInputs["autoPay"] = state ? state.autoPay : undefined;
resourceInputs["autoRenew"] = state ? state.autoRenew : undefined;
resourceInputs["autoTerminateTime"] = state ? state.autoTerminateTime : undefined;
resourceInputs["availabilityZone"] = state ? state.availabilityZone : undefined;
resourceInputs["bandwidth"] = state ? state.bandwidth : undefined;
resourceInputs["chargingMode"] = state ? state.chargingMode : undefined;
resourceInputs["createdAt"] = state ? state.createdAt : undefined;
resourceInputs["dataDisks"] = state ? state.dataDisks : undefined;
resourceInputs["deleteDisksOnTermination"] = state ? state.deleteDisksOnTermination : undefined;
resourceInputs["deleteEipOnTermination"] = state ? state.deleteEipOnTermination : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["eipId"] = state ? state.eipId : undefined;
resourceInputs["eipType"] = state ? state.eipType : undefined;
resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined;
resourceInputs["expiredTime"] = state ? state.expiredTime : undefined;
resourceInputs["flavorId"] = state ? state.flavorId : undefined;
resourceInputs["flavorName"] = state ? state.flavorName : undefined;
resourceInputs["hostname"] = state ? state.hostname : undefined;
resourceInputs["imageId"] = state ? state.imageId : undefined;
resourceInputs["imageName"] = state ? state.imageName : undefined;
resourceInputs["keyPair"] = state ? state.keyPair : undefined;
resourceInputs["metadata"] = state ? state.metadata : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["networks"] = state ? state.networks : undefined;
resourceInputs["period"] = state ? state.period : undefined;
resourceInputs["periodUnit"] = state ? state.periodUnit : undefined;
resourceInputs["powerAction"] = state ? state.powerAction : undefined;
resourceInputs["privateKey"] = state ? state.privateKey : undefined;
resourceInputs["publicIp"] = state ? state.publicIp : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["schedulerHints"] = state ? state.schedulerHints : undefined;
resourceInputs["securityGroupIds"] = state ? state.securityGroupIds : undefined;
resourceInputs["securityGroups"] = state ? state.securityGroups : undefined;
resourceInputs["spotDuration"] = state ? state.spotDuration : undefined;
resourceInputs["spotDurationCount"] = state ? state.spotDurationCount : undefined;
resourceInputs["spotMaximumPrice"] = state ? state.spotMaximumPrice : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["stopBeforeDestroy"] = state ? state.stopBeforeDestroy : undefined;
resourceInputs["systemDiskDssPoolId"] = state ? state.systemDiskDssPoolId : undefined;
resourceInputs["systemDiskId"] = state ? state.systemDiskId : undefined;
resourceInputs["systemDiskIops"] = state ? state.systemDiskIops : undefined;
resourceInputs["systemDiskKmsKeyId"] = state ? state.systemDiskKmsKeyId : undefined;
resourceInputs["systemDiskSize"] = state ? state.systemDiskSize : undefined;
resourceInputs["systemDiskThroughput"] = state ? state.systemDiskThroughput : undefined;
resourceInputs["systemDiskType"] = state ? state.systemDiskType : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["updatedAt"] = state ? state.updatedAt : undefined;
resourceInputs["userData"] = state ? state.userData : undefined;
resourceInputs["userId"] = state ? state.userId : undefined;
resourceInputs["volumeAttacheds"] = state ? state.volumeAttacheds : undefined;
}
else {
const args = argsOrState;
if ((!args || args.networks === undefined) && !opts.urn) {
throw new Error("Missing required property 'networks'");
}
resourceInputs["adminPass"] = args ? args.adminPass : undefined;
resourceInputs["agencyName"] = args ? args.agencyName : undefined;
resourceInputs["agentList"] = args ? args.agentList : undefined;
resourceInputs["autoPay"] = args ? args.autoPay : undefined;
resourceInputs["autoRenew"] = args ? args.autoRenew : undefined;
resourceInputs["autoTerminateTime"] = args ? args.autoTerminateTime : undefined;
resourceInputs["availabilityZone"] = args ? args.availabilityZone : undefined;
resourceInputs["bandwidth"] = args ? args.bandwidth : undefined;
resourceInputs["chargingMode"] = args ? args.chargingMode : undefined;
resourceInputs["dataDisks"] = args ? args.dataDisks : undefined;
resourceInputs["deleteDisksOnTermination"] = args ? args.deleteDisksOnTermination : undefined;
resourceInputs["deleteEipOnTermination"] = args ? args.deleteEipOnTermination : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["eipId"] = args ? args.eipId : undefined;
resourceInputs["eipType"] = args ? args.eipType : undefined;
resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined;
resourceInputs["flavorId"] = args ? args.flavorId : undefined;
resourceInputs["flavorName"] = args ? args.flavorName : undefined;
resourceInputs["hostname"] = args ? args.hostname : undefined;
resourceInputs["imageId"] = args ? args.imageId : undefined;
resourceInputs["imageName"] = args ? args.imageName : undefined;
resourceInputs["keyPair"] = args ? args.keyPair : undefined;
resourceInputs["metadata"] = args ? args.metadata : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["networks"] = args ? args.networks : undefined;
resourceInputs["period"] = args ? args.period : undefined;
resourceInputs["periodUnit"] = args ? args.periodUnit : undefined;
resourceInputs["powerAction"] = args ? args.powerAction : undefined;
resourceInputs["privateKey"] = args ? args.privateKey : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["schedulerHints"] = args ? args.schedulerHints : undefined;
resourceInputs["securityGroupIds"] = args ? args.securityGroupIds : undefined;
resourceInputs["securityGroups"] = args ? args.securityGroups : undefined;
resourceInputs["spotDuration"] = args ? args.spotDuration : undefined;
resourceInputs["spotDurationCount"] = args ? args.spotDurationCount : undefined;
resourceInputs["spotMaximumPrice"] = args ? args.spotMaximumPrice : undefined;
resourceInputs["stopBeforeDestroy"] = args ? args.stopBeforeDestroy : undefined;
resourceInputs["systemDiskDssPoolId"] = args ? args.systemDiskDssPoolId : undefined;
resourceInputs["systemDiskIops"] = args ? args.systemDiskIops : undefined;
resourceInputs["systemDiskKmsKeyId"] = args ? args.systemDiskKmsKeyId : undefined;
resourceInputs["systemDiskSize"] = args ? args.systemDiskSize : undefined;
resourceInputs["systemDiskThroughput"] = args ? args.systemDiskThroughput : undefined;
resourceInputs["systemDiskType"] = args ? args.systemDiskType : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["userData"] = args ? args.userData : undefined;
resourceInputs["userId"] = args ? args.userId : undefined;
resourceInputs["accessIpV4"] = undefined /*out*/;
resourceInputs["accessIpV6"] = undefined /*out*/;
resourceInputs["createdAt"] = undefined /*out*/;
resourceInputs["expiredTime"] = undefined /*out*/;
resourceInputs["publicIp"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
resourceInputs["systemDiskId"] = undefined /*out*/;
resourceInputs["updatedAt"] = undefined /*out*/;
resourceInputs["volumeAttacheds"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Instance.__pulumiType, name, resourceInputs, opts);
}
}
exports.Instance = Instance;
/** @internal */
Instance.__pulumiType = 'huaweicloud:Ecs/instance:Instance';
//# sourceMappingURL=instance.js.map