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

aws_ecs: BaseService.register_load_balancer_targets() got an unexpected keyword argument 'container_name' #30419

Closed
kcong7714 opened this issue Jun 1, 2024 · 3 comments
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@kcong7714
Copy link

kcong7714 commented Jun 1, 2024

Describe the bug

I have a my_service instantiated from aws_ecs.FargateService(). A container my-container is added.

I want to register load balancer target as per documentation:
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecs/FargateService.html#aws_cdk.aws_ecs.FargateService.register_load_balancer_targets

It throws error:
TypeError: BaseService.register_load_balancer_targets() got an unexpected keyword argument 'container_name'

Expected Behavior

Able to add container my-container of my_service to a new target group, added to the specified listener.

Current Behavior

It throws error:
TypeError: BaseService.register_load_balancer_targets() got an unexpected keyword argument 'container_name'

Reproduction Steps

        my_service = aws_ecs.FargateService(
            self, 'MyService',
            cluster=cluster,
            service_name='my-service',
            task_definition=ecs.FargateTaskDefinition(
                self, 'MyTaskDefinition',
            ),
        )

        my_service.task_definition.add_container(
            'MyContainer',
            container_name='my-container',
            image=ecs.ContainerImage.from_registry(name=CONTAINER_IMAGE_URI),
            port_mappings=[ecs.PortMapping(container_port=int(CONTAINER_PORT))],
        )
        
        my_service.register_load_balancer_targets(
            container_name='my-container',
            container_port=int(CONTAINER_PORT),
            new_target_group_id='MyTargetGroup',
            listener=ecs.ListenerConfig.application_listener(
                listener=listener,
                protocol=elbv2.ApplicationProtocol.HTTP,
                priority=1,
                conditions=[elbv2.ListenerCondition.host_headers([MY_DOMAIN_NAME])],
            )
        )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.144.0 (build 5fb15bc)

Framework Version

No response

Node.js Version

v20.11.1

OS

Ubuntu 22.04.4 LTS

Language

Python

Language Version

3.10.12

Other information

No response

@kcong7714 kcong7714 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 1, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Jun 1, 2024
@kcong7714
Copy link
Author

The answer is here:
#21383

I.e. documentation is still incorrect.

Copy link

github-actions bot commented Jun 3, 2024

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

@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants