AWS Elastic Beanstalk can now provision and configure AWS resources to power your application. In conjunction with a new version of our PHP runtime, you get more control and more flexibility with less code.

In October, we announced the Elastic Beanstalk configuration files and talked about how they can help you configure EC2 instances without creating and maintaining custom AMIs. We have extended these configuration files to allow you to provision and configure resources such as SQS queues and DynamoDB tables for your Elastic Beanstalk application. The configuration file format is YAML-based, and you can find the details in the AWS Elastic Beanstalk Developer Guide.

I’d lke to show you how simple and powerful it is to use Elastic Beanstalk to create and configure the new environment resources. Ill use the updated PHP runtime and show you how to configure DynamoDB backed session management. You can find the full example in the AWS Elastic Beanstalk Developer Guide.

Make sure to include a require for the AWS SDK for PHP 2 in your composer.json file:

“require”:{“aws/aws-sdk-php”:“*”}

Finally, add the following code to your PHP application to connect it to the configuration file:

<?php

// Include the SDK using the Composer autoloaderrequire‘vendor/autoload.php’;

use Aws\DynamoDb\DynamoDbClient;

// Grab the session table name and region from the configuration filelist($tableName,$region)=file(__DIR__ .‘/../sessiontable’);

// Create a DynamoDB client and register the table as the session handler$dynamodb= DynamoDbClient::factory(array(‘region’=>$region));$handler=$dynamodb->registerSessionHandler(array(‘table_name’=>$tablename,‘hash_key’=>‘Index’));

?>

As you can see, you can use this new Elastic Beanstalk feature to set up and configure the AWS resources needed by your application.