569532 (7) [Avatar] Offline
Hello again,

When I ran the integration tests at first (before updating the code), I was prompted with a message indicating that Region is missing while executing get-restaurants and search-restaurants. The message was produced on the Scan operation of get-restaurants for example.

This never happened while browsing the site live.

So my workaround was adding this to both functions:

const awsRegion = process.env.AWS_REGION;

// set region if not set (as not set by the SDK by default)
var ddbOptions = {};
ddbOptions.region = awsRegion;

const dynamodb = new AWS.DynamoDB.DocumentClient(ddbOptions);

My questions,

- Why did this happen to me & not in your case?
- Is it the best workaround? Or can I do better?

Thank you.
Yan Cui (49) [Avatar] Offline
I do set the region in the given step here.

In this case, when the 'given' module is required, the region would be set to 'us-east-1'. You can use process.env.REGION but you need something else to set the REGION, so you end up hardcoding it somewhere else, which is why I decided to just hardcode it in the 'given' module.