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.Ec2TaskDefinition : add_container function isn't working properly #4519

Open
keeratg opened this issue May 20, 2024 · 1 comment
Open
Labels
bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort jsii p2

Comments

@keeratg
Copy link

keeratg commented May 20, 2024

Describe the bug

As shown in the image below when I call the add_container function a Ec2TaskDefinition I get the following error: TypeError: add_container() got an unexpected keyword argument 'memory_limit_mi_b'. I checked the documentation and I am calling it correctly with the right parameters.
Documentation:https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecs/Ec2TaskDefinition.html

Screenshot 2024-05-19 at 9 17 00 PM

Expected Behavior

I expect it to add a container with the given memory_limit_mi_b value

Current Behavior

Currently, it is giving me an error when I try to deploy.

Error image:
Screenshot 2024-05-19 at 9 25 08 PM

Reproduction Steps

task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
task_definition.add_container("TheContainer",
    image=ecs.ContainerImage.from_registry("example-image"),
    memory_limit_mi_b=256,
)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.142.1 (build ed4e152)

Framework Version

No response

Node.js Version

v22.2.0

OS

MacOS

Language

Python

Language Version

Python 3.8.2

Other information

No response

@keeratg keeratg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 20, 2024
@ashishdhingra ashishdhingra self-assigned this May 20, 2024
@ashishdhingra ashishdhingra added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels May 20, 2024
@ashishdhingra
Copy link

@keeratg Good morning. Upon developing the sample in Python, this appears to be a documentation issue. Example code below:

from aws_cdk import (
    # Duration,
    Stack,
    aws_ecs as ecs,
)
from constructs import Construct

class PythonStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # The code that defines your stack goes here

        # example resource
        taskDefinition = ecs.TaskDefinition(self, "TaskDef", compatibility=ecs.Compatibility.EC2)
        taskDefinition.add_container("TheContainer",
            image=ecs.ContainerImage.from_registry("example-image"),
            memory_limit_mib=256                            
        )

I see 2 issues with the example at https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ecs/Ec2TaskDefinition.html (the issues are easily caught by running cdk synth command, we do not need to deploy the stack):

  • The property is named memory_limit_mib (not memory_limit_mi_b). This is also supported if you look at the add_container() parameter list in the above documentation where is lists the correct parameter named memory_limit_mib.
  • When we use code ecs.TaskDefinition(self, "TaskDef") while defining TaskDefinition, cdk synth fails with error TypeError: TaskDefinition.__init__() missing 1 required keyword-only argument: 'compatibility'. So looks like the example also needs to be updated to specify compatibility.

Thanks,
Ashish

@ashishdhingra ashishdhingra added p2 effort/small Small work item – less than a day of effort documentation This is a problem with documentation. jsii and removed needs-reproduction This issue needs reproduction. labels May 20, 2024
@ashishdhingra ashishdhingra removed their assignment May 20, 2024
@ashishdhingra ashishdhingra transferred this issue from aws/aws-cdk May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort jsii p2
Projects
None yet
Development

No branches or pull requests

2 participants