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_lambda_dynamodb raises exception when using existing Table #1011

Open
srbcheema1 opened this issue Sep 18, 2023 · 1 comment
Open

aws_lambda_dynamodb raises exception when using existing Table #1011

srbcheema1 opened this issue Sep 18, 2023 · 1 comment
Labels
bug Something isn't working needs-triage The issue or PR still needs to be triaged

Comments

@srbcheema1
Copy link

This is similar to: #119

I am using an existing DynamoDB table with the LambdaToDynamoDB. When I do cdk synth, I receive this error.

TypeError: type of argument existing_table_obj must be one of (aws_cdk.aws_dynamodb.Table, NoneType); got jsii._reference_map.InterfaceDynamicProxy instead

The object that is being passed to the existing_table_obj is <jsii._reference_map.InterfaceDynamicProxy object at 0x10afdbb50>. from_table_name states that it returns an object of type ITable. Perhaps this is the issue? Is there a way to convert ITable to a Table object?

Reproduction Steps

import aws_cdk
from aws_solutions_constructs.aws_lambda_dynamodb import LambdaToDynamoDB

table = aws_cdk.aws_dynamodb.Table.from_table_name(self,"existing-table", "exiting-table-name")

LambdaToDynamoDB(
    self, 
    'LambdaToDynamoDB',
    existing_table_obj=table,
    lambda_function_props=aws_cdk.aws_lambda.FunctionProps(
        function_name=function_name,
        code=lb.Code.from_asset('./lambda_functions'),
        runtime=lb.Runtime.PYTHON_3_8,
        handler='index.handler'
    )
)

Error Log

TypeError: type of argument existing_table_obj must be one of (aws_cdk.aws_dynamodb.Table, NoneType); got jsii._reference_map.InterfaceDynamicProxy instead

Environment

  • **CDK CLI Version :2.72.1
  • **CDK Framework Version: aws-cdk-lib==2.72.1
  • **AWS Solutions Constructs Version : aws-solutions-constructs-aws-lambda-dynamodb==2.36.0
  • **OS : linux
  • **Language : python

Other

This is 🐛 Bug Report

@srbcheema1 srbcheema1 added bug Something isn't working needs-triage The issue or PR still needs to be triaged labels Sep 18, 2023
@biffgaut
Copy link
Contributor

biffgaut commented Nov 6, 2023

Sorry for the delay in responding. The issue is the difference between a Table interface (ITable in Typescript) and a Table object (Table in Typescript). The existingTable property requires a Table object, but the Table.from*() functions return an interface (ITable), so can't be used. In this situation, existingTables must be tables that exist elsewhere in this stack vs elsewhere in the account.

This is a drawback of some of the early constructs, later we started accepting Interfaces as props instead of Objects. We're tossing around the idea of a big 3.0.0 release where we could make many of the lessons we learned standard - while these would be very simple to accommodate breaking changes, they would be breaking changes and would require major release.

I'm gonna leave this Issue open for the moment and see if anyone here has any ideas for a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage The issue or PR still needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants