Class CapacityTask


  • public class CapacityTask
    extends com.pulumi.resources.CustomResource
    Resource for managing an AWS Outposts Capacity Task. A capacity task redistributes the instance pools available on an Outpost rack or server to match the `instancePool` configuration declared in the resource. Starting a capacity task is a long-running, asynchronous operation — Terraform waits for it to reach a terminal state (`COMPLETED`, `CANCELLED`, or `FAILED`) before finishing the apply. Because every argument of this resource is marked as forces-new, any change to the configuration results in destroying and re-creating the capacity task. Tasks that are already in a terminal state (`COMPLETED` or `CANCELLED`) are left in place on destroy and only removed from Terraform state; tasks still in flight are cancelled and Terraform waits for them to reach `CANCELLED`. If a task reaches the terminal state `FAILED` during `delete`, the provider tolerates the "already in a terminal state" error returned by `CancelCapacityTask` and considers the resource successfully destroyed. If a create operation produces a `FAILED` task, the resource is not written to Terraform state (the `failureReason` is surfaced in the diagnostic instead), so no follow-up destroy is required. ## Example Usage ### Minimal
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.outposts.OutpostsFunctions;
     import com.pulumi.aws.outposts.inputs.GetOutpostsArgs;
     import com.pulumi.aws.outposts.CapacityTask;
     import com.pulumi.aws.outposts.CapacityTaskArgs;
     import com.pulumi.aws.outposts.inputs.CapacityTaskInstancePoolArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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 example = OutpostsFunctions.getOutposts(GetOutpostsArgs.builder()
                 .build());
     
             var exampleCapacityTask = new CapacityTask("exampleCapacityTask", CapacityTaskArgs.builder()
                 .instancePools(CapacityTaskInstancePoolArgs.builder()
                     .instanceType("m5.large")
                     .count(2)
                     .build())
                 .outpostIdentifier(example.arns()[0])
                 .build());
     
         }
     }
     
     
    ### Multiple instance pools, excluded instances, and a specified blocking-instance action
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.outposts.OutpostsFunctions;
     import com.pulumi.aws.outposts.inputs.GetAssetsArgs;
     import com.pulumi.aws.outposts.CapacityTask;
     import com.pulumi.aws.outposts.CapacityTaskArgs;
     import com.pulumi.aws.outposts.inputs.CapacityTaskInstancesToExcludeArgs;
     import com.pulumi.aws.outposts.inputs.CapacityTaskInstancePoolArgs;
     import com.pulumi.resources.CustomResourceOptions;
     import com.pulumi.resources.CustomTimeouts;
     import java.util.ArrayList;
     import java.util.Arrays;
     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 example = OutpostsFunctions.getAssets(GetAssetsArgs.builder()
                 .arn("arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef")
                 .build());
     
             var exampleCapacityTask = new CapacityTask("exampleCapacityTask", CapacityTaskArgs.builder()
                 .instancesToExclude(CapacityTaskInstancesToExcludeArgs.builder()
                     .instances(                
                         "i-0123456789abcdef0",
                         "i-0fedcba9876543210")
                     .build())
                 .instancePools(            
                     CapacityTaskInstancePoolArgs.builder()
                         .instanceType("m5.large")
                         .count(4)
                         .build(),
                     CapacityTaskInstancePoolArgs.builder()
                         .instanceType("c5.xlarge")
                         .count(2)
                         .build())
                 .outpostIdentifier("op-1234567890abcdef")
                 .taskActionOnBlockingInstances("WAIT_FOR_EVACUATION")
                 .assetId(example.assetIds()[0])
                 .build(), CustomResourceOptions.builder()
                     .customTimeouts(CustomTimeouts.builder()
                         .create(CustomTimeouts.parseTimeoutString("90m"))
                         .delete(CustomTimeouts.parseTimeoutString("15m"))
                     .build())
                     .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `outpostIdentifier` (String) Outpost identifier supplied when the task was created (ID or ARN). * `capacityTaskId` (String) AWS-assigned capacity task ID. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import a Capacity Task using the same composite ID. For example: ```sh $ pulumi import aws:outposts/capacityTask:CapacityTask example op-1234567890abcdef/cap-1a2b3c4d5e6f7g8h9 ```
    • 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.lang.String> assetId()  
      com.pulumi.core.Output<java.lang.String> capacityTaskId()  
      com.pulumi.core.Output<java.lang.String> completionDate()  
      com.pulumi.core.Output<java.lang.String> creationDate()  
      com.pulumi.core.Output<java.lang.String> failureReason()  
      static CapacityTask get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, CapacityTaskState 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.util.Optional<java.util.List<CapacityTaskInstancePool>>> instancePools()  
      com.pulumi.core.Output<java.util.Optional<CapacityTaskInstancesToExclude>> instancesToExclude()  
      com.pulumi.core.Output<java.lang.String> orderId()  
      com.pulumi.core.Output<java.lang.String> outpostIdentifier()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.String> status()  
      com.pulumi.core.Output<java.lang.String> taskActionOnBlockingInstances()  
      com.pulumi.core.Output<java.util.Optional<CapacityTaskTimeouts>> timeouts()  
      • 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

      • CapacityTask

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

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

        public CapacityTask​(java.lang.String name,
                            CapacityTaskArgs 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

      • assetId

        public com.pulumi.core.Output<java.lang.String> assetId()
        Returns:
        ID of a specific Outposts asset (hardware server) to target for the capacity task. If omitted, AWS selects an appropriate asset automatically. Discover valid asset IDs with the `aws.outposts.getAssets` data source. Changing this value forces a new resource.
      • capacityTaskId

        public com.pulumi.core.Output<java.lang.String> capacityTaskId()
        Returns:
        ID assigned by AWS to the capacity task (for example, `cap-1a2b3c4d5e6f7g8h9`).
      • completionDate

        public com.pulumi.core.Output<java.lang.String> completionDate()
        Returns:
        RFC 3339 timestamp at which the capacity task reached a terminal state (if any).
      • creationDate

        public com.pulumi.core.Output<java.lang.String> creationDate()
        Returns:
        RFC 3339 timestamp at which the capacity task was created.
      • failureReason

        public com.pulumi.core.Output<java.lang.String> failureReason()
        Returns:
        Human-readable reason reported by AWS when the capacity task failed. `null` unless the terminal state is `FAILED`.
      • instancePools

        public com.pulumi.core.Output<java.util.Optional<java.util.List<CapacityTaskInstancePool>>> instancePools()
        Returns:
        One or more `instancePool` blocks defining the desired instance-type layout for the Outpost. See below. At least one block is required. Changing any value forces a new resource.
      • instancesToExclude

        public com.pulumi.core.Output<java.util.Optional<CapacityTaskInstancesToExclude>> instancesToExclude()
        Returns:
        Single `instancesToExclude` block specifying user-owned running instances that must not be stopped to free up capacity. See below. Note: AWS does not return this value via the Get/Describe API; after import, you must add the block back to your configuration manually — see Import.
      • orderId

        public com.pulumi.core.Output<java.lang.String> orderId()
        Returns:
        ID of the Amazon Web Services Outposts order associated with the capacity task. Changing this value forces a new resource.
      • outpostIdentifier

        public com.pulumi.core.Output<java.lang.String> outpostIdentifier()
        Returns:
        ID or ARN of the Outpost on which to run the capacity task. Both forms are accepted; the provider normalizes the value internally. Changing this value forces a new resource.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • status

        public com.pulumi.core.Output<java.lang.String> status()
        Returns:
        Current status of the capacity task. One of `REQUESTED`, `IN_PROGRESS`, `WAITING_FOR_EVACUATION`, `CANCELLATION_IN_PROGRESS`, `COMPLETED`, `CANCELLED`, or `FAILED`. See the [AWS documentation](https://docs.aws.amazon.com/outposts/latest/APIReference/API_GetCapacityTask.html) for semantics.
      • taskActionOnBlockingInstances

        public com.pulumi.core.Output<java.lang.String> taskActionOnBlockingInstances()
        Returns:
        Action to take if running instances block the capacity task. Valid values are `WAIT_FOR_EVACUATION` and `FAIL_TASK`. Changing this value forces a new resource.
      • timeouts

        public com.pulumi.core.Output<java.util.Optional<CapacityTaskTimeouts>> timeouts()
        Returns:
        Configuration block with timeouts. See below.
      • get

        public static CapacityTask get​(java.lang.String name,
                                       com.pulumi.core.Output<java.lang.String> id,
                                       @Nullable
                                       CapacityTaskState 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.