Skip to content

Commit 8953a83

Browse files
committed
revamp qldb
1 parent 37da027 commit 8953a83

File tree

1 file changed

+52
-34
lines changed
  • src/content/docs/aws/services

1 file changed

+52
-34
lines changed

src/content/docs/aws/services/qldb.md

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ tags: ["Ultimate"]
55
description: Get started with Quantum Ledger Database (QLDB) on LocalStack
66
---
77

8-
{{< callout "warning" >}}
8+
:::danger
99
Amazon QLDB will be [retired on 31 July 2025](https://docs.aws.amazon.com/qldb/latest/developerguide/what-is.html).
1010
It will be removed from LocalStack soon after this date.
11-
{{< /callout >}}
11+
:::
1212

1313
## Introduction
1414

@@ -22,7 +22,7 @@ and scalable
2222
way to maintain a complete and verifiable history of data changes over time.
2323

2424
LocalStack allows you to use the QLDB APIs in your local environment to create and manage ledgers.
25-
The supported APIs are available on the [API coverage page]({{< ref "/references/coverage/coverage_qldb/index.md" >}} "QLDB service coverage page"), which provides information on the extent of QLDB's integration with LocalStack.
25+
The supported APIs are available on the [API coverage page](), which provides information on the extent of QLDB's integration with LocalStack.
2626

2727
## Getting started
2828

@@ -54,9 +54,11 @@ the [Releases](https://github.com/awslabs/amazon-qldb-shell/releases) section of
5454
QLDB provides ledger databases, which are centralized, immutable, and cryptographically verifiable
5555
journals of transactions.
5656

57-
{{< command >}}
58-
$ awslocal qldb create-ledger --name vehicle-registration --permissions-mode ALLOW_ALL
59-
{{< / command >}}
57+
```bash
58+
awslocal qldb create-ledger --name vehicle-registration --permissions-mode ALLOW_ALL
59+
```
60+
61+
The output will be similar to the following:
6062

6163
```bash
6264
{
@@ -69,7 +71,7 @@ $ awslocal qldb create-ledger --name vehicle-registration --permissions-mode ALL
6971
}
7072
```
7173

72-
{{< callout >}}
74+
:::note
7375

7476
- Permissions mode – the following options are available in AWS:
7577

@@ -89,13 +91,13 @@ To allow PartiQL
8991
commands, you must create IAM permissions policies for specific table resources and PartiQL actions,
9092
in addition to
9193
the `SendCommand` API permission for the ledger.
92-
{{< /callout >}}
94+
:::
9395

9496
The following command can be used directly to write PartiQL statements against a QLDB ledger:
9597

96-
{{< command >}}
97-
$ qldb --qldb-session-endpoint http://localhost:4566 --ledger vehicle-registration
98-
{{< / command >}}
98+
```bash
99+
qldb --qldb-session-endpoint http://localhost:4566 --ledger vehicle-registration
100+
```
99101

100102
The user can continue from here to create tables, populate and interrogate them.
101103

@@ -104,9 +106,11 @@ The user can continue from here to create tables, populate and interrogate them.
104106
PartiQL is a query language designed for processing structured data, allowing you to perform
105107
various data manipulation tasks using familiar SQL-like syntax.
106108

107-
{{< command >}}
109+
```bash
108110
qldb> CREATE TABLE VehicleRegistration
109-
{{< / command >}}
111+
```
112+
113+
The output will be:
110114

111115
```bash
112116
{
@@ -131,7 +135,7 @@ qldb> CREATE TABLE VehicleRegistration
131135
The `VehicleRegistration` table was created.
132136
Now it's time to add some items:
133137

134-
{{< command >}}
138+
```bash
135139
qldb> INSERT INTO VehicleRegistration VALUE
136140
{
137141
'VIN' : 'KM8SRDHF6EU074761',
@@ -149,7 +153,9 @@ qldb> INSERT INTO VehicleRegistration VALUE
149153
'ValidFromDate' : `2017-09-14T`,
150154
'ValidToDate' : `2020-06-25T`
151155
}
152-
{{< / command >}}
156+
```
157+
158+
The output will be:
153159
154160
```bash
155161
{
@@ -162,9 +168,11 @@ documentId: "3TYR9BamzyqHWBjYOfHegE"
162168
163169
The table can be interrogated based on the inserted registration number:
164170
165-
{{< command >}}
171+
```bash
166172
qldb> SELECT * FROM VehicleRegistration WHERE RegNum=1722
167-
{{< / command >}}
173+
```
174+
175+
The output will be:
168176
169177
```bash
170178
{
@@ -193,9 +201,10 @@ queries.
193201
Supposed the vehicle is sold and changes owners, this information needs to be updated with a new
194202
person ID.
195203
196-
{{< command >}}
204+
```bash
197205
qldb> UPDATE VehicleRegistration AS r SET r.Owners.PrimaryOwner.PersonId = '112233445566NO' WHERE r.VIN = 'KM8SRDHF6EU074761'
198-
{{< / command >}}
206+
```
207+
199208
The command will return the updated document ID.
200209
201210
```bash
@@ -206,9 +215,12 @@ The command will return the updated document ID.
206215
```
207216
208217
The next step is to check on the updates made to the `PersonId` field of the `PrimaryOwner`:
209-
{{< command >}}
218+
219+
```bash
210220
qldb> SELECT r.Owners FROM VehicleRegistration AS r WHERE r.VIN = 'KM8SRDHF6EU074761'
211-
{{< / command >}}
221+
```
222+
223+
The output will be:
212224
213225
```bash
214226
{
@@ -236,9 +248,11 @@ You can see all revisions of a document that you inserted, updated, and deleted
236248
built-in History function.
237249
First the unique `id` of the document must be found.
238250
239-
{{< command >}}
251+
```bash
240252
qldb> SELECT r_id FROM VehicleRegistration AS r BY r_id WHERE r.VIN = 'KM8SRDHF6EU074761'
241-
{{< / command >}}
253+
```
254+
255+
The output will be:
242256
243257
```bash
244258
{
@@ -250,9 +264,11 @@ r_id: "3TYR9BamzyqHWBjYOfHegE"
250264
251265
Then, the `id` is used to query the history function.
252266
253-
{{< command >}}
267+
```bash
254268
qldb> SELECT h.data.VIN, h.data.City, h.data.Owners FROM history(VehicleRegistration) AS h WHERE h.metadata.id = '3TYR9BamzyqHWBjYOfHegE'
255-
{{< / command >}}
269+
```
270+
271+
The output will be:
256272
257273
```bash
258274
{
@@ -298,9 +314,11 @@ Unused ledgers can be deleted.
298314
You'll notice that directly running the following command will lead
299315
to an error message.
300316
301-
{{< command >}}
302-
$ awslocal qldb delete-ledger --name vehicle-registration
303-
{{< / command >}}
317+
```bash
318+
awslocal qldb delete-ledger --name vehicle-registration
319+
```
320+
321+
The output will be:
304322
305323
```bash
306324
An error occurred (ResourcePreconditionNotMetException) when calling the DeleteLedger operation: Preventing deletion
@@ -309,9 +327,11 @@ of ledger vehicle-registration with DeletionProtection enabled
309327
310328
This can be adjusted using the `update-ledger` command in the AWS CLI to remove the deletion protection of the ledger:
311329
312-
{{< command >}}
313-
$ awslocal qldb update-ledger --name vehicle-registration --no-deletion-protection
314-
{{< / command >}}
330+
```bash
331+
awslocal qldb update-ledger --name vehicle-registration --no-deletion-protection
332+
```
333+
334+
The output will be:
315335
316336
```bash
317337
{
@@ -330,9 +350,7 @@ Now the `delete-ledger` command can be repeated without errors.
330350
The LocalStack Web Application provides a Resource Browser for managing QLDB ledgers.
331351
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **QLDB** under the **Database** section.
332352
333-
<img src="qldb-resource-browser.png" alt="QLDB Resource Browser" title="QLDB Resource Browser" width="900" />
334-
<br>
335-
<br>
353+
![QLDB Resource Browser](/images/aws/qldb-resource-browser.png)
336354
337355
The Resource Browser allows you to perform the following actions:
338356

0 commit comments

Comments
 (0)