aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.5k stars 3.84k forks source link

aws-ecs: ECS Anywhere for Windows not supported due to restriction on network mode #19922

Closed grollat closed 1 year ago

grollat commented 2 years ago

Describe the bug

in the following file https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-ecs/lib/base/task-definition.ts the following check was implemented too support ECS Anywhere: throw new Error(External tasks can only have Bridge network mode, got: ${this.networkMode}); Since ECS-Anywhere for windows was release a few weeks ago we should lift this restriction. the documentation (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere.html) states now: "Tasks that run on external instances must use the bridge, host, or none network modes. The awsvpc network mode isn't supported." this issue is blocking the use of CDK with ECS for windows.

Expected Behavior

all network modes supported in the doc shouold be supported in the code: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere.html

Current Behavior

only bridge network mode is supported which prevent creation of external task def for windows OS

Reproduction Steps

   const adminTaskDefinitionWindows = new ecs.TaskDefinition(this, 'REPAdminTaskWindows', {
      executionRole: taskExecRole,
      compatibility: ecs.Compatibility.EXTERNAL,
      networkMode: ecs.NetworkMode.NONE,
      placementConstraints: [ecs.PlacementConstraint.memberOf("attribute:ecs.os-type == windows")]
    });

Possible Solution

change the network mode check (or remove it completely and let the service API be the master when it comes to these checks which would avoid having too keep updating the code.

Note that ExternalTaskProp struct also should support adding the network mode as an option.

Additional Information/Context

No response

CDK CLI Version

2.9.0

Framework Version

No response

Node.js Version

v14.15.4

OS

MACOSX

Language

Typescript

Language Version

No response

Other information

No response

pallymore commented 1 year ago

this has been fixed.

pahud commented 1 year ago

closing as it's been fixed

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.