aws / aws/aws-cdk

Ec2Service: Cannot attach Ec2Service with NetworkModes HOST or BRIDGE to CloudMap service.

Open
#29,245 1 comment 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I want to attach an EC2Service and container to a CloudMap namespace.

The container is using `bridge` network mode as it doesn't need special access to the network, and I'm assuming CloudMap can provide my clients with the port resolved by the container, also I want to deploy more containers than I can attach ENIs for on this instance size (so I am not using awsvpc).

I cannot use Service Connect as I do not want to bring this service into my namespace (AWS please let us attach multiple namespaces to services!!)

The bug is that with these network modes, `AssociateCloudMapService` gives an error.

### Expected Behavior

The EC2Service/Container should be attached to the CloudMap service.

### Current Behavior

```
When specifying 'host' or 'bridge' for networkMode, values for 'containerName' and 'containerPort' must be specified from the task definition.
```

### Reproduction Steps

I have the following configuration:

```csharp
...
PortMappings = new IPortMapping[] { new PortMapping { ContainerPort = 8080, AppProtocol = AppProtocol.Http2, Name = "http" } }
...
service.AssociateCloudMapService(new AssociateCloudMapServiceOptions
{
Container = container,
Service = cloudmapService,
ContainerPort = 8080,
});
```

### Possible Solution

I'm not sure how it transforms the C# into CDK, but I assume it can pull the container name and port from the referenced container, and attach this?

### Additional Information/Context

_No response_

### CDK CLI Version

2.121.1 (build d86bb1a)

### Framework Version

_No response_

### Node.js Version

v19.8.1

### OS

Windows

### Language

.NET

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the AssociateCloudMapService entry point and reproduce the configuration using host or bridge network mode, the referenced container, and containerPort 8080. Trace how the task definition values are validated and determine whether the container name and port can be resolved from the referenced container. Done means the EC2 service can attach to the CloudMap service without the validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.