- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
PutClusterCapacityProvidersCommand
Modifies the available capacity providers and the default capacity provider strategy for a cluster.
You must specify both the available capacity providers and a default capacity provider strategy for the cluster. If the specified cluster has existing capacity providers associated with it, you must specify all existing capacity providers in addition to any new ones you want to add. Any existing capacity providers that are associated with a cluster that are omitted from a PutClusterCapacityProviders API call will be disassociated with the cluster. You can only disassociate an existing capacity provider from a cluster if it's not being used by any existing tasks.
When creating a service or running a task on a cluster, if no capacity provider or launch type is specified, then the cluster's default capacity provider strategy is used. We recommend that you define a default capacity provider strategy for your cluster. However, you must specify an empty array ([]
) to bypass defining a default strategy.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ECSClient, PutClusterCapacityProvidersCommand } from "@aws-sdk/client-ecs"; // ES Modules import
// const { ECSClient, PutClusterCapacityProvidersCommand } = require("@aws-sdk/client-ecs"); // CommonJS import
const client = new ECSClient(config);
const input = { // PutClusterCapacityProvidersRequest
cluster: "STRING_VALUE", // required
capacityProviders: [ // StringList // required
"STRING_VALUE",
],
defaultCapacityProviderStrategy: [ // CapacityProviderStrategy // required
{ // CapacityProviderStrategyItem
capacityProvider: "STRING_VALUE", // required
weight: Number("int"),
base: Number("int"),
},
],
};
const command = new PutClusterCapacityProvidersCommand(input);
const response = await client.send(command);
// { // PutClusterCapacityProvidersResponse
// cluster: { // Cluster
// clusterArn: "STRING_VALUE",
// clusterName: "STRING_VALUE",
// configuration: { // ClusterConfiguration
// executeCommandConfiguration: { // ExecuteCommandConfiguration
// kmsKeyId: "STRING_VALUE",
// logging: "NONE" || "DEFAULT" || "OVERRIDE",
// logConfiguration: { // ExecuteCommandLogConfiguration
// cloudWatchLogGroupName: "STRING_VALUE",
// cloudWatchEncryptionEnabled: true || false,
// s3BucketName: "STRING_VALUE",
// s3EncryptionEnabled: true || false,
// s3KeyPrefix: "STRING_VALUE",
// },
// },
// managedStorageConfiguration: { // ManagedStorageConfiguration
// kmsKeyId: "STRING_VALUE",
// fargateEphemeralStorageKmsKeyId: "STRING_VALUE",
// },
// },
// status: "STRING_VALUE",
// registeredContainerInstancesCount: Number("int"),
// runningTasksCount: Number("int"),
// pendingTasksCount: Number("int"),
// activeServicesCount: Number("int"),
// statistics: [ // Statistics
// { // KeyValuePair
// name: "STRING_VALUE",
// value: "STRING_VALUE",
// },
// ],
// tags: [ // Tags
// { // Tag
// key: "STRING_VALUE",
// value: "STRING_VALUE",
// },
// ],
// settings: [ // ClusterSettings
// { // ClusterSetting
// name: "containerInsights",
// value: "STRING_VALUE",
// },
// ],
// capacityProviders: [ // StringList
// "STRING_VALUE",
// ],
// defaultCapacityProviderStrategy: [ // CapacityProviderStrategy
// { // CapacityProviderStrategyItem
// capacityProvider: "STRING_VALUE", // required
// weight: Number("int"),
// base: Number("int"),
// },
// ],
// attachments: [ // Attachments
// { // Attachment
// id: "STRING_VALUE",
// type: "STRING_VALUE",
// status: "STRING_VALUE",
// details: [ // AttachmentDetails
// {
// name: "STRING_VALUE",
// value: "STRING_VALUE",
// },
// ],
// },
// ],
// attachmentsStatus: "STRING_VALUE",
// serviceConnectDefaults: { // ClusterServiceConnectDefaults
// namespace: "STRING_VALUE",
// },
// },
// };
Example Usage
PutClusterCapacityProvidersCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
capacityProviders Required | string[] | undefined | The name of one or more capacity providers to associate with the cluster. If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the CreateCapacityProvider API operation. To use a Fargate capacity provider, specify either the |
cluster Required | string | undefined | The short name or full Amazon Resource Name (ARN) of the cluster to modify the capacity provider settings for. If you don't specify a cluster, the default cluster is assumed. |
defaultCapacityProviderStrategy Required | CapacityProviderStrategyItem[] | undefined | The capacity provider strategy to use by default for the cluster. When creating a service or running a task on a cluster, if no capacity provider or launch type is specified then the default capacity provider strategy for the cluster is used. A capacity provider strategy consists of one or more capacity providers along with the If specifying a capacity provider that uses an Auto Scaling group, the capacity provider must already be created. New capacity providers can be created with the CreateCapacityProvider API operation. To use a Fargate capacity provider, specify either the |
PutClusterCapacityProvidersCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
cluster | Cluster | undefined | Details about the cluster. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
ClientException | client | These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid. The following list includes additional causes for the error:
|
ClusterNotFoundException | client | The specified cluster wasn't found. You can view your available clusters with ListClusters . Amazon ECS clusters are Region specific. |
InvalidParameterException | client | The specified parameter isn't valid. Review the available parameters for the API request. |
ResourceInUseException | client | The specified resource is in-use and can't be removed. |
ServerException | server | These errors are usually caused by a server issue. |
UpdateInProgressException | client | There's already a current Amazon ECS container agent update in progress on the container instance that's specified. If the container agent becomes disconnected while it's in a transitional stage, such as |
ECSServiceException | Base exception class for all service exceptions from ECS service. |