Updating a cluster to use Amazon ECS Managed Instances
You can update an existing cluster to use Amazon ECS Managed Instances.
When you add Amazon ECS Managed Instances to your cluster, Amazon ECS automatically creates a managed instances capacity provider with default configurations. This capacity provider selects the most cost-optimized general-purpose instance types for your workloads. You can also create custom capacity providers if you need specific instance attributes or types.
Prerequisites
When you don't specify instanceRequirements, Amazon ECS automatically
selects the most cost-optimized instance types based on your task definition
requirements. To use specific instance attributes or types, create a capacity provider
with instanceRequirements.
You have the required IAM roles for Amazon ECS Managed Instances. This includes:
-
Infrastructure role - Allows Amazon ECS to make calls to AWS services on your behalf to manage Amazon ECS Managed Instances infrastructure.
For more information, see Amazon ECS infrastructure IAM role.
-
Instance profile - Provides permissions for the Amazon ECS container agent and Docker daemon running on managed instances.
For more information, see Amazon ECS Managed Instances instance profile.
Update considerations
When updating a cluster for Amazon ECS Managed Instances, consider the following:
-
Running tasks - Updating cluster settings does not affect currently running tasks. Changes will apply to new tasks launched after the update.
-
Capacity provider changes - If you modify capacity provider settings, existing managed instances will continue to run, but new instances will use the updated configuration.
-
Monitoring changes - Enabling or disabling Container Insights will affect metric collection for the entire cluster.
Console procedure
To update a cluster (Amazon ECS console)
Open the console at https://console.aws.amazon.com/ecs/v2
. -
From the navigation bar, select the Region to use.
-
In the navigation pane, choose Clusters.
-
On the Clusters page, select the cluster you want to update.
-
Choose Update cluster.
-
(Optional) To modify capacity provider settings, under Custom Capacity Provider, update the following as needed:
-
For Instance profile, choose a different instance profile role if needed.
-
For Infrastructure role, choose a different infrastructure role if needed.
-
To use a custom capacity provider, for Instance selection, update the Attribute value settings.
-
-
Choose Update.
AWS CLI procedure
You can update a cluster for Amazon ECS Managed Instances using the AWS CLI. Use the latest version of the AWS CLI. For more information on how to upgrade to the latest version, see Installing or updating to the latest version of the AWS CLI.
Note
You can use dual-stack service endpoints to interact with Amazon ECS from the AWS AWS CLI, SDKs, and the Amazon ECS API over both IPv4 and IPv6. For more information, see Using Amazon ECS dual-stack endpoints.
To update a cluster (AWS CLI)
-
Create a capacity provider for . Run the following command:
Replace the
user-inputwith your values.aws ecs create-capacity-provider \ --namemy-managed-instances-provider\ --managed-instances-provider \ --instance-profilearn:aws:iam::123456789012:instance-profile/ecsInstanceProfile\ --infrastructure-role-arnarn:aws:iam::123456789012:role/ecsInfrastructureRole\ --instance-requirements '{ "vCpuCount": {"min": 2, "max": 8}, "memoryMiB": {"min": 4096, "max": 16384} } -
Add the capacity provider to the cluster, use the following command:
Replace the
user-inputwith your values.aws ecs put-cluster-capacity-providers --clustermanaged-instances-cluster--capacity-providersmy-managed-instances-provider--default-capacity-provider-strategy capacityProvider=my-managed-instances-provider,weight=1