Class InstanceState


  • public class InstanceState
    extends com.pulumi.resources.CustomResource
    Provides an EC2 instance state resource. This allows managing an instance power state. > **NOTE on Instance State Management:** AWS does not currently have an EC2 API operation to determine an instance has finished processing user data. As a result, this resource can interfere with user data processing. For example, this resource may stop an instance while the user data script is in mid run. ## Example Usage ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Ec2Functions; import com.pulumi.aws.ec2.inputs.GetAmiArgs; import com.pulumi.aws.ec2.Instance; import com.pulumi.aws.ec2.InstanceArgs; import com.pulumi.aws.ec2transitgateway.InstanceState; import com.pulumi.aws.ec2transitgateway.InstanceStateArgs; 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 ubuntu = Ec2Functions.getAmi(GetAmiArgs.builder() .mostRecent(true) .filters( GetAmiFilterArgs.builder() .name("name") .values("ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*") .build(), GetAmiFilterArgs.builder() .name("virtualization-type") .values("hvm") .build()) .owners("099720109477") .build()); var testInstance = new Instance("testInstance", InstanceArgs.builder() .ami(ubuntu.applyValue(getAmiResult -> getAmiResult.id())) .instanceType("t3.micro") .tags(Map.of("Name", "HelloWorld")) .build()); var testInstanceState = new InstanceState("testInstanceState", InstanceStateArgs.builder() .instanceId(testInstance.id()) .state("stopped") .build()); } } ``` ## Import Using `pulumi import`, import `aws_ec2_instance_state` using the `instance_id` attribute. For example: ```sh $ pulumi import aws:ec2transitgateway/instanceState:InstanceState test i-02cae6557dfcf2f96 ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> force()  
      static InstanceState get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, InstanceStateState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> instanceId()  
      com.pulumi.core.Output<java.lang.String> state()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstanceState

        public InstanceState​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • InstanceState

        public InstanceState​(java.lang.String name,
                             InstanceStateArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • InstanceState

        public InstanceState​(java.lang.String name,
                             InstanceStateArgs args,
                             @Nullable
                             com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • force

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> force()
        Returns:
        Whether to request a forced stop when `state` is `stopped`. Otherwise (_i.e._, `state` is `running`), ignored. When an instance is forced to stop, it does not flush file system caches or file system metadata, and you must subsequently perform file system check and repair. Not recommended for Windows instances. Defaults to `false`.
      • instanceId

        public com.pulumi.core.Output<java.lang.String> instanceId()
        Returns:
        ID of the instance.
      • state

        public com.pulumi.core.Output<java.lang.String> state()
        Returns:
        State of the instance. Valid values are `stopped`, `running`. The following arguments are optional:
      • get

        public static InstanceState get​(java.lang.String name,
                                        com.pulumi.core.Output<java.lang.String> id,
                                        @Nullable
                                        InstanceStateState state,
                                        @Nullable
                                        com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.