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

InvalidParameterException: The container app did not have a container port 80 defined #1172

Closed
kellemar opened this issue Dec 6, 2023 · 4 comments
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@kellemar
Copy link

kellemar commented Dec 6, 2023

What happened?

I am creating a fargate service based on the ECS Fargate template provided on the site.

My NodejS app uses Port 3000. If Port 80 is used, the default tempalte works fine.

However, on Port 3000, and having set the container and host port manually to 3000, doing a pulumi up causes this to occur:

InvalidParameterException: The container app did not have a container port 80 defined.

Do I need to add something else? Here's the actual part of the code where containerPort and hostPort is defined.

const containerPort = 3000;
const service = new awsx.ecs.FargateService("service", {
    cluster: cluster.arn,
    assignPublicIp: true,
    taskDefinitionArgs: {
        container: {
            name: "app",
            image: image.imageUri,
            cpu: cpu,
            memory: memory,
            essential: true,
            
            portMappings: [{
                containerPort: containerPort,
                hostPort: containerPort,
                protocol: "tcp",
                targetGroup: loadbalancer.defaultTargetGroup,
            }],
        },
    }, 
}, {
    dependsOn: [loadbalancer.defaultTargetGroup]
  });

Example

  1. Follow the template in the ECS Fargate tutorial.
  2. Change containerPort 3000.
  3. Add hostPort = 3000 in the container definition.
  4. In your docker app, make sure 3000 is exposed.

Output of pulumi about

CLI
Version 3.95.0
Go Version go1.21.4
Go Compiler gc

Plugins
NAME VERSION
aws 6.13.1
awsx 2.3.0
docker 4.5.0
docker 3.6.1
nodejs unknown

Host
OS darwin
Version 14.0
Arch arm64

This project is written in nodejs: executable='/Users/alvindecruz/.nvm/versions/node/v18.18.0/bin/node' version='v18.18.0'

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@kellemar kellemar added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 6, 2023
@iwahbe
Copy link
Member

iwahbe commented Dec 6, 2023

Hi @kellemar. It looks like you are creating an awsx.ecs.FargateService, which is from a different provider. I'll transfer this issue to pulumi-awsx.

@iwahbe iwahbe transferred this issue from pulumi/pulumi-aws Dec 6, 2023
@mjeffryes
Copy link
Member

mjeffryes commented Dec 9, 2023

GI believe the problem is that the LoadBalancer is looking for the container to export port 80, but the container is only exposing port 3000. (https://stackoverflow.com/questions/66733809/how-to-fix-failed-updating-service-the-container-xxx-did-not-have-a-container) You should be able to point the loadbalancer at the right place using defaultTargetGroupPort:

const loadbalancer = new awsx.lb.ApplicationLoadBalancer("loadbalancer", {
    defaultTargetGroupPort: 3000
});

@mjeffryes mjeffryes added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Dec 9, 2023
@mjeffryes
Copy link
Member

I've also reproduced the error here:
mjeffryes/nodejs-repros@a2e98cd
and the fix here:
mjeffryes/nodejs-repros@c7276a3

@kellemar
Copy link
Author

Thanks @mjeffryes !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants