1. Packages
  2. Volcengine
  3. API Docs
  4. ecs
  5. State
Volcengine v0.0.26 published on Friday, Sep 13, 2024 by Volcengine

volcengine.ecs.State

Explore with Pulumi AI

volcengine logo
Volcengine v0.0.26 published on Friday, Sep 13, 2024 by Volcengine

    Provides a resource to manage ecs instance state

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Volcengine = Pulumi.Volcengine;
    
    return await Deployment.RunAsync(() => 
    {
        var fooZones = Volcengine.Ecs.Zones.Invoke();
    
        var fooVpc = new Volcengine.Vpc.Vpc("fooVpc", new()
        {
            VpcName = "acc-test-vpc",
            CidrBlock = "172.16.0.0/16",
        });
    
        var fooSubnet = new Volcengine.Vpc.Subnet("fooSubnet", new()
        {
            SubnetName = "acc-test-subnet",
            CidrBlock = "172.16.0.0/24",
            ZoneId = fooZones.Apply(zonesResult => zonesResult.Zones[0]?.Id),
            VpcId = fooVpc.Id,
        });
    
        var fooSecurityGroup = new Volcengine.Vpc.SecurityGroup("fooSecurityGroup", new()
        {
            SecurityGroupName = "acc-test-security-group",
            VpcId = fooVpc.Id,
        });
    
        var fooImages = Volcengine.Ecs.Images.Invoke(new()
        {
            OsType = "Linux",
            Visibility = "public",
            InstanceTypeId = "ecs.g1.large",
        });
    
        var fooInstance = new Volcengine.Ecs.Instance("fooInstance", new()
        {
            InstanceName = "acc-test-ecs",
            ImageId = fooImages.Apply(imagesResult => imagesResult.Images[0]?.ImageId),
            InstanceType = "ecs.g1.large",
            Password = "93f0cb0614Aab12",
            InstanceChargeType = "PostPaid",
            SystemVolumeType = "ESSD_PL0",
            SystemVolumeSize = 40,
            SubnetId = fooSubnet.Id,
            SecurityGroupIds = new[]
            {
                fooSecurityGroup.Id,
            },
        });
    
        var fooState = new Volcengine.Ecs.State("fooState", new()
        {
            InstanceId = fooInstance.Id,
            Action = "Stop",
            StoppedMode = "KeepCharging",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/ecs"
    	"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/vpc"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		fooZones, err := ecs.Zones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		fooVpc, err := vpc.NewVpc(ctx, "fooVpc", &vpc.VpcArgs{
    			VpcName:   pulumi.String("acc-test-vpc"),
    			CidrBlock: pulumi.String("172.16.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		fooSubnet, err := vpc.NewSubnet(ctx, "fooSubnet", &vpc.SubnetArgs{
    			SubnetName: pulumi.String("acc-test-subnet"),
    			CidrBlock:  pulumi.String("172.16.0.0/24"),
    			ZoneId:     *pulumi.String(fooZones.Zones[0].Id),
    			VpcId:      fooVpc.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		fooSecurityGroup, err := vpc.NewSecurityGroup(ctx, "fooSecurityGroup", &vpc.SecurityGroupArgs{
    			SecurityGroupName: pulumi.String("acc-test-security-group"),
    			VpcId:             fooVpc.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		fooImages, err := ecs.Images(ctx, &ecs.ImagesArgs{
    			OsType:         pulumi.StringRef("Linux"),
    			Visibility:     pulumi.StringRef("public"),
    			InstanceTypeId: pulumi.StringRef("ecs.g1.large"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		fooInstance, err := ecs.NewInstance(ctx, "fooInstance", &ecs.InstanceArgs{
    			InstanceName:       pulumi.String("acc-test-ecs"),
    			ImageId:            *pulumi.String(fooImages.Images[0].ImageId),
    			InstanceType:       pulumi.String("ecs.g1.large"),
    			Password:           pulumi.String("93f0cb0614Aab12"),
    			InstanceChargeType: pulumi.String("PostPaid"),
    			SystemVolumeType:   pulumi.String("ESSD_PL0"),
    			SystemVolumeSize:   pulumi.Int(40),
    			SubnetId:           fooSubnet.ID(),
    			SecurityGroupIds: pulumi.StringArray{
    				fooSecurityGroup.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ecs.NewState(ctx, "fooState", &ecs.StateArgs{
    			InstanceId:  fooInstance.ID(),
    			Action:      pulumi.String("Stop"),
    			StoppedMode: pulumi.String("KeepCharging"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.volcengine.ecs.EcsFunctions;
    import com.pulumi.volcengine.ecs.inputs.ZonesArgs;
    import com.pulumi.volcengine.vpc.Vpc;
    import com.pulumi.volcengine.vpc.VpcArgs;
    import com.pulumi.volcengine.vpc.Subnet;
    import com.pulumi.volcengine.vpc.SubnetArgs;
    import com.pulumi.volcengine.vpc.SecurityGroup;
    import com.pulumi.volcengine.vpc.SecurityGroupArgs;
    import com.pulumi.volcengine.ecs.inputs.ImagesArgs;
    import com.pulumi.volcengine.ecs.Instance;
    import com.pulumi.volcengine.ecs.InstanceArgs;
    import com.pulumi.volcengine.ecs.State;
    import com.pulumi.volcengine.ecs.StateArgs;
    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 fooZones = EcsFunctions.Zones();
    
            var fooVpc = new Vpc("fooVpc", VpcArgs.builder()        
                .vpcName("acc-test-vpc")
                .cidrBlock("172.16.0.0/16")
                .build());
    
            var fooSubnet = new Subnet("fooSubnet", SubnetArgs.builder()        
                .subnetName("acc-test-subnet")
                .cidrBlock("172.16.0.0/24")
                .zoneId(fooZones.applyValue(zonesResult -> zonesResult.zones()[0].id()))
                .vpcId(fooVpc.id())
                .build());
    
            var fooSecurityGroup = new SecurityGroup("fooSecurityGroup", SecurityGroupArgs.builder()        
                .securityGroupName("acc-test-security-group")
                .vpcId(fooVpc.id())
                .build());
    
            final var fooImages = EcsFunctions.Images(ImagesArgs.builder()
                .osType("Linux")
                .visibility("public")
                .instanceTypeId("ecs.g1.large")
                .build());
    
            var fooInstance = new Instance("fooInstance", InstanceArgs.builder()        
                .instanceName("acc-test-ecs")
                .imageId(fooImages.applyValue(imagesResult -> imagesResult.images()[0].imageId()))
                .instanceType("ecs.g1.large")
                .password("93f0cb0614Aab12")
                .instanceChargeType("PostPaid")
                .systemVolumeType("ESSD_PL0")
                .systemVolumeSize(40)
                .subnetId(fooSubnet.id())
                .securityGroupIds(fooSecurityGroup.id())
                .build());
    
            var fooState = new State("fooState", StateArgs.builder()        
                .instanceId(fooInstance.id())
                .action("Stop")
                .stoppedMode("KeepCharging")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_volcengine as volcengine
    
    foo_zones = volcengine.ecs.zones()
    foo_vpc = volcengine.vpc.Vpc("fooVpc",
        vpc_name="acc-test-vpc",
        cidr_block="172.16.0.0/16")
    foo_subnet = volcengine.vpc.Subnet("fooSubnet",
        subnet_name="acc-test-subnet",
        cidr_block="172.16.0.0/24",
        zone_id=foo_zones.zones[0].id,
        vpc_id=foo_vpc.id)
    foo_security_group = volcengine.vpc.SecurityGroup("fooSecurityGroup",
        security_group_name="acc-test-security-group",
        vpc_id=foo_vpc.id)
    foo_images = volcengine.ecs.images(os_type="Linux",
        visibility="public",
        instance_type_id="ecs.g1.large")
    foo_instance = volcengine.ecs.Instance("fooInstance",
        instance_name="acc-test-ecs",
        image_id=foo_images.images[0].image_id,
        instance_type="ecs.g1.large",
        password="93f0cb0614Aab12",
        instance_charge_type="PostPaid",
        system_volume_type="ESSD_PL0",
        system_volume_size=40,
        subnet_id=foo_subnet.id,
        security_group_ids=[foo_security_group.id])
    foo_state = volcengine.ecs.State("fooState",
        instance_id=foo_instance.id,
        action="Stop",
        stopped_mode="KeepCharging")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as volcengine from "@pulumi/volcengine";
    import * as volcengine from "@volcengine/pulumi";
    
    const fooZones = volcengine.ecs.Zones({});
    const fooVpc = new volcengine.vpc.Vpc("fooVpc", {
        vpcName: "acc-test-vpc",
        cidrBlock: "172.16.0.0/16",
    });
    const fooSubnet = new volcengine.vpc.Subnet("fooSubnet", {
        subnetName: "acc-test-subnet",
        cidrBlock: "172.16.0.0/24",
        zoneId: fooZones.then(fooZones => fooZones.zones?.[0]?.id),
        vpcId: fooVpc.id,
    });
    const fooSecurityGroup = new volcengine.vpc.SecurityGroup("fooSecurityGroup", {
        securityGroupName: "acc-test-security-group",
        vpcId: fooVpc.id,
    });
    const fooImages = volcengine.ecs.Images({
        osType: "Linux",
        visibility: "public",
        instanceTypeId: "ecs.g1.large",
    });
    const fooInstance = new volcengine.ecs.Instance("fooInstance", {
        instanceName: "acc-test-ecs",
        imageId: fooImages.then(fooImages => fooImages.images?.[0]?.imageId),
        instanceType: "ecs.g1.large",
        password: "93f0cb0614Aab12",
        instanceChargeType: "PostPaid",
        systemVolumeType: "ESSD_PL0",
        systemVolumeSize: 40,
        subnetId: fooSubnet.id,
        securityGroupIds: [fooSecurityGroup.id],
    });
    const fooState = new volcengine.ecs.State("fooState", {
        instanceId: fooInstance.id,
        action: "Stop",
        stoppedMode: "KeepCharging",
    });
    
    resources:
      fooVpc:
        type: volcengine:vpc:Vpc
        properties:
          vpcName: acc-test-vpc
          cidrBlock: 172.16.0.0/16
      fooSubnet:
        type: volcengine:vpc:Subnet
        properties:
          subnetName: acc-test-subnet
          cidrBlock: 172.16.0.0/24
          zoneId: ${fooZones.zones[0].id}
          vpcId: ${fooVpc.id}
      fooSecurityGroup:
        type: volcengine:vpc:SecurityGroup
        properties:
          securityGroupName: acc-test-security-group
          vpcId: ${fooVpc.id}
      fooInstance:
        type: volcengine:ecs:Instance
        properties:
          instanceName: acc-test-ecs
          imageId: ${fooImages.images[0].imageId}
          instanceType: ecs.g1.large
          password: 93f0cb0614Aab12
          instanceChargeType: PostPaid
          systemVolumeType: ESSD_PL0
          systemVolumeSize: 40
          subnetId: ${fooSubnet.id}
          securityGroupIds:
            - ${fooSecurityGroup.id}
      fooState:
        type: volcengine:ecs:State
        properties:
          instanceId: ${fooInstance.id}
          action: Stop
          stoppedMode: KeepCharging
    variables:
      fooZones:
        fn::invoke:
          Function: volcengine:ecs:Zones
          Arguments: {}
      fooImages:
        fn::invoke:
          Function: volcengine:ecs:Images
          Arguments:
            osType: Linux
            visibility: public
            instanceTypeId: ecs.g1.large
    

    Create State Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new State(name: string, args: StateArgs, opts?: CustomResourceOptions);
    @overload
    def State(resource_name: str,
              args: StateArgs,
              opts: Optional[ResourceOptions] = None)
    
    @overload
    def State(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              action: Optional[str] = None,
              instance_id: Optional[str] = None,
              stopped_mode: Optional[str] = None)
    func NewState(ctx *Context, name string, args StateArgs, opts ...ResourceOption) (*State, error)
    public State(string name, StateArgs args, CustomResourceOptions? opts = null)
    public State(String name, StateArgs args)
    public State(String name, StateArgs args, CustomResourceOptions options)
    
    type: volcengine:ecs:State
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args StateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args StateArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args StateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args StateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args StateArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var volcengineStateResource = new Volcengine.Ecs.State("volcengineStateResource", new()
    {
        Action = "string",
        InstanceId = "string",
        StoppedMode = "string",
    });
    
    example, err := ecs.NewState(ctx, "volcengineStateResource", &ecs.StateArgs{
    	Action:      pulumi.String("string"),
    	InstanceId:  pulumi.String("string"),
    	StoppedMode: pulumi.String("string"),
    })
    
    var volcengineStateResource = new State("volcengineStateResource", StateArgs.builder()
        .action("string")
        .instanceId("string")
        .stoppedMode("string")
        .build());
    
    volcengine_state_resource = volcengine.ecs.State("volcengineStateResource",
        action="string",
        instance_id="string",
        stopped_mode="string")
    
    const volcengineStateResource = new volcengine.ecs.State("volcengineStateResource", {
        action: "string",
        instanceId: "string",
        stoppedMode: "string",
    });
    
    type: volcengine:ecs:State
    properties:
        action: string
        instanceId: string
        stoppedMode: string
    

    State Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The State resource accepts the following input properties:

    Action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    InstanceId string
    Id of Instance.
    StoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    Action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    InstanceId string
    Id of Instance.
    StoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action String
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId String
    Id of Instance.
    stoppedMode String
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId string
    Id of Instance.
    stoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action str
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instance_id str
    Id of Instance.
    stopped_mode str
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action String
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId String
    Id of Instance.
    stoppedMode String
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the State resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of Instance.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of Instance.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of Instance.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    Status of Instance.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    Status of Instance.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of Instance.

    Look up Existing State Resource

    Get an existing State resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: StateState, opts?: CustomResourceOptions): State
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            action: Optional[str] = None,
            instance_id: Optional[str] = None,
            status: Optional[str] = None,
            stopped_mode: Optional[str] = None) -> State
    func GetState(ctx *Context, name string, id IDInput, state *StateState, opts ...ResourceOption) (*State, error)
    public static State Get(string name, Input<string> id, StateState? state, CustomResourceOptions? opts = null)
    public static State get(String name, Output<String> id, StateState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    InstanceId string
    Id of Instance.
    Status string
    Status of Instance.
    StoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    Action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    InstanceId string
    Id of Instance.
    Status string
    Status of Instance.
    StoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action String
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId String
    Id of Instance.
    status String
    Status of Instance.
    stoppedMode String
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action string
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId string
    Id of Instance.
    status string
    Status of Instance.
    stoppedMode string
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action str
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instance_id str
    Id of Instance.
    status str
    Status of Instance.
    stopped_mode str
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.
    action String
    Start or Stop of Instance Action, the value can be Start, Stop or ForceStop. If the target status of the action is consistent with the current status of the instance, the action will not actually be executed.
    instanceId String
    Id of Instance.
    status String
    Status of Instance.
    stoppedMode String
    Stop Mode of Instance, the value can be KeepCharging or StopCharging.

    Import

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

     $ pulumi import volcengine:ecs/state:State default state:i-mizl7m1kqccg5smt1bdpijuj
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    volcengine volcengine/pulumi-volcengine
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the volcengine Terraform Provider.
    volcengine logo
    Volcengine v0.0.26 published on Friday, Sep 13, 2024 by Volcengine