This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
QLDB examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with QLDB.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use cancel-journal-kinesis-stream
.
- Amazon CLI
-
To cancel a journal stream
The following
cancel-journal-kinesis-stream
example cancels the specified journal stream from a ledger.aws qldb cancel-journal-kinesis-stream \ --ledger-name
myExampleLedger
\ --stream-id7ISCkqwe4y25YyHLzYUFAf
Output:
{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }
For more information, see Streaming journal data from Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see CancelJournalKinesisStream
in Amazon CLI Command Reference.
-
The following code example shows how to use create-ledger
.
- Amazon CLI
-
Example 1: To create a ledger with default properties
The following
create-ledger
example creates a ledger with the namemyExampleLedger
and the permissions modeSTANDARD
. The optional parameters for deletion protection and Amazon KMS key are not specified, so they default totrue
and an Amazon owned KMS key respectively.aws qldb create-ledger \ --name
myExampleLedger
\ --permissions-modeSTANDARD
Output:
{ "State": "CREATING", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": true, "CreationDateTime": 1568839243.951, "Name": "myExampleLedger", "PermissionsMode": "STANDARD" }
Example 2: To create a ledger with deletion protection disabled, a customer managed KMS key, and specified tags
The following
create-ledger
example creates a ledger with the namemyExampleLedger2
and the permissions modeSTANDARD
. The deletion protection feature is disabled, the specified customer managed KMS key is used for encryption at rest, and the specified tags are attached to the resource.aws qldb create-ledger \ --name
myExampleLedger2
\ --permissions-modeSTANDARD
\ --no-deletion-protection \ --kms-keyarn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
\ --tagsIsTest=true,Domain=Test
Output:
{ "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger2", "DeletionProtection": false, "CreationDateTime": 1568839543.557, "State": "CREATING", "Name": "myExampleLedger2", "PermissionsMode": "STANDARD", "KmsKeyArn": "arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see CreateLedger
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-ledger
.
- Amazon CLI
-
To delete a ledger
The following
delete-ledger
example deletes the specified ledger.aws qldb delete-ledger \ --name
myExampleLedger
This command produces no output.
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see DeleteLedger
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-journal-kinesis-stream
.
- Amazon CLI
-
To describe a journal stream
The following
describe-journal-kinesis-stream
example displays the details for the specified journal stream from a ledger.aws qldb describe-journal-kinesis-stream \ --ledger-name
myExampleLedger
\ --stream-id7ISCkqwe4y25YyHLzYUFAf
Output:
{ "Stream": { "LedgerName": "myExampleLedger", "CreationTime": 1591221984.677, "InclusiveStartTime": 1590710400.0, "ExclusiveEndTime": 1590796799.0, "RoleArn": "arn:aws:iam::123456789012:role/my-kinesis-stream-role", "StreamId": "7ISCkqwe4y25YyHLzYUFAf", "Arn": "arn:aws:qldb:us-east-1:123456789012:stream/myExampleLedger/7ISCkqwe4y25YyHLzYUFAf", "Status": "ACTIVE", "KinesisConfiguration": { "StreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb", "AggregationEnabled": true }, "StreamName": "myExampleLedger-stream" } }
For more information, see Streaming journal data from Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see DescribeJournalKinesisStream
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-journal-s3-export
.
- Amazon CLI
-
To describe a journal export job
The following
describe-journal-s3-export
example displays the details for the specified export job from a ledger.aws qldb describe-journal-s3-export \ --name
myExampleLedger
\ --export-idADR2ONPKN5LINYGb4dp7yZ
Output:
{ "ExportDescription": { "S3ExportConfiguration": { "Bucket": "awsExampleBucket", "Prefix": "ledgerexport1/", "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" } }, "RoleArn": "arn:aws:iam::123456789012:role/my-s3-export-role", "Status": "COMPLETED", "ExportCreationTime": 1568847801.418, "InclusiveStartTime": 1568764800.0, "ExclusiveEndTime": 1568847599.0, "LedgerName": "myExampleLedger", "ExportId": "ADR2ONPKN5LINYGb4dp7yZ" } }
For more information, see Exporting Your Journal in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see DescribeJournalS3Export
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-ledger
.
- Amazon CLI
-
To describe a ledger
The following
describe-ledger
example displays the details for the specified ledger.aws qldb describe-ledger \ --name
myExampleLedger
Output:
{ "CreationDateTime": 1568839243.951, "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "State": "ACTIVE", "Name": "myExampleLedger", "DeletionProtection": true, "PermissionsMode": "STANDARD", "EncryptionDescription": { "KmsKeyArn": "arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "EncryptionStatus": "ENABLED" } }
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see DescribeLedger
in Amazon CLI Command Reference.
-
The following code example shows how to use export-journal-to-s3
.
- Amazon CLI
-
To export journal blocks to S3
The following
export-journal-to-s3
example creates an export job for journal blocks within a specified date and time range from a ledger with the namemyExampleLedger
. The export job writes the blocks into a specified Amazon S3 bucket.aws qldb export-journal-to-s3 \ --name
myExampleLedger
\ --inclusive-start-time2019-09-18T00:00:00Z
\ --exclusive-end-time2019-09-18T22:59:59Z
\ --role-arnarn:aws:iam::123456789012:role/my-s3-export-role
\ --s3-export-configurationfile://my-s3-export-config.json
Contents of
my-s3-export-config.json
:{ "Bucket": "awsExampleBucket", "Prefix": "ledgerexport1/", "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" } }
Output:
{ "ExportId": "ADR2ONPKN5LINYGb4dp7yZ" }
For more information, see Exporting Your Journal in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see ExportJournalToS3
in Amazon CLI Command Reference.
-
The following code example shows how to use get-block
.
- Amazon CLI
-
Example 1: To get a journal block and proof for verification using input files
The following
get-block
example requests a block data object and a proof from the specified ledger. The request is for a specified digest tip address and block address.aws qldb get-block \ --name
vehicle-registration
\ --block-addressfile://myblockaddress.json
\ --digest-tip-addressfile://mydigesttipaddress.json
Contents of
myblockaddress.json
:{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}" }
Contents of
mydigesttipaddress.json
:{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}" }
Output:
{ "Block": { "IonText": "{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},transactionId:\"FnQeJBAicTX0Ah32ZnVtSX\",blockTimestamp:2019-09-16T19:37:05.360Z,blockHash:{{NoChM92yKRuJAb/jeLd1VnYn4DHiWIf071ACfic9uHc=}},entriesHash:{{l05LOsiKV14SDbuaYnH7uwXzUvqzIwUiRLXGbTyj/nY=}},previousBlockHash:{{7kewBXhpdbClcZKxhVmpoMHpUGOJtWQD0iY2LPfZkYA=}},entriesHashList:[{{eRSwnmAM7WWANWDd5iGOyK+T4tDXyzUq6HZ/0fgLHos=}},{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},{{y5cCBr7pOAIUfsVQ1j0TqtE97b4b4oo1R0vnYyE5wWM=}},{{TvTXygML1bMe6NvEZtGkX+KR+W/EJl4qD1mmV77KZQg=}}],transactionInfo:{statements:[{statement:\"FROM VehicleRegistration AS r \\nWHERE r.VIN = '1N4AL11D75C109151'\\nINSERT INTO r.Owners.SecondaryOwners\\n VALUE { 'PersonId' : 'CMVdR77XP8zAglmmFDGTvt' }\",startTime:2019-09-16T19:37:05.302Z,statementDigest:{{jcgPX2vsOJ0waum4qmDYtn1pCAT9xKNIzA+2k4R+mxA=}}}],documents:{JUJgkIcNbhS2goq8RqLuZ4:{tableName:\"VehicleRegistration\",tableId:\"BFJKdXgzt9oF4wjMbuxy4G\",statements:[0]}}},revisions:[{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},hash:{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},data:{VIN:\"1N4AL11D75C109151\",LicensePlateNumber:\"LEWISR261LL\",State:\"WA\",PendingPenaltyTicketAmount:90.25,ValidFromDate:2017-08-21,ValidToDate:2020-05-11,Owners:{PrimaryOwner:{PersonId:\"BFJKdXhnLRT27sXBnojNGW\"},SecondaryOwners:[{PersonId:\"CMVdR77XP8zAglmmFDGTvt\"}]},City:\"Everett\"},metadata:{id:\"JUJgkIcNbhS2goq8RqLuZ4\",version:3,txTime:2019-09-16T19:37:05.344Z,txId:\"FnQeJBAicTX0Ah32ZnVtSX\"}}]}" }, "Proof": { "IonText": "[{{l3+EXs69K1+rehlqyWLkt+oHDlw4Zi9pCLW/t/mgTPM=}},{{48CXG3ehPqsxCYd34EEa8Fso0ORpWWAO8010RJKf3Do=}},{{9UnwnKSQT0i3ge1JMVa+tMIqCEDaOPTkWxmyHSn8UPQ=}},{{3nW6Vryghk+7pd6wFCtLufgPM6qXHyTNeCb1sCwcDaI=}},{{Irb5fNhBrNEQ1VPhzlnGT/ZQPadSmgfdtMYcwkNOxoI=}},{{+3CWpYG/ytf/vq9GidpzSx6JJiLXt1hMQWNnqOy3jfY=}},{{NPx6cRhwsiy5m9UEWS5JTJrZoUdO2jBOAAOmyZAT+qE=}}]" } }
For more information, see Data Verification in Amazon QLDB
in the Amazon QLDB Developer Guide. Example 2: To get a journal block and proof for verification using shorthand syntax
The following
get-block
example requests a block data object and a proof from the specified ledger using shorthand syntax. The request is for a specified digest tip address and block address.aws qldb get-block \ --name
vehicle-registration
\ --block-address 'IonText="{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}"
' \ --digest-tip-address 'IonText="{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}"
'Output:
{ "Block": { "IonText": "{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},transactionId:\"FnQeJBAicTX0Ah32ZnVtSX\",blockTimestamp:2019-09-16T19:37:05.360Z,blockHash:{{NoChM92yKRuJAb/jeLd1VnYn4DHiWIf071ACfic9uHc=}},entriesHash:{{l05LOsiKV14SDbuaYnH7uwXzUvqzIwUiRLXGbTyj/nY=}},previousBlockHash:{{7kewBXhpdbClcZKxhVmpoMHpUGOJtWQD0iY2LPfZkYA=}},entriesHashList:[{{eRSwnmAM7WWANWDd5iGOyK+T4tDXyzUq6HZ/0fgLHos=}},{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},{{y5cCBr7pOAIUfsVQ1j0TqtE97b4b4oo1R0vnYyE5wWM=}},{{TvTXygML1bMe6NvEZtGkX+KR+W/EJl4qD1mmV77KZQg=}}],transactionInfo:{statements:[{statement:\"FROM VehicleRegistration AS r \\nWHERE r.VIN = '1N4AL11D75C109151'\\nINSERT INTO r.Owners.SecondaryOwners\\n VALUE { 'PersonId' : 'CMVdR77XP8zAglmmFDGTvt' }\",startTime:2019-09-16T19:37:05.302Z,statementDigest:{{jcgPX2vsOJ0waum4qmDYtn1pCAT9xKNIzA+2k4R+mxA=}}}],documents:{JUJgkIcNbhS2goq8RqLuZ4:{tableName:\"VehicleRegistration\",tableId:\"BFJKdXgzt9oF4wjMbuxy4G\",statements:[0]}}},revisions:[{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},hash:{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},data:{VIN:\"1N4AL11D75C109151\",LicensePlateNumber:\"LEWISR261LL\",State:\"WA\",PendingPenaltyTicketAmount:90.25,ValidFromDate:2017-08-21,ValidToDate:2020-05-11,Owners:{PrimaryOwner:{PersonId:\"BFJKdXhnLRT27sXBnojNGW\"},SecondaryOwners:[{PersonId:\"CMVdR77XP8zAglmmFDGTvt\"}]},City:\"Everett\"},metadata:{id:\"JUJgkIcNbhS2goq8RqLuZ4\",version:3,txTime:2019-09-16T19:37:05.344Z,txId:\"FnQeJBAicTX0Ah32ZnVtSX\"}}]}" }, "Proof": { "IonText": "[{{l3+EXs69K1+rehlqyWLkt+oHDlw4Zi9pCLW/t/mgTPM=}},{{48CXG3ehPqsxCYd34EEa8Fso0ORpWWAO8010RJKf3Do=}},{{9UnwnKSQT0i3ge1JMVa+tMIqCEDaOPTkWxmyHSn8UPQ=}},{{3nW6Vryghk+7pd6wFCtLufgPM6qXHyTNeCb1sCwcDaI=}},{{Irb5fNhBrNEQ1VPhzlnGT/ZQPadSmgfdtMYcwkNOxoI=}},{{+3CWpYG/ytf/vq9GidpzSx6JJiLXt1hMQWNnqOy3jfY=}},{{NPx6cRhwsiy5m9UEWS5JTJrZoUdO2jBOAAOmyZAT+qE=}}]" } }
For more information, see Data Verification in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see GetBlock
in Amazon CLI Command Reference.
-
The following code example shows how to use get-digest
.
- Amazon CLI
-
To get a digest for a ledger
The following
get-digest
example requests a digest from the specified ledger at the latest committed block in the journal.aws qldb get-digest \ --name
vehicle-registration
Output:
{ "Digest": "6m6BMXobbJKpMhahwVthAEsN6awgnHK62Qq5McGP1Gk=", "DigestTipAddress": { "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}" } }
For more information, see Data Verification in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see GetDigest
in Amazon CLI Command Reference.
-
The following code example shows how to use get-revision
.
- Amazon CLI
-
Example 1: To get a document revision and proof for verification using input files
The following
get-revision
example requests a revision data object and a proof from the specified ledger. The request is for a specified digest tip address, document ID, and block address of the revision.aws qldb get-revision \ --name
vehicle-registration
\ --block-addressfile://myblockaddress.json
\ --document-idJUJgkIcNbhS2goq8RqLuZ4
\ --digest-tip-addressfile://mydigesttipaddress.json
Contents of
myblockaddress.json
:{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}" }
Contents of
mydigesttipaddress.json
:{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}" }
Output:
{ "Revision": { "IonText": "{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},hash:{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},data:{VIN:\"1N4AL11D75C109151\",LicensePlateNumber:\"LEWISR261LL\",State:\"WA\",PendingPenaltyTicketAmount:90.25,ValidFromDate:2017-08-21,ValidToDate:2020-05-11,Owners:{PrimaryOwner:{PersonId:\"BFJKdXhnLRT27sXBnojNGW\"},SecondaryOwners:[{PersonId:\"CMVdR77XP8zAglmmFDGTvt\"}]},City:\"Everett\"},metadata:{id:\"JUJgkIcNbhS2goq8RqLuZ4\",version:3,txTime:2019-09-16T19:37:05.344Z,txId:\"FnQeJBAicTX0Ah32ZnVtSX\"}}" }, "Proof": { "IonText": "[{{eRSwnmAM7WWANWDd5iGOyK+T4tDXyzUq6HZ/0fgLHos=}},{{VV1rdaNuf+yJZVGlmsM6gr2T52QvBO8Lg+KgpjcnWAU=}},{{7kewBXhpdbClcZKxhVmpoMHpUGOJtWQD0iY2LPfZkYA=}},{{l3+EXs69K1+rehlqyWLkt+oHDlw4Zi9pCLW/t/mgTPM=}},{{48CXG3ehPqsxCYd34EEa8Fso0ORpWWAO8010RJKf3Do=}},{{9UnwnKSQT0i3ge1JMVa+tMIqCEDaOPTkWxmyHSn8UPQ=}},{{3nW6Vryghk+7pd6wFCtLufgPM6qXHyTNeCb1sCwcDaI=}},{{Irb5fNhBrNEQ1VPhzlnGT/ZQPadSmgfdtMYcwkNOxoI=}},{{+3CWpYG/ytf/vq9GidpzSx6JJiLXt1hMQWNnqOy3jfY=}},{{NPx6cRhwsiy5m9UEWS5JTJrZoUdO2jBOAAOmyZAT+qE=}}]" } }
For more information, see Data Verification in Amazon QLDB
in the Amazon QLDB Developer Guide. Example 2: To get a document revision and proof for verification using shorthand syntax
The following
get-revision
example requests a revision data object and a proof from the specified ledger using shorthand syntax. The request is for a specified digest tip address, document ID, and block address of the revision.aws qldb get-revision \ --name
vehicle-registration
\ --block-address 'IonText="{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}"
' \ --document-idJUJgkIcNbhS2goq8RqLuZ4
\ --digest-tip-address 'IonText="{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}"
'Output:
{ "Revision": { "IonText": "{blockAddress:{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100},hash:{{mHVex/yjHAWjFPpwhBuH2GKXmKJjK2FBa9faqoUVNtg=}},data:{VIN:\"1N4AL11D75C109151\",LicensePlateNumber:\"LEWISR261LL\",State:\"WA\",PendingPenaltyTicketAmount:90.25,ValidFromDate:2017-08-21,ValidToDate:2020-05-11,Owners:{PrimaryOwner:{PersonId:\"BFJKdXhnLRT27sXBnojNGW\"},SecondaryOwners:[{PersonId:\"CMVdR77XP8zAglmmFDGTvt\"}]},City:\"Everett\"},metadata:{id:\"JUJgkIcNbhS2goq8RqLuZ4\",version:3,txTime:2019-09-16T19:37:05.344Z,txId:\"FnQeJBAicTX0Ah32ZnVtSX\"}}" }, "Proof": { "IonText": "[{{eRSwnmAM7WWANWDd5iGOyK+T4tDXyzUq6HZ/0fgLHos=}},{{VV1rdaNuf+yJZVGlmsM6gr2T52QvBO8Lg+KgpjcnWAU=}},{{7kewBXhpdbClcZKxhVmpoMHpUGOJtWQD0iY2LPfZkYA=}},{{l3+EXs69K1+rehlqyWLkt+oHDlw4Zi9pCLW/t/mgTPM=}},{{48CXG3ehPqsxCYd34EEa8Fso0ORpWWAO8010RJKf3Do=}},{{9UnwnKSQT0i3ge1JMVa+tMIqCEDaOPTkWxmyHSn8UPQ=}},{{3nW6Vryghk+7pd6wFCtLufgPM6qXHyTNeCb1sCwcDaI=}},{{Irb5fNhBrNEQ1VPhzlnGT/ZQPadSmgfdtMYcwkNOxoI=}},{{+3CWpYG/ytf/vq9GidpzSx6JJiLXt1hMQWNnqOy3jfY=}},{{NPx6cRhwsiy5m9UEWS5JTJrZoUdO2jBOAAOmyZAT+qE=}}]" } }
For more information, see Data Verification in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see GetRevision
in Amazon CLI Command Reference.
-
The following code example shows how to use list-journal-kinesis-streams-for-ledger
.
- Amazon CLI
-
To list journal streams for a ledger
The following
list-journal-kinesis-streams-for-ledger
example lists journal streams for the specified ledger.aws qldb list-journal-kinesis-streams-for-ledger \ --ledger-name
myExampleLedger
Output:
{ "Streams": [ { "LedgerName": "myExampleLedger", "CreationTime": 1591221984.677, "InclusiveStartTime": 1590710400.0, "ExclusiveEndTime": 1590796799.0, "RoleArn": "arn:aws:iam::123456789012:role/my-kinesis-stream-role", "StreamId": "7ISCkqwe4y25YyHLzYUFAf", "Arn": "arn:aws:qldb:us-east-1:123456789012:stream/myExampleLedger/7ISCkqwe4y25YyHLzYUFAf", "Status": "ACTIVE", "KinesisConfiguration": { "StreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb", "AggregationEnabled": true }, "StreamName": "myExampleLedger-stream" } ] }
For more information, see Streaming journal data from Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see ListJournalKinesisStreamsForLedger
in Amazon CLI Command Reference.
-
The following code example shows how to use list-journal-s3-exports-for-ledger
.
- Amazon CLI
-
To list journal export jobs for a ledger
The following
list-journal-s3-exports-for-ledger
example lists journal export jobs for the specified ledger.aws qldb list-journal-s3-exports-for-ledger \ --name
myExampleLedger
Output:
{ "JournalS3Exports": [ { "LedgerName": "myExampleLedger", "ExclusiveEndTime": 1568847599.0, "ExportCreationTime": 1568847801.418, "S3ExportConfiguration": { "Bucket": "awsExampleBucket", "Prefix": "ledgerexport1/", "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" } }, "ExportId": "ADR2ONPKN5LINYGb4dp7yZ", "RoleArn": "arn:aws:iam::123456789012:role/qldb-s3-export", "InclusiveStartTime": 1568764800.0, "Status": "IN_PROGRESS" } ] }
For more information, see Exporting Your Journal in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see ListJournalS3ExportsForLedger
in Amazon CLI Command Reference.
-
The following code example shows how to use list-journal-s3-exports
.
- Amazon CLI
-
To list journal export jobs
The following
list-journal-s3-exports
example lists journal export jobs for all ledgers that are associated with the current Amazon account and Region.aws qldb list-journal-s3-exports
Output:
{ "JournalS3Exports": [ { "Status": "IN_PROGRESS", "LedgerName": "myExampleLedger", "S3ExportConfiguration": { "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" }, "Bucket": "awsExampleBucket", "Prefix": "ledgerexport1/" }, "RoleArn": "arn:aws:iam::123456789012:role/my-s3-export-role", "ExportCreationTime": 1568847801.418, "ExportId": "ADR2ONPKN5LINYGb4dp7yZ", "InclusiveStartTime": 1568764800.0, "ExclusiveEndTime": 1568847599.0 }, { "Status": "COMPLETED", "LedgerName": "myExampleLedger2", "S3ExportConfiguration": { "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" }, "Bucket": "awsExampleBucket", "Prefix": "ledgerexport1/" }, "RoleArn": "arn:aws:iam::123456789012:role/my-s3-export-role", "ExportCreationTime": 1568846847.638, "ExportId": "2pdvW8UQrjBAiYTMehEJDI", "InclusiveStartTime": 1568592000.0, "ExclusiveEndTime": 1568764800.0 } ] }
For more information, see Exporting Your Journal in Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see ListJournalS3Exports
in Amazon CLI Command Reference.
-
The following code example shows how to use list-ledgers
.
- Amazon CLI
-
To list your available ledgers
The following
list-ledgers
example lists all ledgers that are associated with the current Amazon account and Region.aws qldb list-ledgers
Output:
{ "Ledgers": [ { "State": "ACTIVE", "CreationDateTime": 1568839243.951, "Name": "myExampleLedger" }, { "State": "ACTIVE", "CreationDateTime": 1568839543.557, "Name": "myExampleLedger2" } ] }
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see ListLedgers
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource
.
- Amazon CLI
-
To list the tags attached to a ledger
The following
list-tags-for-resource
example lists all tags attached to the specified ledger.aws qldb list-tags-for-resource \ --resource-arn
arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger
Output:
{ "Tags": { "IsTest": "true", "Domain": "Test" } }
For more information, see Tagging Amazon QLDB Resources
in the Amazon QLDB Developer Guide. -
For API details, see ListTagsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use stream-journal-to-kinesis
.
- Amazon CLI
-
Example 1: To stream journal data to Kinesis Data Streams using input files
The following
stream-journal-to-kinesis
example creates a stream of journal data within a specified date and time range from a ledger with the namemyExampleLedger
. The stream sends the data to a specified Amazon Kinesis data stream.aws qldb stream-journal-to-kinesis \ --ledger-name
myExampleLedger
\ --inclusive-start-time2020-05-29T00:00:00Z
\ --exclusive-end-time2020-05-29T23:59:59Z
\ --role-arnarn:aws:iam::123456789012:role/my-kinesis-stream-role
\ --kinesis-configurationfile://my-kinesis-config.json
\ --stream-namemyExampleLedger-stream
Contents of
my-kinesis-config.json
:{ "StreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb", "AggregationEnabled": true }
Output:
{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }
For more information, see Streaming journal data from Amazon QLDB
in the Amazon QLDB Developer Guide. Example 2: To stream journal data to Kinesis Data Streams using shorthand syntax
The following
stream-journal-to-kinesis
example creates a stream of journal data within a specified date and time range from a ledger with the namemyExampleLedger
. The stream sends the data to a specified Amazon Kinesis data stream.aws qldb stream-journal-to-kinesis \ --ledger-name
myExampleLedger
\ --inclusive-start-time2020-05-29T00:00:00Z
\ --exclusive-end-time2020-05-29T23:59:59Z
\ --role-arnarn:aws:iam::123456789012:role/my-kinesis-stream-role
\ --stream-namemyExampleLedger-stream
\ --kinesis-configurationStreamArn=arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb,AggregationEnabled=true
Output:
{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }
For more information, see Streaming journal data from Amazon QLDB
in the Amazon QLDB Developer Guide. -
For API details, see StreamJournalToKinesis
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-resource
.
- Amazon CLI
-
To tag a ledger
The following
tag-resource
example adds a set of tags to a specified ledger.aws qldb tag-resource \ --resource-arn
arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger
\ --tagsIsTest=true,Domain=Test
This command produces no output.
For more information, see Tagging Amazon QLDB Resources
in the Amazon QLDB Developer Guide. -
For API details, see TagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-resource
.
- Amazon CLI
-
To remove tags from a resource
The following
untag-resource
example removes tags with the specified tag keys from a specified ledger.aws qldb untag-resource \ --resource-arn
arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger
\ --tag-keysIsTest
Domain
This command produces no output.
For more information, see Tagging Amazon QLDB Resources
in the Amazon QLDB Developer Guide. -
For API details, see UntagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-ledger-permissions-mode
.
- Amazon CLI
-
Example 1: To update the permissions mode of a ledger to STANDARD
The following
update-ledger-permissions-mode
example assigns theSTANDARD
permissions mode to the specified ledger.aws qldb update-ledger-permissions-mode \ --name
myExampleLedger
\ --permissions-modeSTANDARD
Output:
{ "Name": "myExampleLedger", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "PermissionsMode": "STANDARD" }
Example 2: To update the permissions mode of a ledger to ALLOW_ALL
The following
update-ledger-permissions-mode
example assigns theALLOW_ALL
permissions mode to the specified ledger.aws qldb update-ledger-permissions-mode \ --name
myExampleLedger
\ --permissions-modeALLOW_ALL
Output:
{ "Name": "myExampleLedger", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "PermissionsMode": "ALLOW_ALL" }
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see UpdateLedgerPermissionsMode
in Amazon CLI Command Reference.
-
The following code example shows how to use update-ledger
.
- Amazon CLI
-
Example 1: To update the deletion protection property of a ledger
The following
update-ledger
example updates the specified ledger to disable the deletion protection feature.aws qldb update-ledger \ --name
myExampleLedger
\ --no-deletion-protectionOutput:
{ "CreationDateTime": 1568839243.951, "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": false, "Name": "myExampleLedger", "State": "ACTIVE" }
Example 2: To update the Amazon KMS key of a ledger to a customer managed key
The following
update-ledger
example updates the specified ledger to use a customer managed KMS key for encryption at rest.aws qldb update-ledger \ --name
myExampleLedger
\ --kms-keyarn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
Output:
{ "CreationDateTime": 1568839243.951, "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": false, "Name": "myExampleLedger", "State": "ACTIVE", "EncryptionDescription": { "KmsKeyArn": "arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "EncryptionStatus": "UPDATING" } }
Example 3: To update the Amazon KMS key of a ledger to an Amazon owned key
The following
update-ledger
example updates the specified ledger to use an Amazon owned KMS key for encryption at rest.aws qldb update-ledger \ --name
myExampleLedger
\ --kms-keyAWS_OWNED_KMS_KEY
Output:
{ "CreationDateTime": 1568839243.951, "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": false, "Name": "myExampleLedger", "State": "ACTIVE", "EncryptionDescription": { "KmsKeyArn": "AWS_OWNED_KMS_KEY", "EncryptionStatus": "UPDATING" } }
For more information, see Basic Operations for Amazon QLDB Ledgers
in the Amazon QLDB Developer Guide. -
For API details, see UpdateLedger
in Amazon CLI Command Reference.
-