Get the name of a dynamo table created with AWS CDK

0 votes

Using the example from here. I can create a table and lambda function that has access to the table. But I need to know the name of table to use table.put to add records.

Short term I am declaring the table name in the dynamo_table_props and then exporting it to the lambda as an environment variable. However, this is against the best practices to declare names.

I've tried to access the pattern properties, but cannot find the correct syntax.

What I have working is:

from aws_solutions_constructs.aws_iot_lambda_dynamodb import IotToLambdaToDynamoDB
from aws_cdk import (
    aws_iot as iot,
    aws_lambda as _lambda,
    Stack
)
from constructs import Construct

IotToLambdaToDynamoDB(self, 'test-iot-lambda-dynamodb-stack',
            lambda_function_props=_lambda.FunctionProps(
                code=_lambda.Code.from_asset('lambda'),
                runtime=_lambda.Runtime.PYTHON_3_9,
                handler='index.handler',
                environment={ 
                    'TABLE_NAME':'hard_coded_table_name'
                },
            ),
            iot_topic_rule_props=iot.CfnTopicRuleProps(
                topic_rule_payload=iot.CfnTopicRule.TopicRulePayloadProperty(
                    rule_disabled=False,
                    description="Processing of DTC messages from the AWS Connected Vehicle Solution.",
                    sql="SELECT * FROM 'connectedcar/dtc/#'",
                    actions=[]
                )
            ),
            dynamo_table_props=ddb.TableProps(
               partition_key={'name': 'id', 'type': ddb.AttributeType.STRING},
               table_name='hard_coded_table_name'))

Jan 3, 2023 in AWS by Tejashwini
• 3,820 points
596 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer

How to change the name of a repository in AWS CodeCommit?

Hi@akhtar, You can rename a repository. The repository name ...READ MORE

answered Nov 25, 2020 in AWS by MD
• 95,440 points
2,333 views
0 votes
1 answer

How to get the contents of a folder in an AWS CodeCommit repository?

Hi@akhtar, The following get-folder example demonstrates how to get the ...READ MORE

answered Nov 25, 2020 in AWS by MD
• 95,440 points

edited Aug 4, 2023 by Khan Sarfaraz 2,230 views
0 votes
1 answer
+1 vote
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link  https://aws.amazon.com/certificate-manager/faqs/ You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 58,090 points
1,619 views
0 votes
2 answers

How to display just the name of files using aws s3 ls command?

aws s3 ls s3://<your_bucket_name>/ | awk '{print ...READ MORE

answered Mar 17, 2019 in AWS by anonymous
21,038 views
0 votes
1 answer

Amazon DynamoDB: warning

Yes, you should address this problem. You can ...READ MORE

answered Aug 30, 2018 in AWS by Priyaj
• 58,090 points
438 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Chalice: Unable to connect with DynamoDB through pynamodb

You have to add "autogen_policy":false, to config.json and ...READ MORE

answered Sep 10, 2018 in AWS by Priyaj
• 58,090 points
1,840 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP