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

Object resource conversion error using Ec2TaskDefinition.from_ec2_task_definition_arn with ApplicationLoadBalancedEc2Service #8499

Closed
ghost opened this issue Jun 11, 2020 · 2 comments
Assignees
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. language/python Related to Python bindings

Comments

@ghost
Copy link

ghost commented Jun 11, 2020

  • When using a task definition object (Ec2TaskDefinition.from_ec2_task_definition_arn) in ApplicationLoadBalancedEc2Service pattern, i get the following error:
jsii.errors.JSIIError: Object of type @aws-cdk/core.Resource is not convertible to @aws-cdk/aws-ecs.Ec2TaskDefinition

Reproduction Steps

python code:

        task_arn = (
            "arn:aws:ecs:<regionacctredacted>task-definition/mytask"
        )

        task_definition = ecs.Ec2TaskDefinition.from_ec2_task_definition_arn(
            self, "my_task_def", task_arn
        )

        loadbalanced_service = patterns.ApplicationLoadBalancedEc2Service(
            self,
            "loadbalance_service",
            cluster=ecs_cluster, <- ecs cluster code not included here, just a regular ec2 cluster 
            task_definition=task_definition
        )

Error Log

Traceback (most recent call last):
  File "app.py", line 20, in <module>
  File "/.env/lib/python3.7/site-packages/jsii/_runtime.py", line 66, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/stack.py", line 83, in __init__
    task_definition=task_definition,
  File "/.env/lib/python3.7/site-packages/jsii/_runtime.py", line 66, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/.env/lib/python3.7/site-packages/aws_cdk/aws_ecs_patterns/__init__.py", line 3286, in __init__
    jsii.create(ApplicationLoadBalancedEc2Service, self, [scope, id, props])
  File "/.env/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 229, in create
    interfaces=[iface.__jsii_type__ for iface in getattr(klass, "__jsii_ifaces__", [])],
  File "/.env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 333, in create
    return self._process.send(request, CreateResponse)
  File "/.env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 318, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Object of type @aws-cdk/core.Resource is not convertible to @aws-cdk/aws-ecs.Ec2TaskDefinition
Subprocess exited with error 1

Environment

  • CLI Version : 1.18.77
  • **Framework Version:**1.45.0
  • Node.js Version: 12.13.1
  • OS : mac os 10.15.4
  • Language (Version): python 3.7

Other

Looks like during synthesis, the task definition object is a core.resource and cannot be converted to what is needed for the pattern.

I feel like this is a bug. I asked around various forums/slack channels but no answers as yet.

It looks like i'm using this correctly, but honestly this is the first time i'm using this construct/pattern and there are no real good examples on using this i can get a bearing on( or at least any that i can find). So it's entirely possible i'm not using this right.

When i comment out the service pattern, things synthesize with no problems.


This is 🐛 Bug Report

@ghost ghost added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 11, 2020
@ghost ghost changed the title Object resource conversion error using Ec2TaskDefinition.from_ec2_task_definition_arn with ApplicationLoadBalancedEc2Service with Object resource conversion error using Ec2TaskDefinition.from_ec2_task_definition_arn with ApplicationLoadBalancedEc2Service Jun 11, 2020
@SomayaB SomayaB added @aws-cdk/aws-ecs-patterns Related to ecs-patterns library language/python Related to Python bindings labels Jun 11, 2020
@SoManyHs
Copy link
Contributor

Related: #6240

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

Closing as a duplicate of abovementioned issue -- let us know if you have other questions!

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. language/python Related to Python bindings
Projects
None yet
Development

No branches or pull requests

3 participants