When I run my lambda locally using AWS SAM it can’t see DynamoDB tables. Everything is fine if the lambda is running in the cloud env, it just doesn’t work locally. Also this command: aws dynamodb list-tables
works locally – it lists tables successfully, that’s how I know that my config/aws creds are set up properly. The relevant python code:
<code>ddb = boto3.resource("dynamodb")
client = ddb.meta.client
response = client.list_tables()
print("Tables in DynamoDB:")
for table_name in response['TableNames']:
print(table_name)
</code>
<code>ddb = boto3.resource("dynamodb")
client = ddb.meta.client
response = client.list_tables()
print("Tables in DynamoDB:")
for table_name in response['TableNames']:
print(table_name)
</code>
ddb = boto3.resource("dynamodb")
client = ddb.meta.client
response = client.list_tables()
print("Tables in DynamoDB:")
for table_name in response['TableNames']:
print(table_name)
Policy for the lambda execution role that my lambda uses:
<code>- PolicyName: DynamoDBAccessPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:ListTables
Resource: '*'
</code>
<code>- PolicyName: DynamoDBAccessPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:ListTables
Resource: '*'
</code>
- PolicyName: DynamoDBAccessPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:ListTables
Resource: '*'
Anyone knows what’s happening here? Am I missing some specific SAM configuration or smth?