aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.51k stars 3.86k forks source link

(ecs): array of objects is incorrectly translated to keyword args in Python example #22028

Open ghost opened 2 years ago

ghost commented 2 years ago

Describe the issue

In the TypeScript API Ref, the example for Ec2Service.registerLoadBalancerTargets looks like this:

declare const listener: elbv2.ApplicationListener;
declare const service: ecs.BaseService;
service.registerLoadBalancerTargets(
  {
    containerName: 'web',
    containerPort: 80,
    newTargetGroupId: 'ECS',
    listener: ecs.ListenerConfig.applicationListener(listener, {
      protocol: elbv2.ApplicationProtocol.HTTPS
    }),
  },
)

The Python version of the example looks like this:

# listener: elbv2.ApplicationListener
# service: ecs.BaseService

service.register_load_balancer_targets(
    container_name="web",
    container_port=80,
    new_target_group_id="ECS",
    listener=ecs.ListenerConfig.application_listener(listener,
        protocol=elbv2.ApplicationProtocol.HTTPS
    )
)

Each argument of the Python example should be an EcsTarget with the properties given as keyword arguments. The keyword args are instead given as keyword arguments to register_load_balancer_targets, which is wrong.

Links

https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecs/Ec2Service.html#aws_cdk.aws_ecs.Ec2Service.register_load_balancer_targets

peterwoodworth commented 2 years ago

Thanks for reporting this Jerry, I've come across similar instances of this in the past. Here's a similar issue where this occurs https://github.com/aws/aws-cdk/issues/4900