Class ClusterProps
The properties used to define an ECS cluster.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ClusterProps : Object, IClusterProps
Syntax (vb)
Public Class ClusterProps
Inherits Object
Implements IClusterProps
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
var cluster = new Cluster(this, "Cluster", new ClusterProps {
Vpc = vpc
});
var autoScalingGroup = new AutoScalingGroup(this, "ASG", new AutoScalingGroupProps {
Vpc = vpc,
InstanceType = new InstanceType("t2.micro"),
MachineImage = EcsOptimizedImage.AmazonLinux2(),
MinCapacity = 0,
MaxCapacity = 100
});
var capacityProvider = new AsgCapacityProvider(this, "AsgCapacityProvider", new AsgCapacityProviderProps {
AutoScalingGroup = autoScalingGroup,
InstanceWarmupPeriod = 300
});
cluster.AddAsgCapacityProvider(capacityProvider);
var taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryReservationMiB = 256
});
new Ec2Service(this, "EC2Service", new Ec2ServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = capacityProvider.CapacityProviderName,
Weight = 1
} }
});
Synopsis
Constructors
ClusterProps() |
Properties
Capacity | The ec2 capacity to add to the cluster. |
ClusterName | The name for the cluster. |
ContainerInsights | If true CloudWatch Container Insights will be enabled for the cluster. |
DefaultCloudMapNamespace | The service discovery namespace created in this cluster. |
EnableFargateCapacityProviders | Whether to enable Fargate Capacity Providers. |
ExecuteCommandConfiguration | The execute command configuration for the cluster. |
Vpc | The VPC where your ECS instances will be running or your ENIs will be deployed. |
Constructors
ClusterProps()
public ClusterProps()
Properties
Capacity
The ec2 capacity to add to the cluster.
public IAddCapacityOptions Capacity { get; set; }
Property Value
Remarks
Default: - no EC2 capacity will be added, you can use addCapacity
to add capacity later.
ClusterName
The name for the cluster.
public string ClusterName { get; set; }
Property Value
System.String
Remarks
Default: CloudFormation-generated name
ContainerInsights
If true CloudWatch Container Insights will be enabled for the cluster.
public Nullable<bool> ContainerInsights { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - Container Insights will be disabled for this cluster.
DefaultCloudMapNamespace
The service discovery namespace created in this cluster.
public ICloudMapNamespaceOptions DefaultCloudMapNamespace { get; set; }
Property Value
Remarks
Default: - no service discovery namespace created, you can use addDefaultCloudMapNamespace
to add a
default service discovery namespace later.
EnableFargateCapacityProviders
Whether to enable Fargate Capacity Providers.
public Nullable<bool> EnableFargateCapacityProviders { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
ExecuteCommandConfiguration
The execute command configuration for the cluster.
public IExecuteCommandConfiguration ExecuteCommandConfiguration { get; set; }
Property Value
Remarks
Default: - no configuration will be provided.
Vpc
The VPC where your ECS instances will be running or your ENIs will be deployed.
public IVpc Vpc { get; set; }
Property Value
Remarks
Default: - creates a new VPC with two AZs