Reputation: 2181
I am wondering if we can write a lambda function in one region for example us-east-1 to query a DynamoDB database present in another region.
I feel that there is a provision. just wondering how the syntax would be to achieve this.
dynamo_client = boto3.resource('dynamodb')
dynamo_table = dynamo_client.Table('table')
Above is a normal example of a dynamodb connection in the same region.
Wondering how would be the syntax when we want to access the dynamodb from another region.
Thank you
Upvotes: 3
Views: 3863
Reputation: 10704
Yes you can. In your Lambda code - you can still set the Region for the DynamoDB Service Client. Consider this Java example:
// Create a DynamoDbClient object
Region region = Region.US_WEST_2;
DynamoDbClient ddb = DynamoDbClient.builder()
.region(region)
.build();
Now you can interact with a DynamoDB table located in US-WEST_2 region.
Upvotes: 2