In this tutorial, you created the
Movies table in DynamoDB on your computer and
performed basic operations. The downloadable version of DynamoDB is useful during application development and
testing. However, when you are ready to run your application in a production
environment, you need to modify your code so that it uses the Amazon DynamoDB web service.
Using the Amazon DynamoDB Service
You need to change the endpoint in your application in order to use the Amazon DynamoDB service. To do this, find the following lines in the code:
$sdk = new Aws\Sdk([ 'endpoint' => 'http://localhost:8000', 'region' => 'us-west-2', 'version' => 'latest' ]);
Now remove the
endpoint parameter so that the code looks like
$sdk = new Aws\Sdk([ 'region' => 'us-west-2', 'version' => 'latest' ]);
After you remove this line, your code can access the DynamoDB service in the region
specified by the
region config value. For example, the following line
specifies that you want to use the US West (Oregon) region:
'region' => 'us-west-2',
Instead of using DynamoDB on your computer, the program now uses the DynamoDB service endpoint in US West (Oregon).
Amazon DynamoDB is available in several regions worldwide. For the complete list, see Regions and Endpoints in the AWS General Reference. For more information about setting regions and endpoints in your code, see the boto: A Python interface to Amazon Web Services.
Finally, we recommend that you read the Amazon DynamoDB Developer Guide. It provides more in-depth information about DynamoDB, including sample code and best practices.