User guide

A config file that copies the jar into Tomcat's lib directory and applies the overridden context.xml
file.
You can find in more information on customizing the Elastic Beanstalk environments in the developer
guide for that service.
If you deploy to Elastic Beanstalk with the AWS Toolkit for Eclipse, then the session manager is set up
for you if you go through the New AWS Java Web Project wizard and select DynamoDB for session
management.The Toolkit for Eclipse configures all the needed files, and puts them in the .ebextensions
directory inside the WebContent directory of your project. If you have problems finding this directory,
make sure you aren't hiding files that begin with a period.
Manage Tomcat Session State with DynamoDB
If the Tomcat server is running on an Amazon EC2 instance that is configured to use IAM roles for EC2
Instances, you do not need to specify any credentials in the context.xml file; in this case, the AWS
SDK for Java uses IAM roles credentials obtained through the instance metadata service (IMDS).
When your application starts, it looks for an DynamoDB table called, by default, Tomcat_SessionState.
The table should have a string hash key named "sessionId" (case-sensitive), no range key, and the desired
values for ReadCapacityUnits and WriteCapacityUnits.
We recommend that you create this table before first running your application. (For information on working
with DynamoDB tables and provisioned throughput, see the Amazon DynamoDB Developer Guide.) If
you don't create the table, however, the extension creates it during initialization. See the context.xml
options in the next section for a list of attributes that configure how the session-state table is created
when it doesn't exist.
Once the application is configured and the table is created, you can use sessions with any other session
provider.
Options Specified in context.xml
Below are the configuration attributes that you can use in the Manager element of your context.xml
file:
AwsAccessKey – Access key ID to use.
AwsSecretKey – Secret key to use.
AwsCredentialsFile – A properties file containing accessKey and secretKey properties with your
AWS security credentials.
Table – Optional string attribute. The name of the table used to store session data. The default is
Tomcat_SessionState.
RegionId – Optional string attribute.The AWS region in which to use DynamoDB. For a list of available
AWS regions, see Regions and Endpoints in the AWS General Reference.
Endpoint – Optional string attribute; if present, this option overrides any value set for the Region
option. The regional endpoint of the DynamoDB service to use. For a list of available AWS regions,
see Regions and Endpoints in the AWS General Reference.
ReadCapacityUnits – Optional int attribute.The read capacity units to use if the session manager
creates the table. The default is 10.
WriteCapacityUnits – Optional int attribute.The write capacity units to use if the session manager
creates the table. The default is 5.
CreateIfNotExist – Optional Boolean attribute.The CreateIfNotExist attribute controls whether
the session manager autocreates the table if it doesn't exist. The default is true. If this flag is set to
false and the table doesn't exist, an exception is thrown during Tomcat startup.
Version v1.0.0
25
AWS SDK for Java Developer Guide
Manage Tomcat Session State with DynamoDB