Class ManagedInstancesCapacityProvider
A Managed Instances Capacity Provider.
Implements
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ManagedInstancesCapacityProvider : Construct, IConnectable
Syntax (vb)
Public Class ManagedInstancesCapacityProvider Inherits Construct Implements IConnectable
Remarks
This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.
ExampleMetadata: infused
Examples
Vpc vpc;
Role infrastructureRole;
InstanceProfile instanceProfile;
var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc });
// Create a Managed Instances Capacity Provider
var miCapacityProvider = new ManagedInstancesCapacityProvider(this, "MICapacityProvider", new ManagedInstancesCapacityProviderProps {
InfrastructureRole = infrastructureRole,
Ec2InstanceProfile = instanceProfile,
Subnets = vpc.PrivateSubnets,
SecurityGroups = new [] { new SecurityGroup(this, "MISecurityGroup", new SecurityGroupProps { Vpc = vpc }) },
InstanceRequirements = new InstanceRequirementsConfig {
VCpuCountMin = 1,
MemoryMin = Size.Gibibytes(2),
CpuManufacturers = new [] { CpuManufacturer.INTEL },
AcceleratorManufacturers = new [] { AcceleratorManufacturer.NVIDIA }
},
PropagateTags = PropagateManagedInstancesTags.CAPACITY_PROVIDER
});
// Optionally configure security group rules using IConnectable interface
miCapacityProvider.Connections.AllowFrom(Peer.Ipv4(vpc.VpcCidrBlock), Port.Tcp(80));
// Add the capacity provider to the cluster
cluster.AddManagedInstancesCapacityProvider(miCapacityProvider);
var taskDefinition = new TaskDefinition(this, "TaskDef", new TaskDefinitionProps {
MemoryMiB = "512",
Cpu = "256",
NetworkMode = NetworkMode.AWS_VPC,
Compatibility = Compatibility.MANAGED_INSTANCES
});
taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryReservationMiB = 256
});
new FargateService(this, "FargateService", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
MinHealthyPercent = 100,
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = miCapacityProvider.CapacityProviderName,
Weight = 1
} }
});
Synopsis
Constructors
| ManagedInstancesCapacityProvider(Construct, string, IManagedInstancesCapacityProviderProps) | A Managed Instances Capacity Provider. |
Properties
| CapacityProviderName | Capacity provider name. |
| Connections | The network connections associated with this resource. |
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
Methods
| Bind(ICluster) | Associates the capacity provider with the specified cluster. |
Constructors
ManagedInstancesCapacityProvider(Construct, string, IManagedInstancesCapacityProviderProps)
A Managed Instances Capacity Provider.
public ManagedInstancesCapacityProvider(Construct scope, string id, IManagedInstancesCapacityProviderProps props)
Parameters
- scope Construct
- id string
- props IManagedInstancesCapacityProviderProps
Remarks
This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.
ExampleMetadata: infused
Examples
Vpc vpc;
Role infrastructureRole;
InstanceProfile instanceProfile;
var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc });
// Create a Managed Instances Capacity Provider
var miCapacityProvider = new ManagedInstancesCapacityProvider(this, "MICapacityProvider", new ManagedInstancesCapacityProviderProps {
InfrastructureRole = infrastructureRole,
Ec2InstanceProfile = instanceProfile,
Subnets = vpc.PrivateSubnets,
SecurityGroups = new [] { new SecurityGroup(this, "MISecurityGroup", new SecurityGroupProps { Vpc = vpc }) },
InstanceRequirements = new InstanceRequirementsConfig {
VCpuCountMin = 1,
MemoryMin = Size.Gibibytes(2),
CpuManufacturers = new [] { CpuManufacturer.INTEL },
AcceleratorManufacturers = new [] { AcceleratorManufacturer.NVIDIA }
},
PropagateTags = PropagateManagedInstancesTags.CAPACITY_PROVIDER
});
// Optionally configure security group rules using IConnectable interface
miCapacityProvider.Connections.AllowFrom(Peer.Ipv4(vpc.VpcCidrBlock), Port.Tcp(80));
// Add the capacity provider to the cluster
cluster.AddManagedInstancesCapacityProvider(miCapacityProvider);
var taskDefinition = new TaskDefinition(this, "TaskDef", new TaskDefinitionProps {
MemoryMiB = "512",
Cpu = "256",
NetworkMode = NetworkMode.AWS_VPC,
Compatibility = Compatibility.MANAGED_INSTANCES
});
taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryReservationMiB = 256
});
new FargateService(this, "FargateService", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
MinHealthyPercent = 100,
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = miCapacityProvider.CapacityProviderName,
Weight = 1
} }
});
Properties
CapacityProviderName
Capacity provider name.
public virtual string CapacityProviderName { get; }
Property Value
Remarks
This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.
ExampleMetadata: infused
Connections
The network connections associated with this resource.
public virtual Connections_ Connections { get; }
Property Value
Remarks
This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.
ExampleMetadata: infused
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
This allows an ECS cluster to use Managed Instances for task placement with managed infrastructure.
ExampleMetadata: infused
Methods
Bind(ICluster)
Associates the capacity provider with the specified cluster.
public virtual void Bind(ICluster cluster)
Parameters
- cluster ICluster
Remarks
This method is called by the cluster when adding the capacity provider.