You're partly correct in that it infers the account number and permissions needed from the IAM policy attached to your Lambdas ExecutionRole.
And you're also correct that DynamoDB is a http/https based connection, which uses short lived connections rather that the long lived ones that you may be more familiar with.
Ultimately it comes down to how you configure your DynamoDB Client. It's through the parameters you pass to your SDKs client that Lambda knows how to connect to that table. 2 important parameters here are the region_name
and table_name
:
session = boto3.session.Session(region_name="eu-west-1")
client = session.client('dynamodb')
response = client.scan(
TableName=table_name
)
Above you can see an example of a Scan
in python, where you see the region being set and also the table name being passed as a parameter to the Scan
function.
Most people tend to store their table names as Lambda Environment Variables which allow you to set the tables name at creation time through infrastructure as code for example.
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStartedDynamoDB.html