AWS DynamoDB Plugin
The plugin provides functionality to interact with Amazon DynamoDB.
Installation
-
Copy the below line to
dependencies
section of the projectbuild.gradle
fileExample 1. build.gradleimplementation(group: 'org.vividus', name: 'vividus-plugin-aws-dynamodb', version: '0.5.11')
-
If the project was imported to the IDE before adding new dependency, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.
Configuration
Authentication
The plugin attempts to find AWS credentials by using the default credential provider chain. The provider chain looks for credentials using the provided below options one by one starting from the top. If credentials are found at some point, the search stops and further options are not evaluated.
-
The AWS credentials scoped to either current scenario or story (configured via the corresponding step).
-
Environment variables:
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
(the optional variable for session token isAWS_SESSION_TOKEN
). -
The properties:
system.aws.accessKeyId
andsystem.aws.secretKey
(the optional property for session token issystem.aws.sessionToken
). -
Web Identity Token credentials from the environment or container.
-
In the default credentials file (the location of this file varies by platform).
-
Credentials delivered through the Amazon EC2 container service if the
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
environment variable is set and security manager has permission to access the variable. -
In the instance profile credentials, which exist within the instance metadata associated with the IAM role for the EC2 instance. This step is available only when running your application on an Amazon EC2 instance, but provides the greatest ease of use and best security when working with Amazon EC2 instances.
-
If the plugin still hasn’t found credentials by this point, client creation fails with an exception.
See the official "Working with AWS Credentials" guide to get more details.
Region Selection
The plugin attempts to find AWS region by using the default region provider chain. The provider chain looks for a region using the provided below options one by one starting from the top. If region is found at some point, the search stops and further options are not evaluated.
-
Environment variable:
AWS_REGION
. -
The property:
system.aws.region
. -
AWS shared configuration file (usually located at
~/.aws/config
). -
Use the Amazon EC2 instance metadata service to determine the region of the currently running Amazon EC2 instance.
-
If the plugin still hasn’t found a region by this point, client creation fails with an exception.
See the official "AWS Region Selection" guide to get more details.
Cross-account Access
Cross-account access is achieved by switching roles. Use the following property to specify the Amazon Resource Name (ARN) of the role to assume:
aws.dynamodb.role-arn=
The property is empty by default: no role is assumed.
Steps
Querying Data
Execute PartiQL SELECT
statement and save the result as JSON to the specified variable.
When I execute query `$partiqlQuery` against DynamoDB and save result as JSON to $scopes variable `$variableName`
-
$partiqlQuery
- The PartiQL (A SQL-Compatible Query Language for Amazon DynamoDB) query representing theSELECT
statement to execute. -
$variableName
- The variable name to store results in JSON format.
When I execute query `
SELECT * FROM Music
WHERE Artist='Roxette' and SongTitle='The Look'
` against DynamoDB and save result as JSON to scenario variable `song`
Then JSON element from `${song}` by JSON path `$` is equal to `
{
"Artist": "Roxette",
"SongTitle": "The Look"
}`
Manipulating Data
Execute PartiQL INSERT
, UPDATE
, DELETE
statements.
When I execute query `$partiqlQuery` against DynamoDB
-
$partiqlQuery
- The PartiQL (A SQL-Compatible Query Language for Amazon DynamoDB) query representing theINSERT
,UPDATE
orDELETE
statement to execute.
When I execute query `
INSERT INTO Music
value {'Artist':'Roxette','SongTitle':'The Look'}
` against DynamoDB
When I execute query `
UPDATE Music
SET AwardsWon=1
SET AwardDetail={'Grammis':[1989, 1990]}
WHERE Artist='Roxette' and SongTitle='The Look'
` against DynamoDB
When I execute query `
DELETE FROM Music
WHERE Artist='Roxette' and SongTitle='The Look'
` against DynamoDB