Esempi di QLDB che utilizzano AWS CLI - AWS Command Line Interface

Esempi di QLDB che utilizzano AWS CLI

Gli esempi di codice seguenti mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface con QLDB.

Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le operazioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, dove è possibile trovare le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Operazioni

L’esempio di codice seguente mostra come utilizzare cancel-journal-kinesis-stream.

AWS CLI

Come annullare un flusso di journal

L’esempio cancel-journal-kinesis-stream seguente annulla il flusso di journal specificato da un libro mastro.

aws qldb cancel-journal-kinesis-stream \ --ledger-name myExampleLedger \ --stream-id 7ISCkqwe4y25YyHLzYUFAf

Output:

{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }

Per ulteriori informazioni, consulta Streaming journal data from Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare create-ledger.

AWS CLI

Esempio 1: creare un libro mastro con proprietà predefinite

L’esempio create-ledger seguente crea un libro mastro con il nome myExampleLedger e la modalità di autorizzazione STANDARD. I parametri facoltativi per la protezione dall’eliminazione e la chiave AWS KMS non sono specificati, quindi vengono impostati rispettivamente sui valori predefiniti true e su una chiave KMS di proprietà di AWS.

aws qldb create-ledger \ --name myExampleLedger \ --permissions-mode STANDARD

Output:

{ "State": "CREATING", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": true, "CreationDateTime": 1568839243.951, "Name": "myExampleLedger", "PermissionsMode": "STANDARD" }

Esempio 2: creare un registro con la protezione dall’eliminazione disattivata, una chiave KMS gestita dal cliente e tag specificati

L’esempio create-ledger seguente crea un libro mastro con il nome myExampleLedger2 e la modalità di autorizzazione STANDARD. La funzionalità di protezione dall’eliminazione è disabilitata, viene utilizzata la chiave KMS gestita dal cliente per la crittografia dei dati inattivi e vengono applicati i tag specificati alla risorsa.

aws qldb create-ledger \ --name myExampleLedger2 \ --permissions-mode STANDARD \ --no-deletion-protection \ --kms-key arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --tags IsTest=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" }

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta CreateLedger in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare delete-ledger.

AWS CLI

Come eliminare un libro mastro

Nell’esempio seguente, delete-ledger elimina il libro mastro specificato.

aws qldb delete-ledger \ --name myExampleLedger

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta DeleteLedger in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare describe-journal-kinesis-stream.

AWS CLI

Come descrivere un flusso di journal

L’esempio describe-journal-kinesis-stream seguente mostra i dettagli del flusso di journal specificato da un libro mastro.

aws qldb describe-journal-kinesis-stream \ --ledger-name myExampleLedger \ --stream-id 7ISCkqwe4y25YyHLzYUFAf

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" } }

Per ulteriori informazioni, consulta Streaming journal data from Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare describe-journal-s3-export.

AWS CLI

Come descrivere un processo di esportazione del journal

Nell’esempio seguente, describe-journal-s3-export mostra i dettagli del processo di esportazione specificato da un libro mastro.

aws qldb describe-journal-s3-export \ --name myExampleLedger \ --export-id ADR2ONPKN5LINYGb4dp7yZ

Output:

{ "ExportDescription": { "S3ExportConfiguration": { "Bucket": "amzn-s3-demo-bucket", "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" } }

Per ulteriori informazioni, consulta Exporting Your Journal in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare describe-ledger.

AWS CLI

Come descrivere un libro mastro

Nell’esempio seguente, describe-ledger mostra i dettagli del libro mastro specificato.

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" } }

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta DescribeLedger in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare export-journal-to-s3.

AWS CLI

Come esportare blocchi del journal in S3

L’esempio export-journal-to-s3 seguente crea un processo di esportazione dei blocchi del journal all’interno di un intervallo di data e ora specificato da un libro mastro con il nome myExampleLedger. Il processo di esportazione scrive i blocchi in un bucket Amazon S3 specificato.

aws qldb export-journal-to-s3 \ --name myExampleLedger \ --inclusive-start-time 2019-09-18T00:00:00Z \ --exclusive-end-time 2019-09-18T22:59:59Z \ --role-arn arn:aws:iam::123456789012:role/my-s3-export-role \ --s3-export-configuration file://my-s3-export-config.json

Contenuto di my-s3-export-config.json.

{ "Bucket": "amzn-s3-demo-bucket", "Prefix": "ledgerexport1/", "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" } }

Output:

{ "ExportId": "ADR2ONPKN5LINYGb4dp7yZ" }

Per ulteriori informazioni, consulta Exporting Your Journal in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta ExportJournalToS3 in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare get-block.

AWS CLI

Esempio 1: ottenere un blocco del journal e una prova per la verifica utilizzando file di input

L’esempio get-block seguente richiede un oggetto di dati di blocco e una prova dal libro mastro specificato. La richiesta riguarda un indirizzo di suggerimento digest e un indirizzo di blocco specificati.

aws qldb get-block \ --name vehicle-registration \ --block-address file://myblockaddress.json \ --digest-tip-address file://mydigesttipaddress.json

Contenuto di myblockaddress.json.

{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}" }

Contenuto di 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=}}]" } }

Per ulteriori informazioni, consulta Data Verification in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

Esempio 2: ottenere un blocco del journal e una prova per la verifica utilizzando sintassi abbreviata

L’esempio get-block seguente richiede un oggetto di dati di blocco e una prova dal libro mastro specificato utilizzando la sintassi abbreviata. La richiesta riguarda un indirizzo di suggerimento digest e un indirizzo di blocco specificati.

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=}}]" } }

Per ulteriori informazioni, consulta Data Verification in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta GetBlock in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare get-digest.

AWS CLI

Come ottenere un digest di un libro mastro

L’esempio get-digest seguente richiede un digest dal libro mastro specificato all’ultimo blocco con commit nel journal.

aws qldb get-digest \ --name vehicle-registration

Output:

{ "Digest": "6m6BMXobbJKpMhahwVthAEsN6awgnHK62Qq5McGP1Gk=", "DigestTipAddress": { "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:123}" } }

Per ulteriori informazioni, consulta Data Verification in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta GetDigest in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare get-revision.

AWS CLI

Esempio 1: ottenere una revisione del documento e una prova per la verifica utilizzando file di input

L’esempio get-revision seguente richiede un oggetto di dati di revisione e una prova dal libro mastro specificato. La richiesta riguarda un indirizzo di suggerimento digest, un ID documento e un indirizzo di blocco della revisione specificati.

aws qldb get-revision \ --name vehicle-registration \ --block-address file://myblockaddress.json \ --document-id JUJgkIcNbhS2goq8RqLuZ4 \ --digest-tip-address file://mydigesttipaddress.json

Contenuto di myblockaddress.json.

{ "IonText": "{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}" }

Contenuto di 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=}}]" } }

Per ulteriori informazioni, consulta Data Verification in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

Esempio 2: ottenere una revisione del documento e una prova per la verifica utilizzando sintassi abbreviata

L’esempio get-revision seguente richiede un oggetto di dati di revisione e una prova dal libro mastro specificato utilizzando la sintassi abbreviata. La richiesta riguarda un indirizzo di suggerimento digest, un ID documento e un indirizzo di blocco della revisione specificati.

aws qldb get-revision \ --name vehicle-registration \ --block-address 'IonText="{strandId:\"KmA3ZZca7vAIiJAK9S5Iwl\",sequenceNo:100}"' \ --document-id JUJgkIcNbhS2goq8RqLuZ4 \ --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=}}]" } }

Per ulteriori informazioni, consulta Data Verification in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta GetRevision in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare list-journal-kinesis-streams-for-ledger.

AWS CLI

Come elencare i flussi di journal per un libro mastro

L’esempio list-journal-kinesis-streams-for-ledger seguente elenca i flussi di journal per il libro mastro specificato.

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" } ] }

Per ulteriori informazioni, consulta Streaming journal data from Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare list-journal-s3-exports-for-ledger.

AWS CLI

Come elencare i processi di esportazione del journal per un libro mastro

L’esempio list-journal-s3-exports-for-ledger seguente elenca i processi di esportazione del journal per il libro mastro specificato.

aws qldb list-journal-s3-exports-for-ledger \ --name myExampleLedger

Output:

{ "JournalS3Exports": [ { "LedgerName": "myExampleLedger", "ExclusiveEndTime": 1568847599.0, "ExportCreationTime": 1568847801.418, "S3ExportConfiguration": { "Bucket": "amzn-s3-demo-bucket", "Prefix": "ledgerexport1/", "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" } }, "ExportId": "ADR2ONPKN5LINYGb4dp7yZ", "RoleArn": "arn:aws:iam::123456789012:role/qldb-s3-export", "InclusiveStartTime": 1568764800.0, "Status": "IN_PROGRESS" } ] }

Per ulteriori informazioni, consulta Exporting Your Journal in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare list-journal-s3-exports.

AWS CLI

Come elencare i processi di esportazione del journal

L’esempio list-journal-s3-exports seguente elenca i processi di esportazione del journal per tutti i libri mastri associati all’account AWS e alla Regione correnti.

aws qldb list-journal-s3-exports

Output:

{ "JournalS3Exports": [ { "Status": "IN_PROGRESS", "LedgerName": "myExampleLedger", "S3ExportConfiguration": { "EncryptionConfiguration": { "ObjectEncryptionType": "SSE_S3" }, "Bucket": "amzn-s3-demo-bucket", "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": "amzn-s3-demo-bucket", "Prefix": "ledgerexport1/" }, "RoleArn": "arn:aws:iam::123456789012:role/my-s3-export-role", "ExportCreationTime": 1568846847.638, "ExportId": "2pdvW8UQrjBAiYTMehEJDI", "InclusiveStartTime": 1568592000.0, "ExclusiveEndTime": 1568764800.0 } ] }

Per ulteriori informazioni, consulta Exporting Your Journal in Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta ListJournalS3Exports in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare list-ledgers.

AWS CLI

Come elencare i libri mastri disponibili

Nell’esempio seguente, list-ledgers elenca tutti i libri mastri associati all’account AWS e alla Regione correnti.

aws qldb list-ledgers

Output:

{ "Ledgers": [ { "State": "ACTIVE", "CreationDateTime": 1568839243.951, "Name": "myExampleLedger" }, { "State": "ACTIVE", "CreationDateTime": 1568839543.557, "Name": "myExampleLedger2" } ] }

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta ListLedgers in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare list-tags-for-resource.

AWS CLI

Come elencare i tag associati a un libro mastro

L’esempio list-tags-for-resource seguente elenca tutti i tag associati al libro mastro specificato.

aws qldb list-tags-for-resource \ --resource-arn arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger

Output:

{ "Tags": { "IsTest": "true", "Domain": "Test" } }

Per ulteriori informazioni, consulta Tagging Amazon QLDB Resources nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta ListTagsForResource in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare stream-journal-to-kinesis.

AWS CLI

Esempio 1: trasmettere i dati del journal di registrazione al flusso di dati Kinesis utilizzando file di input

L’esempio stream-journal-to-kinesis seguente crea un flusso di dati del journal all’interno di un intervallo di data e ora specificato da un libro mastro con il nome myExampleLedger. Il flusso invia i dati a un flusso di dati Amazon Kinesis specificato.

aws qldb stream-journal-to-kinesis \ --ledger-name myExampleLedger \ --inclusive-start-time 2020-05-29T00:00:00Z \ --exclusive-end-time 2020-05-29T23:59:59Z \ --role-arn arn:aws:iam::123456789012:role/my-kinesis-stream-role \ --kinesis-configuration file://my-kinesis-config.json \ --stream-name myExampleLedger-stream

Contenuto di my-kinesis-config.json.

{ "StreamArn": "arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb", "AggregationEnabled": true }

Output:

{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }

Per ulteriori informazioni, consulta Streaming journal data from Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

Esempio 2: trasmettere i dati del journal al flusso di dati Kinesis utilizzando sintassi abbreviata

L’esempio stream-journal-to-kinesis seguente crea un flusso di dati del journal all’interno di un intervallo di data e ora specificato da un libro mastro con il nome myExampleLedger. Il flusso invia i dati a un flusso di dati Amazon Kinesis specificato.

aws qldb stream-journal-to-kinesis \ --ledger-name myExampleLedger \ --inclusive-start-time 2020-05-29T00:00:00Z \ --exclusive-end-time 2020-05-29T23:59:59Z \ --role-arn arn:aws:iam::123456789012:role/my-kinesis-stream-role \ --stream-name myExampleLedger-stream \ --kinesis-configuration StreamArn=arn:aws:kinesis:us-east-1:123456789012:stream/stream-for-qldb,AggregationEnabled=true

Output:

{ "StreamId": "7ISCkqwe4y25YyHLzYUFAf" }

Per ulteriori informazioni, consulta Streaming journal data from Amazon QLDB nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare tag-resource.

AWS CLI

Come aggiungere tag a un libro mastro

L’esempio tag-resource seguente aggiunge un set di tag a un libro mastro specificato.

aws qldb tag-resource \ --resource-arn arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger \ --tags IsTest=true,Domain=Test

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Tagging Amazon QLDB Resources nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta TagResource in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare untag-resource.

AWS CLI

Come rimuovere tag da una risorsa

L’esempio untag-resource seguente rimuove i tag con le chiavi di tag specificate da un libro mastro.

aws qldb untag-resource \ --resource-arn arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger \ --tag-keys IsTest Domain

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Tagging Amazon QLDB Resources nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta UntagResource in AWS CLI Command Reference.

L’esempio di codice seguente mostra come utilizzare update-ledger-permissions-mode.

AWS CLI

Esempio 1: aggiornare la modalità di autorizzazione di un libro mastro su STANDARD

L’esempio update-ledger-permissions-mode seguente assegna la modalità di autorizzazione STANDARD al libro mastro specificato.

aws qldb update-ledger-permissions-mode \ --name myExampleLedger \ --permissions-mode STANDARD

Output:

{ "Name": "myExampleLedger", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "PermissionsMode": "STANDARD" }

Esempio 2: aggiornare la modalità di autorizzazione di un libro mastro su ALLOW_ALL

L’esempio update-ledger-permissions-mode seguente assegna la modalità di autorizzazione ALLOW_ALL al libro mastro specificato.

aws qldb update-ledger-permissions-mode \ --name myExampleLedger \ --permissions-mode ALLOW_ALL

Output:

{ "Name": "myExampleLedger", "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "PermissionsMode": "ALLOW_ALL" }

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

L’esempio di codice seguente mostra come utilizzare update-ledger.

AWS CLI

Esempio 1: aggiornare la proprietà di protezione dall’eliminazione di un libro mastro

L’esempio update-ledger seguente aggiorna il libro mastro specificato per disabilitare la funzionalità di protezione dall’eliminazione.

aws qldb update-ledger \ --name myExampleLedger \ --no-deletion-protection

Output:

{ "CreationDateTime": 1568839243.951, "Arn": "arn:aws:qldb:us-west-2:123456789012:ledger/myExampleLedger", "DeletionProtection": false, "Name": "myExampleLedger", "State": "ACTIVE" }

Esempio 2: aggiornare la chiave AWS KMS di un libro mastro con una chiave gestita dal cliente

L’esempio update-ledger seguente aggiorna il libro mastro specificato per utilizzare una chiave KMS gestita dal cliente per la crittografia dei dati inattivi.

aws qldb update-ledger \ --name myExampleLedger \ --kms-key arn: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" } }

Esempio 3: aggiornare la chiave AWS KMS di un libro mastro con una chiave di proprietà di AWS

L’esempio update-ledger seguente aggiorna il libro mastro specificato per utilizzare una chiave KMS di proprietà di AWS per la crittografia dei dati inattivi.

aws qldb update-ledger \ --name myExampleLedger \ --kms-key AWS_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" } }

Per ulteriori informazioni, consulta Basic Operations for Amazon QLDB Ledgers nella Guida per gli sviluppatori di Amazon QLDB.

  • Per informazioni dettagliate sull’API, consulta UpdateLedger in AWS CLI Command Reference.