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

Unclear how to use ecs-patterns NetworkMultipleTargetGroupsEc2Service #6263

Closed
konstantinj opened this issue Feb 13, 2020 · 5 comments
Closed
Assignees
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p2

Comments

@konstantinj
Copy link

In my use case I'm trying to setup Gitlab on ecs with an NLB attached so the ip is static but the LoadBalancer can take the certificate and I don't need to handle that in Gitlab.

❓ General Issue

This is my code:

const service = new NetworkMultipleTargetGroupsEc2Service(this, 'Service', {
            cluster: cluster,
            memoryReservationMiB: 4096,
            desiredCount: 1,
            healthCheckGracePeriod: Duration.seconds(240),
            loadBalancers: [
                {
                    publicLoadBalancer: false,
                    domainName: scope.getConfig(this, 'domainName'),
                    domainZone: hostedZone,
                    name: scope.getConfig(this, 'domainName'),
                    listeners: [
                        {
                            name: 'https',
                            port: 443,
                        },
                        {
                            name: 'http',
                            port: 80,
                        },
                        {
                            name: 'ssh',
                            port: 22,
                        }
                    ]
                }
            ],
            taskImageOptions: {
                image: ContainerImage.fromRegistry('gitlab/gitlab-ce'),
                containerPorts: [80, 22],
                environment: {},
                secrets: {
                    AWS_SECRET_ACCESS_KEY: Secret.fromSsmParameter(ssmSecretKey),
                    LDAP_PASSWORD: Secret.fromSsmParameter(ssmLdapPassword),
                    CI_APP_ID: Secret.fromSsmParameter(ssmCiAppId),
                    CI_APP_SECRET: Secret.fromSsmParameter(ssmCiAppSecret),
                },
                logDriver: LogDriver.awsLogs({
                    logGroup: logGroup,
                    streamPrefix: 'gitlab',
                }),
            }
        })

The Question

First of all the created Loadbalancer is internet-facing while with the other construct NetworkLoadBalancedEc2Service it is private. publicLoadBalancer needs to be set to false manually.

For setting this I need to fill out loadBalancers completely. This way I need to fill out all options below, even a name for the NLB. I have no idea why this is needed.

This way I also need to create listeners since it's a required field.

I think this way it's not possible to create a TLS listener.

I'm not really sure how to use this construct. Also it is not possible to get to the created resources later on using my service object. The properties are the ones from the NetworkLoadBalancedEc2Service contruct. I have no idea which listener is meant on service.listener.

Creating my Gitlab using NetworkLoadBalancedEc2Service only did also not work because of #4283

Environment

  • CDK CLI Version: 1.23.0
  • Module Version: 1.23.0
  • OS: osx
  • Language: Typescript
@konstantinj konstantinj added the needs-triage This issue or PR still needs to be triaged. label Feb 13, 2020
@SomayaB SomayaB added @aws-cdk/aws-ecs-patterns Related to ecs-patterns library guidance Question that needs advice or information. labels Feb 17, 2020
@iamhopaul123
Copy link
Contributor

iamhopaul123 commented Feb 20, 2020

Hi @konstantinj, can you also attach the error log like why this construct doesn't work?

The reason why we want this pattern is because it is easier for you to spin up your application if you need multiple LBs or multiple target groups. However, if you only need one LB with one target group. Then NetworkLoadBalancedEc2Service would be better to use.

To answer your questions:

First of all the created Loadbalancer is internet-facing while with the other construct NetworkLoadBalancedEc2Service it is private. publicLoadBalancer needs to be set to false manually.

I don't think the default value for publicLoadBalancer is different. If you have trouble in configuring the security group then this might help.

For setting this I need to fill out loadBalancers completely. This way I need to fill out all options below, even a name for the NLB. I have no idea why this is needed.

NetworkMultipleTargetGroupsEc2Service creates an NLB with one listener for you by default. However, we also provide with options to customize if more LBs/listeners are required. The name is required because we allow multiple LBs to be defined.

you can skip setting Load balancer like the example in the README:

// One application load balancer with one listener and two target groups.
const loadBalancedEc2Service = new ApplicationMultipleTargetGroupsEc2Service(stack, 'Service', {
  cluster,
  memoryLimitMiB: 256,
  taskImageOptions: {
    image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  },
  targetGroups: [
    {
      containerPort: 80,
    },
    {
      containerPort: 90,
      pathPattern: 'a/b/c',
      priority: 10
    }
  ]
});

This way I also need to create listeners since it's a required field.

Same reason above. If it is just one LB one listener structure then LoadBalancer field can be skipped, unless it is an HTTPS LB then you have to set up domainName and domainZone.

I think this way it's not possible to create a TLS listener.

Yes you can do it by setting your certificate.

Also it is not possible to get to the created resources later on using my service object. The properties are the ones from the NetworkLoadBalancedEc2Service contruct. I have no idea which listener is meant on service.listener.

service.listener is the first listener of the first LB. We expose properties as required. What else properties would you like to expose?

@iamhopaul123
Copy link
Contributor

iamhopaul123 commented Feb 20, 2020

Apologies so to create a TLS listener you can do service.loadBalancer.addListener() then add a TLS listener. But yes we should fix that!

@SoManyHs SoManyHs removed the needs-triage This issue or PR still needs to be triaged. label Feb 24, 2020
@SoManyHs
Copy link
Contributor

Possibly related to #5461 @bvtujo

@SoManyHs SoManyHs added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 23, 2020
@SoManyHs SoManyHs removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 23, 2020
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Mar 25, 2020
@SomayaB SomayaB added bug This issue is a bug. and removed guidance Question that needs advice or information. labels Jun 22, 2020
@SoManyHs SoManyHs added the guidance Question that needs advice or information. label Dec 22, 2020
@iamhopaul123 iamhopaul123 removed the in-progress This issue is being actively worked on. label Dec 22, 2020
@MrArnoldPalmer MrArnoldPalmer added effort/small Small work item – less than a day of effort p2 labels Feb 22, 2021
@namedgraph
Copy link

And how does one specify the backend/upstream server? I suppose that's what the target groups are for, but I cannot find any examples.

@MrArnoldPalmer MrArnoldPalmer removed their assignment Jun 21, 2021
@peterwoodworth peterwoodworth removed the guidance Question that needs advice or information. label Jul 8, 2021
@github-actions
Copy link

github-actions bot commented Jul 8, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants