Skip to content

AutoAssignIP is always set to true, even for ECS EC2 task #2996

@Kent1

Description

@Kent1

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    I want to create a Compatibility.Ec2AndFargate TaskDefinition. using the network mode AWSVPC. However, AutoAssignIP property is set automatically if we use public Subnet.
    See run-ecs-task-base.ts. While it is not a problem with Fargate, ECS EC2 does not allow to have AutoAssignIP to true.

  • What is the expected behavior (or behavior of feature suggested)?
    AutoAssignIP should be disabled in run-ecs-ec2-task.ts

  • What is the motivation / use case for changing the behavior or adding this feature?
    Make Fargate task definition work with ECS EC2

  • Please tell us about your environment:

    • CDK CLI Version: 0.35.0 (build c5e43e2)
    • Module Version: 0.35.0
    • OS: OSX Mojave
    • Language: Java
  • Code:

Cluster ecsCluster = new Cluster(this, "PtaEcsCluster", ClusterProps.builder()
        .withClusterName("Pta")
        .withVpc(vpc)
        .build());

ecsCluster.addCapacity("PtaEcsInstance", AddCapacityOptions.builder()
        .withInstanceType(new InstanceType("t3.small"))
        .withVpcSubnets(SubnetSelection.builder().withSubnetType(SubnetType.Public).build())
        .build());

TaskDefinition taskDefinition = new TaskDefinition(this, "PtaEcsTaskDefinition", 
TaskDefinitionProps.builder()
        .withCompatibility(Compatibility.Ec2AndFargate)
        .withNetworkMode(NetworkMode.AwsVpc)
        .withMemoryMiB("1024")
        .build());

taskDefinition.addContainer("PtaContainer", ContainerDefinitionOptions.builder()
        .withImage(ecrImage)
        .withCpu(512)
        .withMemoryReservationMiB(512)
        .withEssential(true)
        .build());

Rule rule = new Rule(this, "PtaEventRule", RuleProps.builder()
        .withEnabled(false)
        .withSchedule(Schedule.rate(15, TimeUnit.Minute))
        .build());

rule.addTarget(new EcsTask(EcsTaskProps.builder()
        .withSubnetSelection(SubnetSelection.builder().withSubnetType(SubnetType.Public).build())
        .withCluster(ecsCluster)
        .withTaskDefinition(taskDefinition)
        .withTaskCount(1)
        .build()));

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ec2Related to Amazon Elastic Compute Cloud@aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.good first issueRelated to contributions. See CONTRIBUTING.mdlanguage/javaRelated to Java bindingsneeds-reproductionThis issue needs reproduction.response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions