Skip to content
v2.273.0

ClusterProps Struct ​

The properties used to define an ECS cluster.

Example ​

ts
declare const vpc: ec2.Vpc;

const cluster = new ecs.Cluster(this, 'Cluster', {
  vpc,
});

const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
  vpc,
  instanceType: new ec2.InstanceType('t2.micro'),
  machineImage: ecs.EcsOptimizedImage.amazonLinux2(),
  minCapacity: 0,
  maxCapacity: 100,
});

const capacityProvider = new ecs.AsgCapacityProvider(this, 'AsgCapacityProvider', {
  autoScalingGroup,
  instanceWarmupPeriod: 300,
});
cluster.addAsgCapacityProvider(capacityProvider);

const taskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef');

taskDefinition.addContainer('web', {
  image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
  memoryReservationMiB: 256,
});

new ecs.Ec2Service(this, 'EC2Service', {
  cluster,
  taskDefinition,
  minHealthyPercent: 100,
  capacityProviderStrategies: [
    {
      capacityProvider: capacityProvider.capacityProviderName,
      weight: 1,
    },
  ],
});

Properties ​

capacityAddCapacityOptionscapacityAddCapacityOptionscapacityAddCapacityOptionsCapacityAddCapacityOptionsCapacityAddCapacityOptions= no EC2 capacity will be added, y…#
The ec2 capacity to add to the cluster.
default

Default: no EC2 capacity will be added, you can use addCapacity to add capacity later.

clusterNamestringcluster_namestrclusterNameStringClusterNamestringClusterName*string= CloudFormation-generated name#
The name for the cluster.
containerInsightsbooleancontainer_insightsboolcontainerInsightsBooleanContainerInsightsboolContainerInsights*bool= Container Insights will be disab…deprecated#
See {@link containerInsightsV2 }
default

Default: Container Insights will be disabled for this cluster.

containerInsightsV2ContainerInsightscontainer_insights_v2ContainerInsightscontainerInsightsV2ContainerInsightsContainerInsightsV2ContainerInsightsContainerInsightsV2ContainerInsights= {@link ContainerInsights.DISABLE…#
The CloudWatch Container Insights configuration for the cluster.
default

Default: {@link ContainerInsights.DISABLED } This may be overridden by ECS account level settings.

defaultCloudMapNamespaceCloudMapNamespaceOptionsdefault_cloud_map_namespaceCloudMapNamespaceOptionsdefaultCloudMapNamespaceCloudMapNamespaceOptionsDefaultCloudMapNamespaceCloudMapNamespaceOptionsDefaultCloudMapNamespaceCloudMapNamespaceOptions= no service discovery namespace c…#
The service discovery namespace created in this cluster.
default

Default: no service discovery namespace created, you can use addDefaultCloudMapNamespace to add a default service discovery namespace later.

enableFargateCapacityProvidersbooleanenable_fargate_capacity_providersboolenableFargateCapacityProvidersBooleanEnableFargateCapacityProvidersboolEnableFargateCapacityProviders*bool= false#
Whether to enable Fargate Capacity Providers.
executeCommandConfigurationExecuteCommandConfigurationexecute_command_configurationExecuteCommandConfigurationexecuteCommandConfigurationExecuteCommandConfigurationExecuteCommandConfigurationExecuteCommandConfigurationExecuteCommandConfigurationExecuteCommandConfiguration= no configuration will be provide…#
The execute command configuration for the cluster.
default

Default: no configuration will be provided.

managedStorageConfigurationManagedStorageConfigurationmanaged_storage_configurationManagedStorageConfigurationmanagedStorageConfigurationManagedStorageConfigurationManagedStorageConfigurationManagedStorageConfigurationManagedStorageConfigurationManagedStorageConfiguration= no encryption will be applied.#
Encryption configuration for ECS Managed storage.
vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpc= creates a new VPC with two AZs#
The VPC where your ECS instances will be running or your ENIs will be deployed.

Used as props by ​