# DynamoDB

> Seed DynamoDB tables and check the items your services write.

Source: https://axx.nimbusxr.us/references/steps/aws-dynamodb/

Seed DynamoDB tables and check the items your services write.

The steps use the scenario's AWS account (`the {word} aws account with the following properties:`, from aws-core).

A **seed** is a YAML or JSON file that maps table names to the items to put, written as plain JSON (numbers become `N`, objects `M`, arrays `L`):

```yaml
insured-parcels:
  - reference: PX-CLM-1001
    declaredValue: 120
    carrier: KESTREL
```

**Checks** wait (10 seconds unless `within {duration}` says otherwise) until the table has an item, or a number of items, meeting every condition: `attribute | value` rows with a dotted path into maps (`address.city`), compared as text, `null` for null and `undefined` for absent. Items are read with a scan, which suits the small tables of a test environment.

## `aws-dynamodb.seed`

```gherkin
Given a {filepath} dynamodb seed
```

Put the items of a seed file (resolved against `resources`): YAML or JSON mapping table names to lists of items.

**Parameters:** `{filepath}` (A file of the project, without whitespace: a path relative to the `resources` directories or to the directory of axx.yaml, or an absolute path. Editors link it to the file)

**Example:**

```gherkin
Given a seeds/insured-parcels.yaml dynamodb seed
```

_Since 0.1.0._

## `aws-dynamodb.item`

```gherkin
Then [[within {duration} ]]the {word} dynamodb table has an item where:
  | ... | ... |
```

Wait (10s, or the given time) until the table has an item meeting every `attribute | value` row.

**Variants** (optional parts in `[[...]]` above):

- `the {word} dynamodb table has an item where:`
- `within {duration} the {word} dynamodb table has an item where:`

**Parameters:** `{duration}` (A duration in seconds or minutes, e.g. `5s` or `2m`), `{word}` (one word, no spaces)

**Example:**

```gherkin
Then within 30s the claims dynamodb table has an item where:
```

_Since 0.1.0._

## `aws-dynamodb.items`

```gherkin
Then [[within {duration} ]]the {word} dynamodb table has {int} item(s) where:
  | ... | ... |
```

Wait (10s, or the given time) until exactly that many items of the table meet every `attribute | value` row.

**Variants** (optional parts in `[[...]]` above):

- `the {word} dynamodb table has {int} item(s) where:`
- `within {duration} the {word} dynamodb table has {int} item(s) where:`

**Parameters:** `{duration}` (A duration in seconds or minutes, e.g. `5s` or `2m`), `{word}` (one word, no spaces), `{int}` (a 32-bit integer)

**Example:**

```gherkin
Then the claims dynamodb table has 1 item where:
```

_Since 0.1.0._
