Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamescarter-le opened this issue Feb 24, 2024 · 1 comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@jamescarter-le
Copy link

jamescarter-le commented Feb 24, 2024

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:

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

@jamescarter-le jamescarter-le added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 24, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Feb 24, 2024
@pahud
Copy link
Contributor

pahud commented Feb 26, 2024

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

Unfortunately I can't see how your task definition is defined. Can you share the complete code snippets so we can read more about it?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 26, 2024
@vinayak-kukreja vinayak-kukreja added @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud and removed package/tools Related to AWS CDK Tools or CLI labels Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

3 participants