Skip to content
v2.274.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 ​

capacityoptionalAddCapacityOptionscapacityoptionalAddCapacityOptionscapacityoptionalAddCapacityOptionsCapacityoptionalAddCapacityOptionsCapacityoptionalAddCapacityOptions#
The ec2 capacity to add to the cluster.

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

clusterNameoptionalstringcluster_nameoptionalstrclusterNameoptionalStringClusterNameoptionalstringClusterNameoptional*string#
The name for the cluster.

Default: CloudFormation-generated name

containerInsightsoptionalbooleancontainer_insightsoptionalboolcontainerInsightsoptionalBooleanContainerInsightsoptionalboolContainerInsightsoptional*booldeprecated#
See {@link containerInsightsV2 }

Default: Container Insights will be disabled for this cluster.

containerInsightsV2optionalContainerInsightscontainer_insights_v2optionalContainerInsightscontainerInsightsV2optionalContainerInsightsContainerInsightsV2optionalContainerInsightsContainerInsightsV2optionalContainerInsights#
The CloudWatch Container Insights configuration for the cluster.

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

defaultCloudMapNamespaceoptionalCloudMapNamespaceOptionsdefault_cloud_map_namespaceoptionalCloudMapNamespaceOptionsdefaultCloudMapNamespaceoptionalCloudMapNamespaceOptionsDefaultCloudMapNamespaceoptionalCloudMapNamespaceOptionsDefaultCloudMapNamespaceoptionalCloudMapNamespaceOptions#
The service discovery namespace created in this cluster.

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

enableFargateCapacityProvidersoptionalbooleanenable_fargate_capacity_providersoptionalboolenableFargateCapacityProvidersoptionalBooleanEnableFargateCapacityProvidersoptionalboolEnableFargateCapacityProvidersoptional*bool= false#
Whether to enable Fargate Capacity Providers.
executeCommandConfigurationoptionalExecuteCommandConfigurationexecute_command_configurationoptionalExecuteCommandConfigurationexecuteCommandConfigurationoptionalExecuteCommandConfigurationExecuteCommandConfigurationoptionalExecuteCommandConfigurationExecuteCommandConfigurationoptionalExecuteCommandConfiguration#
The execute command configuration for the cluster.

Default: no configuration will be provided.

managedStorageConfigurationoptionalManagedStorageConfigurationmanaged_storage_configurationoptionalManagedStorageConfigurationmanagedStorageConfigurationoptionalManagedStorageConfigurationManagedStorageConfigurationoptionalManagedStorageConfigurationManagedStorageConfigurationoptionalManagedStorageConfiguration#
Encryption configuration for ECS Managed storage.

Default: no encryption will be applied.

vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc#
The VPC where your ECS instances will be running or your ENIs will be deployed.

Default: creates a new VPC with two AZs