CapacityTask class
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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.outposts.getOutposts({});
const exampleCapacityTask = new aws.outposts.CapacityTask("example", {
instancePools: [{
instanceType: "m5.large",
count: 2,
}],
outpostIdentifier: example.then(example => example.arns?.[0]),
});
import pulumi
import pulumi_aws as aws
example = aws.outposts.get_outposts()
example_capacity_task = aws.outposts.CapacityTask("example",
instance_pools=[{
"instance_type": "m5.large",
"count": 2,
}],
outpost_identifier=example.arns[0])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Outposts.GetOutposts.Invoke();
var exampleCapacityTask = new Aws.Outposts.CapacityTask("example", new()
{
InstancePools = new[]
{
new Aws.Outposts.Inputs.CapacityTaskInstancePoolArgs
{
InstanceType = "m5.large",
Count = 2,
},
},
OutpostIdentifier = example.Apply(getOutpostsResult => getOutpostsResult.Arns[0]),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/outposts"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := outposts.GetOutposts(ctx, &outposts.GetOutpostsArgs{}, nil)
if err != nil {
return err
}
_, err = outposts.NewCapacityTask(ctx, "example", &outposts.CapacityTaskArgs{
InstancePools: outposts.CapacityTaskInstancePoolArray{
&outposts.CapacityTaskInstancePoolArgs{
InstanceType: pulumi.String("m5.large"),
Count: pulumi.Int(2),
},
},
OutpostIdentifier: pulumi.String(example.Arns[0]),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_outposts_getoutposts" "example" {
}
resource "aws_outposts_capacitytask" "example" {
instance_pools {
instance_type = "m5.large"
count = 2
}
outpost_identifier = data.aws_outposts_getoutposts.example.arns[0]
}
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());
}
}
resources:
exampleCapacityTask:
type: aws:outposts:CapacityTask
name: example
properties:
instancePools:
- instanceType: m5.large
count: 2
outpostIdentifier: ${example.arns[0]}
variables:
example:
fn::invoke:
function: aws:outposts:getOutposts
arguments: {}
Multiple instance pools, excluded instances, and a specified blocking-instance action
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.outposts.getAssets({
arn: "arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef",
});
const exampleCapacityTask = new aws.outposts.CapacityTask("example", {
instancesToExclude: {
instances: [
"i-0123456789abcdef0",
"i-0fedcba9876543210",
],
},
instancePools: [
{
instanceType: "m5.large",
count: 4,
},
{
instanceType: "c5.xlarge",
count: 2,
},
],
outpostIdentifier: "op-1234567890abcdef",
taskActionOnBlockingInstances: "WAIT_FOR_EVACUATION",
assetId: example.then(example => example.assetIds?.[0]),
}, {
customTimeouts: {
create: "90m",
"delete": "15m",
},
});
import pulumi
import pulumi_aws as aws
example = aws.outposts.get_assets(arn="arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef")
example_capacity_task = aws.outposts.CapacityTask("example",
instances_to_exclude={
"instances": [
"i-0123456789abcdef0",
"i-0fedcba9876543210",
],
},
instance_pools=[
{
"instance_type": "m5.large",
"count": 4,
},
{
"instance_type": "c5.xlarge",
"count": 2,
},
],
outpost_identifier="op-1234567890abcdef",
task_action_on_blocking_instances="WAIT_FOR_EVACUATION",
asset_id=example.asset_ids[0],
opts = pulumi.ResourceOptions(custom_timeouts=pulumi.CustomTimeouts(create="90m", delete="15m")))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Outposts.GetAssets.Invoke(new()
{
Arn = "arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef",
});
var exampleCapacityTask = new Aws.Outposts.CapacityTask("example", new()
{
InstancesToExclude = new Aws.Outposts.Inputs.CapacityTaskInstancesToExcludeArgs
{
Instances = new[]
{
"i-0123456789abcdef0",
"i-0fedcba9876543210",
},
},
InstancePools = new[]
{
new Aws.Outposts.Inputs.CapacityTaskInstancePoolArgs
{
InstanceType = "m5.large",
Count = 4,
},
new Aws.Outposts.Inputs.CapacityTaskInstancePoolArgs
{
InstanceType = "c5.xlarge",
Count = 2,
},
},
OutpostIdentifier = "op-1234567890abcdef",
TaskActionOnBlockingInstances = "WAIT_FOR_EVACUATION",
AssetId = example.Apply(getAssetsResult => getAssetsResult.AssetIds[0]),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/outposts"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := outposts.GetAssets(ctx, &outposts.GetAssetsArgs{
Arn: "arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef",
}, nil)
if err != nil {
return err
}
_, err = outposts.NewCapacityTask(ctx, "example", &outposts.CapacityTaskArgs{
InstancesToExclude: &outposts.CapacityTaskInstancesToExcludeArgs{
Instances: pulumi.StringArray{
pulumi.String("i-0123456789abcdef0"),
pulumi.String("i-0fedcba9876543210"),
},
},
InstancePools: outposts.CapacityTaskInstancePoolArray{
&outposts.CapacityTaskInstancePoolArgs{
InstanceType: pulumi.String("m5.large"),
Count: pulumi.Int(4),
},
&outposts.CapacityTaskInstancePoolArgs{
InstanceType: pulumi.String("c5.xlarge"),
Count: pulumi.Int(2),
},
},
OutpostIdentifier: pulumi.String("op-1234567890abcdef"),
TaskActionOnBlockingInstances: pulumi.String("WAIT_FOR_EVACUATION"),
AssetId: pulumi.String(example.AssetIds[0]),
}, pulumi.Timeouts(&pulumi.CustomTimeouts{Create: "90m", Delete: "15m"}))
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_outposts_getassets" "example" {
arn = "arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef"
}
resource "aws_outposts_capacitytask" "example" {
timeouts {
create = "90m"
delete = "15m"
}
instances_to_exclude = {
instances = ["i-0123456789abcdef0", "i-0fedcba9876543210"]
}
instance_pools {
instance_type = "m5.large"
count = 4
}
instance_pools {
instance_type = "c5.xlarge"
count = 2
}
outpost_identifier = "op-1234567890abcdef"
task_action_on_blocking_instances = "WAIT_FOR_EVACUATION"
asset_id = data.aws_outposts_getassets.example.asset_ids[0]
}
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());
}
}
resources:
exampleCapacityTask:
type: aws:outposts:CapacityTask
name: example
properties:
instancesToExclude:
instances:
- i-0123456789abcdef0
- i-0fedcba9876543210
instancePools:
- instanceType: m5.large
count: 4
- instanceType: c5.xlarge
count: 2
outpostIdentifier: op-1234567890abcdef
taskActionOnBlockingInstances: WAIT_FOR_EVACUATION
assetId: ${example.assetIds[0]}
options:
customTimeouts:
create: 90m
delete: 15m
variables:
example:
fn::invoke:
function: aws:outposts:getAssets
arguments:
arn: arn:aws:outposts:us-west-2:123456789012:outpost/op-1234567890abcdef
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:
$ pulumi import aws:outposts/capacityTask:CapacityTask example op-1234567890abcdef/cap-1a2b3c4d5e6f7g8h9
Constructors
- CapacityTask(String name, {CapacityTaskArgs? args, CustomResourceOptions? options})
-
Creates a new CapacityTask.
nameThe Pulumi resource name.argsArguments used to configure this CapacityTask. The set of arguments for CapacityTask.optionsResource options controlling this resource's behavior. - CapacityTask.reference(String urn)
- Creates a typed reference to an existing CapacityTask resource.
Properties
-
assetId
↔ Output<
String> -
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.getAssetsdata source. Changing this value forces a new resource.latefinal -
capacityTaskId
↔ Output<
String> -
ID assigned by AWS to the capacity task (for example,
cap-1a2b3c4d5e6f7g8h9).latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionDate
↔ Output<
String> -
RFC 3339 timestamp at which the capacity task reached a terminal state (if any).
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
creationDate
↔ Output<
String> -
RFC 3339 timestamp at which the capacity task was created.
latefinal
-
failureReason
↔ Output<
String> -
Human-readable reason reported by AWS when the capacity task failed.
nullunless the terminal state isFAILED.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
instancePools
↔ Output<
List< CapacityTaskInstancePool> ?> -
One or more
instancePoolblocks defining the desired instance-type layout for the Outpost. See below. At least one block is required. Changing any value forces a new resource.latefinal -
instancesToExclude
↔ Output<
CapacityTaskInstancesToExclude?> -
Single
instancesToExcludeblock 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.latefinal - isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
orderId
↔ Output<
String> -
ID of the Amazon Web Services Outposts order associated with the capacity task. Changing this value forces a new resource.
latefinal
-
outpostIdentifier
↔ Output<
String> -
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.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
status
↔ Output<
String> -
Current status of the capacity task. One of
REQUESTED,IN_PROGRESS,WAITING_FOR_EVACUATION,CANCELLATION_IN_PROGRESS,COMPLETED,CANCELLED, orFAILED. See the AWS documentation for semantics.latefinal -
taskActionOnBlockingInstances
↔ Output<
String> -
Action to take if running instances block the capacity task. Valid values are
WAIT_FOR_EVACUATIONandFAIL_TASK. Changing this value forces a new resource.latefinal -
timeouts
↔ Output<
CapacityTaskTimeouts?> -
Configuration block with timeouts. See below.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {CapacityTaskState? state, CustomResourceOptions? options}) → CapacityTask -
Gets an existing CapacityTask resource's state with the given
nameandid.