All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.alicloud.ecp.kotlin.Instance.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 3.62.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.alicloud.ecp.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

/**
 * Builder for [Instance].
 */
@PulumiTagMarker
public class InstanceResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: InstanceArgs = InstanceArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend InstanceArgsBuilder.() -> Unit) {
        val builder = InstanceArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Instance {
        val builtJavaResource = com.pulumi.alicloud.ecp.Instance(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Instance(builtJavaResource)
    }
}

/**
 * Provides a Elastic Cloud Phone (ECP) Instance resource.
 * For information about Elastic Cloud Phone (ECP) Instance and how to use it,
 * see [What is Instance](https://www.alibabacloud.com/help/en/cloudphone/latest/api-cloudphone-2020-12-30-runinstances).
 * > **NOTE:** Available since v1.158.0.
 * ## Example Usage
 * Basic Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as alicloud from "@pulumi/alicloud";
 * import * as random from "@pulumi/random";
 * const config = new pulumi.Config();
 * const name = config.get("name") || "tf-example";
 * const defaultInteger = new random.index.Integer("default", {
 *     min: 10000,
 *     max: 99999,
 * });
 * const default = alicloud.ecp.getZones({});
 * const defaultGetInstanceTypes = alicloud.ecp.getInstanceTypes({});
 * const countSize = _default.then(_default => _default.zones).length;
 * const zoneId = Promise.all([_default, countSize]).then(([_default, countSize]) => _default.zones[countSize - 1].zoneId);
 * const instanceTypeCountSize = defaultGetInstanceTypes.then(defaultGetInstanceTypes => defaultGetInstanceTypes.instanceTypes).length;
 * const instanceType = Promise.all([defaultGetInstanceTypes, instanceTypeCountSize]).then(([defaultGetInstanceTypes, instanceTypeCountSize]) => defaultGetInstanceTypes.instanceTypes[instanceTypeCountSize - 1].instanceType);
 * const defaultGetNetworks = alicloud.vpc.getNetworks({
 *     nameRegex: "^default-NODELETING$",
 * });
 * const defaultGetSwitches = defaultGetNetworks.then(defaultGetNetworks => alicloud.vpc.getSwitches({
 *     vpcId: defaultGetNetworks.ids?.[0],
 *     zoneId: zoneId,
 * }));
 * const group = new alicloud.ecs.SecurityGroup("group", {
 *     name: name,
 *     vpcId: defaultGetNetworks.then(defaultGetNetworks => defaultGetNetworks.ids?.[0]),
 * });
 * const defaultKeyPair = new alicloud.ecp.KeyPair("default", {
 *     keyPairName: `${name}-${defaultInteger.result}`,
 *     publicKeyBody: "ssh-rsa AAAAB3Nza12345678qwertyuudsfsg",
 * });
 * const defaultInstance = new alicloud.ecp.Instance("default", {
 *     instanceName: name,
 *     description: name,
 *     keyPairName: defaultKeyPair.keyPairName,
 *     securityGroupId: group.id,
 *     vswitchId: defaultGetSwitches.then(defaultGetSwitches => defaultGetSwitches.ids?.[0]),
 *     imageId: "android_9_0_0_release_2851157_20211201.vhd",
 *     instanceType: defaultGetInstanceTypes.then(defaultGetInstanceTypes => defaultGetInstanceTypes.instanceTypes?.[1]?.instanceType),
 *     vncPassword: "Ecp123",
 *     paymentType: "PayAsYouGo",
 *     force: true,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_alicloud as alicloud
 * import pulumi_random as random
 * config = pulumi.Config()
 * name = config.get("name")
 * if name is None:
 *     name = "tf-example"
 * default_integer = random.index.Integer("default",
 *     min=10000,
 *     max=99999)
 * default = alicloud.ecp.get_zones()
 * default_get_instance_types = alicloud.ecp.get_instance_types()
 * count_size = len(default.zones)
 * zone_id = default.zones[count_size - 1].zone_id
 * instance_type_count_size = len(default_get_instance_types.instance_types)
 * instance_type = default_get_instance_types.instance_types[instance_type_count_size - 1].instance_type
 * default_get_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
 * default_get_switches = alicloud.vpc.get_switches(vpc_id=default_get_networks.ids[0],
 *     zone_id=zone_id)
 * group = alicloud.ecs.SecurityGroup("group",
 *     name=name,
 *     vpc_id=default_get_networks.ids[0])
 * default_key_pair = alicloud.ecp.KeyPair("default",
 *     key_pair_name=f"{name}-{default_integer['result']}",
 *     public_key_body="ssh-rsa AAAAB3Nza12345678qwertyuudsfsg")
 * default_instance = alicloud.ecp.Instance("default",
 *     instance_name=name,
 *     description=name,
 *     key_pair_name=default_key_pair.key_pair_name,
 *     security_group_id=group.id,
 *     vswitch_id=default_get_switches.ids[0],
 *     image_id="android_9_0_0_release_2851157_20211201.vhd",
 *     instance_type=default_get_instance_types.instance_types[1].instance_type,
 *     vnc_password="Ecp123",
 *     payment_type="PayAsYouGo",
 *     force=True)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using AliCloud = Pulumi.AliCloud;
 * using Random = Pulumi.Random;
 * return await Deployment.RunAsync(() =>
 * {
 *     var config = new Config();
 *     var name = config.Get("name") ?? "tf-example";
 *     var defaultInteger = new Random.Index.Integer("default", new()
 *     {
 *         Min = 10000,
 *         Max = 99999,
 *     });
 *     var @default = AliCloud.Ecp.GetZones.Invoke();
 *     var defaultGetInstanceTypes = AliCloud.Ecp.GetInstanceTypes.Invoke();
 *     var countSize = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)).Length;
 *     var zoneId = Output.Tuple(@default, countSize).Apply(values =>
 *     {
 *         var @default = values.Item1;
 *         var countSize = values.Item2;
 *         return @default.Apply(getZonesResult => getZonesResult.Zones)[countSize - 1].ZoneId;
 *     });
 *     var instanceTypeCountSize = defaultGetInstanceTypes.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes).Length;
 *     var instanceType = Output.Tuple(defaultGetInstanceTypes, instanceTypeCountSize).Apply(values =>
 *     {
 *         var defaultGetInstanceTypes = values.Item1;
 *         var instanceTypeCountSize = values.Item2;
 *         return defaultGetInstanceTypes.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes)[instanceTypeCountSize - 1].InstanceType;
 *     });
 *     var defaultGetNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
 *     {
 *         NameRegex = "^default-NODELETING$",
 *     });
 *     var defaultGetSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
 *     {
 *         VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
 *         ZoneId = zoneId,
 *     });
 *     var @group = new AliCloud.Ecs.SecurityGroup("group", new()
 *     {
 *         Name = name,
 *         VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
 *     });
 *     var defaultKeyPair = new AliCloud.Ecp.KeyPair("default", new()
 *     {
 *         KeyPairName = $"{name}-{defaultInteger.Result}",
 *         PublicKeyBody = "ssh-rsa AAAAB3Nza12345678qwertyuudsfsg",
 *     });
 *     var defaultInstance = new AliCloud.Ecp.Instance("default", new()
 *     {
 *         InstanceName = name,
 *         Description = name,
 *         KeyPairName = defaultKeyPair.KeyPairName,
 *         SecurityGroupId = @group.Id,
 *         VswitchId = defaultGetSwitches.Apply(getSwitchesResult => getSwitchesResult.Ids[0]),
 *         ImageId = "android_9_0_0_release_2851157_20211201.vhd",
 *         InstanceType = defaultGetInstanceTypes.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes[1]?.InstanceType),
 *         VncPassword = "Ecp123",
 *         PaymentType = "PayAsYouGo",
 *         Force = true,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"fmt"
 * 	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecp"
 * 	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
 * 	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
 * 	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		cfg := config.New(ctx, "")
 * 		name := "tf-example"
 * 		if param := cfg.Get("name"); param != "" {
 * 			name = param
 * 		}
 * 		defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
 * 			Min: 10000,
 * 			Max: 99999,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_default, err := ecp.GetZones(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultGetInstanceTypes, err := ecp.GetInstanceTypes(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		countSize := len(_default.Zones)
 * 		zoneId := _default.Zones[countSize-1].ZoneId
 * 		instanceTypeCountSize := len(defaultGetInstanceTypes.InstanceTypes)
 * 		_ := defaultGetInstanceTypes.InstanceTypes[instanceTypeCountSize-1].InstanceType
 * 		defaultGetNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
 * 			NameRegex: pulumi.StringRef("^default-NODELETING$"),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultGetSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
 * 			VpcId:  pulumi.StringRef(defaultGetNetworks.Ids[0]),
 * 			ZoneId: pulumi.StringRef(zoneId),
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		group, err := ecs.NewSecurityGroup(ctx, "group", &ecs.SecurityGroupArgs{
 * 			Name:  pulumi.String(name),
 * 			VpcId: pulumi.String(defaultGetNetworks.Ids[0]),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultKeyPair, err := ecp.NewKeyPair(ctx, "default", &ecp.KeyPairArgs{
 * 			KeyPairName:   pulumi.Sprintf("%v-%v", name, defaultInteger.Result),
 * 			PublicKeyBody: pulumi.String("ssh-rsa AAAAB3Nza12345678qwertyuudsfsg"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = ecp.NewInstance(ctx, "default", &ecp.InstanceArgs{
 * 			InstanceName:    pulumi.String(name),
 * 			Description:     pulumi.String(name),
 * 			KeyPairName:     defaultKeyPair.KeyPairName,
 * 			SecurityGroupId: group.ID(),
 * 			VswitchId:       pulumi.String(defaultGetSwitches.Ids[0]),
 * 			ImageId:         pulumi.String("android_9_0_0_release_2851157_20211201.vhd"),
 * 			InstanceType:    pulumi.String(defaultGetInstanceTypes.InstanceTypes[1].InstanceType),
 * 			VncPassword:     pulumi.String("Ecp123"),
 * 			PaymentType:     pulumi.String("PayAsYouGo"),
 * 			Force:           pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.random.integer;
 * import com.pulumi.random.IntegerArgs;
 * import com.pulumi.alicloud.ecp.EcpFunctions;
 * import com.pulumi.alicloud.ecp.inputs.GetZonesArgs;
 * import com.pulumi.alicloud.ecp.inputs.GetInstanceTypesArgs;
 * import com.pulumi.alicloud.vpc.VpcFunctions;
 * import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
 * import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
 * import com.pulumi.alicloud.ecs.SecurityGroup;
 * import com.pulumi.alicloud.ecs.SecurityGroupArgs;
 * import com.pulumi.alicloud.ecp.KeyPair;
 * import com.pulumi.alicloud.ecp.KeyPairArgs;
 * import com.pulumi.alicloud.ecp.Instance;
 * import com.pulumi.alicloud.ecp.InstanceArgs;
 * 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("tf-example");
 *         var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
 *             .min(10000)
 *             .max(99999)
 *             .build());
 *         final var default = EcpFunctions.getZones();
 *         final var defaultGetInstanceTypes = EcpFunctions.getInstanceTypes();
 *         final var countSize = default_.zones().length();
 *         final var zoneId = default_.zones()[countSize - 1].zoneId();
 *         final var instanceTypeCountSize = defaultGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()).length();
 *         final var instanceType = defaultGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes())[instanceTypeCountSize - 1].instanceType();
 *         final var defaultGetNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
 *             .nameRegex("^default-NODELETING$")
 *             .build());
 *         final var defaultGetSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
 *             .vpcId(defaultGetNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
 *             .zoneId(zoneId)
 *             .build());
 *         var group = new SecurityGroup("group", SecurityGroupArgs.builder()
 *             .name(name)
 *             .vpcId(defaultGetNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
 *             .build());
 *         var defaultKeyPair = new KeyPair("defaultKeyPair", KeyPairArgs.builder()
 *             .keyPairName(String.format("%s-%s", name,defaultInteger.result()))
 *             .publicKeyBody("ssh-rsa AAAAB3Nza12345678qwertyuudsfsg")
 *             .build());
 *         var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
 *             .instanceName(name)
 *             .description(name)
 *             .keyPairName(defaultKeyPair.keyPairName())
 *             .securityGroupId(group.id())
 *             .vswitchId(defaultGetSwitches.applyValue(getSwitchesResult -> getSwitchesResult.ids()[0]))
 *             .imageId("android_9_0_0_release_2851157_20211201.vhd")
 *             .instanceType(defaultGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[1].instanceType()))
 *             .vncPassword("Ecp123")
 *             .paymentType("PayAsYouGo")
 *             .force("true")
 *             .build());
 *     }
 * }
 * ```
 * 
 * ## Import
 * Elastic Cloud Phone (ECP) Instance can be imported using the id, e.g.
 * ```sh
 * $ pulumi import alicloud:ecp/instance:Instance example 
 * ```
 */
public class Instance internal constructor(
    override val javaResource: com.pulumi.alicloud.ecp.Instance,
) : KotlinCustomResource(javaResource, InstanceMapper) {
    /**
     * The auto pay.
     */
    public val autoPay: Output?
        get() = javaResource.autoPay().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The auto renew.
     */
    public val autoRenew: Output?
        get() = javaResource.autoRenew().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Description of the instance. 2 to 256 English or Chinese characters in length and cannot
     * start with `http://` and `https`.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The eip bandwidth.
     */
    public val eipBandwidth: Output?
        get() = javaResource.eipBandwidth().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The force.
     */
    public val force: Output?
        get() = javaResource.force().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The ID Of The Image.
     */
    public val imageId: Output
        get() = javaResource.imageId().applyValue({ args0 -> args0 })

    /**
     * The name of the instance. It must be 2 to 128 characters in length and must start with an
     * uppercase letter or Chinese. It cannot start with http:// or https. It can contain Chinese, English, numbers,
     * half-width colons (:), underscores (_), half-width periods (.), or dashes (-). The default value is the InstanceId of
     * the instance.
     */
    public val instanceName: Output?
        get() = javaResource.instanceName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Instance Type.
     */
    public val instanceType: Output
        get() = javaResource.instanceType().applyValue({ args0 -> args0 })

    /**
     * The name of the key pair of the mobile phone instance.
     */
    public val keyPairName: Output?
        get() = javaResource.keyPairName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The payment type.Valid values: `PayAsYouGo`,`Subscription`
     */
    public val paymentType: Output?
        get() = javaResource.paymentType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The period. It is valid when `period_unit` is 'Year'. Valid value: `1`, `2`, `3`, `4`, `5`. It
     * is valid when `period_unit` is 'Month'. Valid value: `1`, `2`, `3`, `5`
     */
    public val period: Output?
        get() = javaResource.period().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The duration unit that you will buy the resource. Valid value: `Year`,`Month`. Default
     * to `Month`.
     */
    public val periodUnit: Output?
        get() = javaResource.periodUnit().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The selected resolution for the cloud mobile phone instance.
     */
    public val resolution: Output
        get() = javaResource.resolution().applyValue({ args0 -> args0 })

    /**
     * The ID of the security group. The security group is the same as that of the
     * ECS instance.
     */
    public val securityGroupId: Output
        get() = javaResource.securityGroupId().applyValue({ args0 -> args0 })

    /**
     * Instance status. Valid values: `Running`, `Stopped`.
     */
    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    /**
     * Cloud mobile phone VNC password. The password must be six characters in length and must
     * contain only uppercase, lowercase English letters and Arabic numerals.
     */
    public val vncPassword: Output?
        get() = javaResource.vncPassword().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The vswitch id.
     */
    public val vswitchId: Output
        get() = javaResource.vswitchId().applyValue({ args0 -> args0 })
}

public object InstanceMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.alicloud.ecp.Instance::class == javaResource::class

    override fun map(javaResource: Resource): Instance = Instance(
        javaResource as
            com.pulumi.alicloud.ecp.Instance,
    )
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Instance].
 */
public suspend fun instance(name: String, block: suspend InstanceResourceBuilder.() -> Unit): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Instance].
 * @param name The _unique_ name of the resulting resource.
 */
public fun instance(name: String): Instance {
    val builder = InstanceResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy