Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .changeset/docs-readme-data-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
"@aws-cdk-blocks/bb-kv-store": patch
"@aws-cdk-blocks/bb-database": patch
"@aws-cdk-blocks/bb-file-bucket": patch
"@aws-cdk-blocks/bb-app-setting": patch
"@aws-cdk-blocks/bb-secret": patch
"aws-cdk-blocks": patch
---

docs: correct the data blocks' error tables, explain concurrent counters in `KVStore`, and document how to import an existing `AppSetting` and set the value of a `secret: true` setting.

**`KVStore`**

- Corrected: for a transaction the README named two packages that do not exist; it names `transaction()` on `Database`.
- Added: there is no atomic increment. The conditional-writes section gives two ways to keep a concurrent counter: a `get()` and conditional `put()` loop (`ifNotExists: true` for a new item, otherwise `ifValueEquals` or `ifFieldEquals`, retry on `KVStoreErrors.ConditionalCheckFailed`, no expiry on the counter), or one item per event aggregated with `query()`.
- Added: a `Default` column in the options table. The errors table follows the options, and `scan` has its own section.
- Removed: "Best practices" and "Scaling and cost (AWS)" items that repeated earlier sections.

**`Database`**

- Corrected: the errors table lists each `DatabaseErrors` constant with the `error.name` the caller sees (`QueryFailedException`, not `QueryFailed`).
- Added: a table of the `transaction()` options (`retryOnConflict`, `maxRetries`, `signal`), `Default` columns in the options tables, and a second table for the four errors that are not for `catch`.
- Moved: `npm run db` is documented once, in `## Command line`, which says which commands apply to a block that provisions its cluster and which to an existing database, and that a command with `--block` refuses `--name`. The steps to move or rename a block are their own section. "Migrations" has one subsection per target. `## Local mode` is now `## Local development`.

**`FileBucket`**

- Corrected: no method throws `FileBucketErrors.FileNotFound` or `FileBucketErrors.FileTooLarge`. `get()` returns `null` for a missing file, and an upload over `maxUploadBytes` throws `ValidationFailed`, which has no `FileBucketErrors` constant and is matched with `isBlocksError(e, 'ValidationFailed')`.
- Corrected: the method table says when to return a download or upload handle and when a raw presigned URL; two bullets gave opposite advice.
- Added: a quick start, the `FileBucket.fromKmsKey(keyArn)` row, tables for `FileContent`, `FileInfo`, `FileDownloadClient` and `FileUploadClient`, a `Default` column in the options table, and a `## Scaling and cost (AWS)` section: an upload is one `PutObject` request, with no multipart upload.
- Removed: the "Best Practices" list, the Batch Delete example, and the on-disk layout of the local mock (it is in `DESIGN.md`).

**`AppSetting`**

- Corrected: `value` is required unless `secret: true`. A missing parameter throws `ParameterNotFound` on AWS only; an empty `secret: true` value throws on AWS and locally. The block skips its own size check for secrets; Parameter Store still enforces its tier's limit.
- Added: `AppSetting.fromExisting` does not create the parameter or grant write access. The mock permits `put()`; on AWS, it can overwrite the parameter if another policy allows the write. For an imported SecureString, the external owner manages re-encryption.
- Added: a section on `secret: true`: the first deploy stores a random value; set the real one with `put()` or in the console; `get()` parses the stored text as JSON, so a console value such as `12345` comes back as a number.

**`Secret`**

- Corrected: `SecretErrors.NotSupported` is also thrown by a deployed `Secret` that has no registered secret ARN, not only in browser code.
- Corrected: `put()` clears the cache of the instance that calls it only; other running instances read the new value once their cache entry expires (`cacheTtlSeconds`).
- Added: one errors table, a `Default` column in the options table, a quick start, and a separate `## What it provisions (AWS)` section.
4 changes: 2 additions & 2 deletions docs/guides/upgrading-older-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ Keep the old table with `LegacyKVStore`, and migrate its items to a `KVStore` wi
const prefs = new KVStore<Prefs>(scope, 'prefs-v2');
```

Deploy. The deploy goes through: it creates the table of `prefs-v2` and doesn't change the old one. `LegacyKVStore` has the `get`, `put`, `delete`, and `scan` of release 0.4.0, so code that still calls the old store keeps working.
Deploy. The deploy goes through: it creates the table of `prefs-v2` and doesn't change the old one. `LegacyKVStore` has the `get`, `put`, `delete`, and `scan` of release 0.4.0. Its `scan` adds `limit`, `cursor`, and expiry metadata; its `get` defaults to a strongly consistent read at twice the read capacity. Pass `{ consistentRead: false }` to keep eventually consistent reads.

2. Migrate the data however is appropriate for your app. `LegacyKVStore` does not copy the items. The [`KVStore` README](../../packages/bb-kv-store/README.md#upgrade-from-release-040-or-earlier) lists the tools for a copy and steps that are suitable for some migrations.
2. Migrate the data however is appropriate for your app. `LegacyKVStore` does not copy the items. The [`KVStore` README](../../packages/bb-kv-store/README.md#step-2-migrate-the-data) describes one way to migrate while the app stays live and explains its limits.

3. When the data is in the new store, remove the `LegacyKVStore` line and any read of the old store, and deploy. The old table leaves the stack. A table with a removal policy of `destroy` is deleted. A retained table, which is the default of the production preset, stays in your account until you delete it.

Expand Down
2 changes: 1 addition & 1 deletion packages/bb-app-setting/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The 4 KB (4096 bytes) size limit applies to the **JSON-encoded** value of non-se

## Mock Implementation

- Data stored in the shared `.cdk-blocks/local/data/settings.json`, keyed by `scope.fullId`.
- Values share `.cdk-blocks/local/data/settings.json`, keyed by the setting's `fullId`.
- Data persists across dev server restarts. Customers can wipe with `rm -rf .cdk-blocks/local/data .bb-data`.
- `get()` returns the stored value from disk, or the initial `value` from constructor if no file exists.
- `put()` writes the value to disk immediately.
Expand Down
Loading
Loading