Show / Hide Table of Contents

Enum NetworkMode

The networking mode to use for the containers in the task.

Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public enum NetworkMode
Syntax (vb)
Public Enum NetworkMode
Remarks

ExampleMetadata: infused

Examples
Vpc vpc;


            var cluster = new Cluster(this, "Cluster", new ClusterProps { Vpc = vpc });

            var securityGroup = new SecurityGroup(this, "SecurityGroup", new SecurityGroupProps {
                Vpc = vpc,
                Description = "Security group for managed instances"
            });

            var miCapacityProvider = new ManagedInstancesCapacityProvider(this, "MICapacityProvider", new ManagedInstancesCapacityProviderProps {
                CapacityOptionType = CapacityOptionType.SPOT,
                Subnets = vpc.PrivateSubnets,
                SecurityGroups = new [] { securityGroup },
                InstanceRequirements = new InstanceRequirementsConfig {
                    VCpuCountMin = 1,
                    MemoryMin = Size.Gibibytes(2)
                }
            });

            // 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

Fields

AWS_VPC

The task is allocated an elastic network interface.

BRIDGE

The task utilizes Docker's built-in virtual network which runs inside each container instance.

HOST

The task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly.

NAT

The task utilizes Docker's built-in virtual network which runs inside each Windows container instance.

NONE

The task's containers do not have external connectivity and port mappings can't be specified in the container definition.

Fields

Name Description
AWS_VPC

The task is allocated an elastic network interface.

BRIDGE

The task utilizes Docker's built-in virtual network which runs inside each container instance.

HOST

The task bypasses Docker's built-in virtual network and maps container ports directly to the EC2 instance's network interface directly.

NAT

The task utilizes Docker's built-in virtual network which runs inside each Windows container instance.

NONE

The task's containers do not have external connectivity and port mappings can't be specified in the container definition.

Back to top Generated by DocFX