Skip to content
GitHubXDiscordRSS

Cluster

Learn how to create, update, and manage AWS ECS Clusters using Alchemy Cloud Control.

The Cluster resource lets you manage AWS ECS Clusters which provide the infrastructure for running containerized applications.

Create a basic ECS cluster with a specified name.

import AWS from "alchemy/aws/control";
const myCluster = await AWS.ECS.Cluster("myEcsCluster", {
clusterName: "MyEcsCluster",
capacityProviders: ["FARGATE"],
tags: [
{
key: "Environment",
value: "Production"
}
]
});

Configure an ECS cluster with custom settings, default capacity provider strategy, and service connect defaults.

const advancedCluster = await AWS.ECS.Cluster("advancedEcsCluster", {
clusterName: "AdvancedEcsCluster",
clusterSettings: [
{
name: "containerInsights",
value: "enabled"
}
],
defaultCapacityProviderStrategy: [
{
capacityProvider: "FARGATE",
weight: 1,
base: 1
}
],
serviceConnectDefaults: {
namespace: "my-service-connect-namespace"
}
});

Custom Configuration for Capacity Providers

Section titled “Custom Configuration for Capacity Providers”

Create a cluster with multiple capacity providers to manage different scaling strategies.

const customCapacityCluster = await AWS.ECS.Cluster("customCapacityCluster", {
clusterName: "CustomCapacityCluster",
capacityProviders: ["FARGATE", "FARGATE_SPOT"],
tags: [
{
key: "Team",
value: "Engineering"
}
]
});

Set up a cluster with specific configuration settings for container insights and additional settings.

const configuredCluster = await AWS.ECS.Cluster("configuredEcsCluster", {
clusterName: "ConfiguredEcsCluster",
configuration: {
executeCommandConfiguration: {
kmsKeyId: "arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef",
logConfiguration: {
cloudWatchLogGroupName: "my-log-group",
cloudWatchEncryptionEnabled: true,
s3BucketName: "my-log-bucket"
}
}
},
tags: [
{
key: "Project",
value: "Migration"
}
]
});

Create a cluster that adopts an existing ECS cluster if it already exists.

const adoptCluster = await AWS.ECS.Cluster("existingEcsCluster", {
clusterName: "ExistingEcsCluster",
adopt: true,
tags: [
{
key: "Status",
value: "Adopted"
}
]
});