Esempi di utilizzo di Security Lake AWS CLI - AWS Command Line Interface

Questa documentazione è valida AWS CLI solo per la versione 1. Per la documentazione relativa alla versione 2 di AWS CLI, consulta la Guida per l'utente della versione 2.

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Esempi di utilizzo di Security Lake AWS CLI

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando il AWS Command Line Interface con Security Lake.

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

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzarecreate-aws-log-source.

AWS CLI

Come aggiungere un Amazon Web Service con supporto nativo come sorgente Amazon Security Lake

L’esempio create-aws-logsource seguente aggiunge i log di flusso VPC come origine di Security Lake negli account e nelle Regioni designati.

aws securitylake create-aws-log-source \ --sources '[{"regions": ["us-east-1"], "accounts": ["123456789012"], "sourceName": "SH_FINDINGS", "sourceVersion": "2.0"}]'

Output:

{ "failed": [ "123456789012" ] }

Per ulteriori informazioni, consulta Aggiungere un AWS servizio come fonte nella Guida per l'utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarecreate-custom-log-source.

AWS CLI

Come aggiungere un’origine personalizzata come origine Amazon Security Lake

L’esempio create-custom-logsource seguente aggiunge un’origine personalizzata come origine di Security Lake nell’account del provider di log e nella Regione designati.

aws securitylake create-custom-log-source \ --source-name "VPC_FLOW" \ --event-classes '["DNS_ACTIVITY", "NETWORK_ACTIVITY"]' \ --configuration '{"crawlerConfiguration": {"roleArn": "arn:aws:glue:eu-west-2:123456789012:crawler/E1WG1ZNPRXT0D4"},"providerIdentity": {"principal": "029189416600","externalId": "123456789012"}}' --region "us-east-1"

Output:

{ "customLogSource": { "attributes": { "crawlerArn": "arn:aws:glue:eu-west-2:123456789012:crawler/E1WG1ZNPRXT0D4", "databaseArn": "arn:aws:glue:eu-west-2:123456789012:database/E1WG1ZNPRXT0D4", "tableArn": "arn:aws:glue:eu-west-2:123456789012:table/E1WG1ZNPRXT0D4" }, "provider": { "location": "amzn-s3-demo-bucket--usw2-az1--x-s3", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-Provider-testCustom2-eu-west-2" }, "sourceName": "testCustom2" "sourceVersion": "2.0" } }

Per ulteriori informazioni, consulta Aggiungere un’origine personalizzata nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarecreate-data-lake-exception-subscription.

AWS CLI

Come inviare notifiche relative alle eccezioni di Security Lake

L’esempio create-data-lake-exception-subscription seguente invia notifiche relative alle eccezioni di Security Lake all’account specificato tramite invio di SMS. Il messaggio di eccezione rimane attivo per il periodo di tempo specificato.

aws securitylake create-data-lake-exception-subscription \ --notification-endpoint "123456789012" \ --exception-time-to-live 30 \ --subscription-protocol "sms"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Risoluzione dei problemi di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarecreate-data-lake-organization-configuration.

AWS CLI

Come configurare Security Lake nei nuovi account dell’organizzazione

L’esempio create-data-lake-organization-configuration seguente abilita Security Lake e la raccolta degli eventi di origine specificati e registra i logo dei nuovi account dell’organizzazione.

aws securitylake create-data-lake-organization-configuration \ --auto-enable-new-account '[{"region":"us-east-1","sources":[{"sourceName":"SH_FINDINGS","sourceVersion": "1.0"}]}]'

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Managing multiple account with AWS Organizations nella Amazon Security Lake User Guide.

Il seguente esempio di codice mostra come utilizzarecreate-data-lake.

AWS CLI

Esempio 1: come configurare il data lake in più Regioni

L'create-data-lakeesempio seguente abilita Amazon Security Lake in più AWS regioni e configura il tuo data lake.

aws securitylake create-data-lake \ --configurations '[{"encryptionConfiguration": {"kmsKeyId":"S3_MANAGED_KEY"},"region":"us-east-1","lifecycleConfiguration": {"expiration":{"days":365},"transitions":[{"days":60,"storageClass":"ONEZONE_IA"}]}}, {"encryptionConfiguration": {"kmsKeyId":"S3_MANAGED_KEY"},"region":"us-east-2","lifecycleConfiguration": {"expiration":{"days":365},"transitions":[{"days":60,"storageClass":"ONEZONE_IA"}]}}]' \ --meta-store-manager-role-arn "arn:aws:iam:us-east-1:123456789012:role/service-role/AmazonSecurityLakeMetaStoreManager"

Output:

{ "dataLakes": [ { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-1:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "S3_MANAGED_KEY" }, "lifecycleConfiguration": { "expiration": { "days": 365 }, "transitions": [ { "days": 60, "storageClass": "ONEZONE_IA" } ] }, "region": "us-east-1", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-1-gnevt6s8z7bzby8oi3uiaysbr8v2ml", "updateStatus": { "exception": {}, "requestId": "f20a6450-d24a-4f87-a6be-1d4c075a59c2", "status": "INITIALIZED" } }, { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-2:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "S3_MANAGED_KEY" }, "lifecycleConfiguration": { "expiration": { "days": 365 }, "transitions": [ { "days": 60, "storageClass": "ONEZONE_IA" } ] }, "region": "us-east-2", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-2-cehuifzl5rwmhm6m62h7zhvtseogr9", "updateStatus": { "exception": {}, "requestId": "f20a6450-d24a-4f87-a6be-1d4c075a59c2", "status": "INITIALIZED" } } ] }

Per ulteriori informazioni, consulta Guida introduttiva ad Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Esempio 2: come configurare il data lake in un’unica Regione

L'create-data-lakeesempio seguente abilita Amazon Security Lake in una singola AWS regione e configura il tuo data lake.

aws securitylake create-data-lake \ --configurations '[{"encryptionConfiguration": {"kmsKeyId":"1234abcd-12ab-34cd-56ef-1234567890ab"},"region":"us-east-2","lifecycleConfiguration": {"expiration":{"days":500},"transitions":[{"days":30,"storageClass":"GLACIER"}]}}]' \ --meta-store-manager-role-arn "arn:aws:iam:us-east-1:123456789012:role/service-role/AmazonSecurityLakeMetaStoreManager"

Output:

{ "dataLakes": [ { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-2:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "1234abcd-12ab-34cd-56ef-1234567890ab" }, "lifecycleConfiguration": { "expiration": { "days": 500 }, "transitions": [ { "days": 30, "storageClass": "GLACIER" } ] }, "region": "us-east-2", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-2-cehuifzl5rwmhm6m62h7zhvtseogr9", "updateStatus": { "exception": {}, "requestId": "77702a53-dcbf-493e-b8ef-518e362f3003", "status": "INITIALIZED" } } ] }

Per ulteriori informazioni, consulta Guida introduttiva ad Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarecreate-subscriber-notification.

AWS CLI

Come creare una notifica per gli abbonati

L’esempio create-subscriber-notification seguente mostra come specificare la notifica dell’abbonato per creare una notifica quando nuovi dati vengono scritti nel data lake.

aws securitylake create-subscriber-notification \ --subscriber-id "12345ab8-1a34-1c34-1bd4-12345ab9012" \ --configuration '{"httpsNotificationConfiguration": {"targetRoleArn":"arn:aws:iam::XXX:role/service-role/RoleName", "endpoint":"https://account-management.$3.$2.securitylake.aws.dev/v1/datalake"}}'

Output:

{ "subscriberEndpoint": [ "https://account-management.$3.$2.securitylake.aws.dev/v1/datalake" ] }

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarecreate-subscriber.

AWS CLI

Esempio 1: come creare un abbonato con accesso ai dati

L'create-subscriberesempio seguente crea un sottoscrittore in Security Lake con accesso ai dati nella AWS regione corrente per l'identità di sottoscrittore specificata per un' AWS origine.

aws securitylake create-subscriber \ --access-types "S3" \ --sources '[{"awsLogSource": {"sourceName": "VPC_FLOW","sourceVersion": "2.0"}}]' \ --subscriber-name 'opensearch-s3' \ --subscriber-identity '{"principal": "029189416600","externalId": "123456789012"}'

Output:

{ "subscriber": { "accessTypes": [ "S3" ], "createdAt": "2024-07-17T19:08:26.787000+00:00", "roleArn": "arn:aws:iam::773172568199:role/AmazonSecurityLake-896f218b-cfba-40be-a255-8b49a65d0407", "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-1-um632ufwpvxkyz0bc5hkb64atycnf3", "sources": [ { "awsLogSource": { "sourceName": "VPC_FLOW", "sourceVersion": "2.0" } } ], "subscriberArn": "arn:aws:securitylake:us-east-1:773172568199:subscriber/896f218b-cfba-40be-a255-8b49a65d0407", "subscriberId": "896f218b-cfba-40be-a255-8b49a65d0407", "subscriberIdentity": { "externalId": "123456789012", "principal": "029189416600" }, "subscriberName": "opensearch-s3", "subscriberStatus": "ACTIVE", "updatedAt": "2024-07-17T19:08:27.133000+00:00" } }

Per ulteriori informazioni, consulta Creare un abbonato con accesso ai dati nella Guida per l’utente di Amazon Security Lake.

Esempio 2: come creare un abbonato con accesso alle query

L'create-subscriberesempio seguente crea un sottoscrittore in Security Lake con accesso tramite query nella AWS regione corrente per l'identità di sottoscrittore specificata.

aws securitylake create-subscriber \ --access-types "LAKEFORMATION" \ --sources '[{"awsLogSource": {"sourceName": "VPC_FLOW","sourceVersion": "2.0"}}]' \ --subscriber-name 'opensearch-s3' \ --subscriber-identity '{"principal": "029189416600","externalId": "123456789012"}'

Output:

{ "subscriber": { "accessTypes": [ "LAKEFORMATION" ], "createdAt": "2024-07-18T01:05:55.853000+00:00", "resourceShareArn": "arn:aws:ram:us-east-1:123456789012:resource-share/8c31da49-c224-4f1e-bb12-37ab756d6d8a", "resourceShareName": "LakeFormation-V2-NAMENAMENA-123456789012", "sources": [ { "awsLogSource": { "sourceName": "VPC_FLOW", "sourceVersion": "2.0" } } ], "subscriberArn": "arn:aws:securitylake:us-east-1:123456789012:subscriber/e762aabb-ce3d-4585-beab-63474597845d", "subscriberId": "e762aabb-ce3d-4585-beab-63474597845d", "subscriberIdentity": { "externalId": "123456789012", "principal": "029189416600" }, "subscriberName": "opensearch-s3", "subscriberStatus": "ACTIVE", "updatedAt": "2024-07-18T01:05:58.393000+00:00" } }

Per ulteriori informazioni, consulta Creare un abbonato con accesso alle query nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzaredelete-aws-log-source.

AWS CLI

Per rimuovere un servizio supportato nativamente AWS .

L’esempio delete-aws-logsource seguente elimina i log di flusso VPC come origine di Security Lake negli account e nelle Regioni designati.

aws securitylake delete-aws-log-source \ --sources '[{"regions": ["us-east-1"], "accounts": ["123456789012"], "sourceName": "SH_FINDINGS", "sourceVersion": "2.0"}]'

Output:

{ "failed": [ "123456789012" ] }

Per ulteriori informazioni, consulta Rimuovere un AWS servizio come fonte nella Guida per l'utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzaredelete-custom-log-source.

AWS CLI

Come rimuovere un’origine personalizzata.

L’esempio delete-custom-logsource seguente elimina un’origine personalizzata nell’account del provider di log designato nella Regione designata.

aws securitylake delete-custom-log-source \ --source-name "CustomSourceName"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Eliminazione di una fonte personalizzata nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzaredelete-data-lake-organization-configuration.

AWS CLI

Come arrestare la raccolta automatica delle origini negli account membro

L'delete-data-lake-organization-configurationesempio seguente interrompe la raccolta automatica dei risultati del AWS Security Hub dai nuovi account membri che entrano a far parte dell'organizzazione. Solo l’account amministratore di Security Lake delegato può eseguire questo comando. Impedisce ai nuovi account membro di fornire automaticamente dati al data lake.

aws securitylake delete-data-lake-organization-configuration \ --auto-enable-new-account '[{"region":"us-east-1","sources":[{"sourceName":"SH_FINDINGS"}]}]'

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Managing multiple account with AWS Organizations nella Amazon Security Lake User Guide.

Il seguente esempio di codice mostra come utilizzaredelete-data-lake.

AWS CLI

Come disabilitare il data lake

L'delete-data-lakeesempio seguente disabilita il data lake nelle AWS regioni specificate. Nelle Regioni specificate, le origini non forniscono più dati al data lake. Per una distribuzione di Security Lake che utilizza AWS Organizations, solo l'amministratore delegato di Security Lake dell'organizzazione può disabilitare Security Lake per gli account dell'organizzazione.

aws securitylake delete-data-lake \ --regions "ap-northeast-1" "eu-central-1"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Disabilitazione di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

  • Per i dettagli sull'API, vedere DeleteDataLakein AWS CLI Command Reference.

Il seguente esempio di codice mostra come utilizzaredelete-subscriber-notification.

AWS CLI

Come eliminare un abbonato da una notifica

L’esempio delete-subscriber-notification seguente mostra come eliminare la notifica di sottoscrizione per un abbonato specifico di Security Lake.

aws securitylake delete-subscriber-notification \ --subscriber-id "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzaredelete-subscriber.

AWS CLI

Come eliminare un abbonato

L’esempio delete-subscriber seguente mostra come rimuovere un abbonato se non desideri più che questo utilizzi i dati di Security Lake.

aws securitylake delete-subscriber \ --subscriber-id "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareget-data-lake-exception-subscription.

AWS CLI

Come ottenere dettagli su un abbonamento eccezionale

L’esempio get-data-lake-exception-subscription seguente fornisce dettagli su un abbonamento alle eccezioni di Security Lake. In questo esempio, l'utente dell' AWS account specificato riceve una notifica degli errori tramite l'invio di SMS. Il messaggio di eccezione rimane attivo nell’account per il periodo di tempo specificato. Un abbonamento alle eccezioni notifica a un utente di Security Lake un errore tramite il protocollo preferito del richiedente.

aws securitylake get-data-lake-exception-subscription

Output:

{ "exceptionTimeToLive": 30, "notificationEndpoint": "123456789012", "subscriptionProtocol": "sms" }

Per ulteriori informazioni, consulta Risoluzione dei problemi con gli stati del data lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareget-data-lake-organization-configuration.

AWS CLI

Come ottenere dettagli sulla configurazione dei nuovi account dell’organizzazione

L’esempio get-data-lake-organization-configuration seguente recupera i dettagli sui log di origine che i nuovi account dell’organizzazione invieranno dopo l’onboarding su Amazon Security Lake.

aws securitylake get-data-lake-organization-configuration

Output:

{ "autoEnableNewAccount": [ { "region": "us-east-1", "sources": [ { "sourceName": "VPC_FLOW", "sourceVersion": "1.0" }, { "sourceName": "ROUTE53", "sourceVersion": "1.0" }, { "sourceName": "SH_FINDINGS", "sourceVersion": "1.0" } ] } ] }

Per ulteriori informazioni, consulta Managing multiple account with AWS Organizations nella Amazon Security Lake User Guide.

Il seguente esempio di codice mostra come utilizzareget-data-lake-sources.

AWS CLI

Come ottenere lo stato della raccolta dei log

L'get-data-lake-sourcesesempio seguente ottiene un'istantanea della raccolta dei registri per l'account specificato nella AWS regione corrente. L’account ha Amazon Security Lake abilitato.

aws securitylake get-data-lake-sources \ --accounts "123456789012"

Output:

{ "dataLakeSources": [ { "account": "123456789012", "sourceName": "SH_FINDINGS", "sourceStatuses": [ { "resource": "vpc-1234567890abcdef0", "status": "COLLECTING" } ] }, { "account": "123456789012", "sourceName": "VPC_FLOW", "sourceStatuses": [ { "resource": "vpc-1234567890abcdef0", "status": "NOT_COLLECTING" } ] }, { "account": "123456789012", "sourceName": "LAMBDA_EXECUTION", "sourceStatuses": [ { "resource": "vpc-1234567890abcdef0", "status": "COLLECTING" } ] }, { "account": "123456789012", "sourceName": "ROUTE53", "sourceStatuses": [ { "resource": "vpc-1234567890abcdef0", "status": "COLLECTING" } ] }, { "account": "123456789012", "sourceName": "CLOUD_TRAIL_MGMT", "sourceStatuses": [ { "resource": "vpc-1234567890abcdef0", "status": "COLLECTING" } ] } ], "dataLakeArn": null }

Per ulteriori informazioni, consulta la sezione Raccolta di dati dai AWS servizi nella Guida per l'utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareget-subscriber.

AWS CLI

Come recuperare le informazioni sull’abbonamento

L’esempio get-subscriber seguente recupera le informazioni sull’abbonamento per l’abbonato Securiy Lake specificato.

aws securitylake get-subscriber \ --subscriber-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111

Output:

{ "subscriber": { "accessTypes": [ "LAKEFORMATION" ], "createdAt": "2024-04-19T15:19:44.421803+00:00", "resourceShareArn": "arn:aws:ram:eu-west-2:123456789012:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "resourceShareName": "LakeFormation-V3-TKJGBHCKTZ-123456789012", "sources": [ { "awsLogSource": { "sourceName": "LAMBDA_EXECUTION", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "EKS_AUDIT", "sourceVersion": "2.0" } }, { "awsLogSource": { "sourceName": "ROUTE53", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "SH_FINDINGS", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "VPC_FLOW", "sourceVersion": "1.0" } }, { "customLogSource": { "attributes": { "crawlerArn": "arn:aws:glue:eu-west-2:123456789012:crawler/testCustom2", "databaseArn": "arn:aws:glue:eu-west-2:123456789012:database/amazon_security_lake_glue_db_eu_west_2", "tableArn": "arn:aws:glue:eu-west-2:123456789012:table/amazon_security_lake_table_eu_west_2_ext_testcustom2" }, "provider": { "location": "s3://aws-security-data-lake-eu-west-2-8ugsus4ztnsfpjbldwbgf4vge98av9/ext/testCustom2/", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-Provider-testCustom2-eu-west-2" }, "sourceName": "testCustom2" } }, { "customLogSource": { "attributes": { "crawlerArn": "arn:aws:glue:eu-west-2:123456789012:crawler/TestCustom", "databaseArn": "arn:aws:glue:eu-west-2:123456789012:database/amazon_security_lake_glue_db_eu_west_2", "tableArn": "arn:aws:glue:eu-west-2:123456789012:table/amazon_security_lake_table_eu_west_2_ext_testcustom" }, "provider": { "location": "s3://aws-security-data-lake-eu-west-2-8ugsus4ztnsfpjbldwbgf4vge98av9/ext/TestCustom/", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-Provider-TestCustom-eu-west-2" }, "sourceName": "TestCustom" } } ], "subscriberArn": "arn:aws:securitylake:eu-west-2:123456789012:subscriber/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "subscriberId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "subscriberIdentity": { "externalId": "123456789012", "principal": "123456789012" }, "subscriberName": "test", "subscriberStatus": "ACTIVE", "updatedAt": "2024-04-19T15:19:55.230588+00:00" } }

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarelist-data-lake-exceptions.

AWS CLI

Come elencare i problemi che riguardano il tuo data lake

L'list-data-lake-exceptionsesempio seguente elenca i problemi che hanno interessato il data lake negli ultimi 14 giorni nelle AWS regioni specificate.

aws securitylake list-data-lake-exceptions \ --regions "us-east-1" "eu-west-3"

Output:

{ "exceptions": [ { "exception": "The account does not have the required role permissions. Update your role permissions to use the new data source version.", "region": "us-east-1", "timestamp": "2024-02-29T12:24:15.641725+00:00" }, { "exception": "The account does not have the required role permissions. Update your role permissions to use the new data source version.", "region": "eu-west-3", "timestamp": "2024-02-29T12:24:15.641725+00:00" } ] }

Per ulteriori informazioni, consulta Risoluzione dei problemi di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarelist-data-lakes.

AWS CLI

Come elencare l’oggetto di configurazione Security Lake

L'list-data-lakesesempio seguente elenca l'oggetto di configurazione Amazon Security Lake per la AWS regione specificata. È possibile utilizzare questo comando per determinare se Security Lake è abilitato in una o più Regioni specificate.

aws securitylake list-data-lakes \ --regions "us-east-1"

Output:

{ "dataLakes": [ { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-1:123456789012:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "S3_MANAGED_KEY" }, "lifecycleConfiguration": { "expiration": { "days": 365 }, "transitions": [ { "days": 60, "storageClass": "ONEZONE_IA" } ] }, "region": "us-east-1", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:123456789012:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-1-1234567890abcdef0", "updateStatus": { "exception": { "code": "software.amazon.awssdk.services.s3.model.S3Exception", "reason": "" }, "requestId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "status": "FAILED" } } ] }

Per ulteriori informazioni, consulta Verifica dello stato della regione nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarelist-log-sources.

AWS CLI

Come recuperare le origini dei log di Amazon Security Lake

L’esempio list-log-sources seguente elenca le sorgenti di log di Amazon Security Lake in un account specificato.

aws securitylake list-log-sources \ --accounts "123456789012"

Output:

{ "account": "123456789012", "region": "xy-region-1", "sources": [ { "awsLogSource": { "sourceName": "VPC_FLOW", "sourceVersion": "2.0" } }, { "awsLogSource": { "sourceName": "SH_FINDINGS", "sourceVersion": "2.0" } } ] }

Per ulteriori informazioni, consulta Gestione delle fonti nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarelist-subscribers.

AWS CLI

Come recuperare le origini degli abbonati di Amazon Security Lake

L’esempio list-subscribers seguente elenca tutti gli abbonati a Amazon Security Lake in un account specifico.

aws securitylake list-subscribers

Output:

{ "subscribers": [ { "accessTypes": [ "S3" ], "createdAt": "2024-06-04T15:02:28.921000+00:00", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-E1WG1ZNPRXT0D4", "s3BucketArn": "amzn-s3-demo-bucket--usw2-az1--x-s3", "sources": [ { "awsLogSource": { "sourceName": "CLOUD_TRAIL_MGMT", "sourceVersion": "2.0" } }, { "awsLogSource": { "sourceName": "LAMBDA_EXECUTION", "sourceVersion": "1.0" } }, { "customLogSource": { "attributes": { "crawlerArn": "arn:aws:glue:eu-west-2:123456789012:crawler/E1WG1ZNPRXT0D4", "databaseArn": "arn:aws:glue:eu-west-2:123456789012:database/E1WG1ZNPRXT0D4", "tableArn": "arn:aws:glue:eu-west-2:123456789012:table/E1WG1ZNPRXT0D4" }, "provider": { "location": "amzn-s3-demo-bucket--usw2-az1--x-s3", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-E1WG1ZNPRXT0D4" }, "sourceName": "testCustom2" } } ], "subscriberArn": "arn:aws:securitylake:eu-west-2:123456789012:subscriber/E1WG1ZNPRXT0D4", "subscriberEndpoint": "arn:aws:sqs:eu-west-2:123456789012:AmazonSecurityLake-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111-Main-Queue", "subscriberId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "subscriberIdentity": { "externalId": "ext123456789012", "principal": "123456789012" }, "subscriberName": "Test", "subscriberStatus": "ACTIVE", "updatedAt": "2024-06-04T15:02:35.617000+00:00" } ] }

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzarelist-tags-for-resource.

AWS CLI

Come elencare i tag di una risorsa esistente

L’esempio list-tags-for-resource seguente elenca i tag associati all’abbonato ad Amazon Security Lake specificato. In questo esempio, la chiave del tag Proprietario ha un valore di tag associato. È possibile utilizzare questa operazione per elencare i tag anche per altre risorse di Security Lake esistenti.

aws securitylake list-tags-for-resource \ --resource-arn "arn:aws:securitylake:us-east-1:123456789012:subscriber/1234abcd-12ab-34cd-56ef-1234567890ab"

Output:

{ "tags": [ { "key": "Environment", "value": "Cloud" }, { "key": "CostCenter", "value": "12345" }, { "key": "Owner", "value": "" } ] }

Per ulteriori informazioni, consulta Associazione di tag alle risorse di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareregister-data-lake-delegated-administrator.

AWS CLI

Come designare l’amministratore delegato

L'register-data-lake-delegated-administratoresempio seguente designa l' AWS account specificato come amministratore delegato di Amazon Security Lake.

aws securitylake register-data-lake-delegated-administrator \ --account-id 123456789012

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Managing multiple account with AWS Organizations nella Amazon Security Lake User Guide.

Il seguente esempio di codice mostra come utilizzaretag-resource.

AWS CLI

Come aggiungere tag a una risorsa esistente

L’esempio tag-resource seguente aggiunge un tag a una risorsa di abbonato esistente. Per creare una nuova risorsa e aggiungervi uno o più tag, non utilizzare questa operazione. Utilizza invece l’operazione Crea appropriata per il tipo di risorsa da creare.

aws securitylake tag-resource \ --resource-arn "arn:aws:securitylake:us-east-1:123456789012:subscriber/1234abcd-12ab-34cd-56ef-1234567890ab" \ --tags key=Environment,value=Cloud

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Associazione di tag alle risorse di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareuntag-resource.

AWS CLI

Come rimuovere i tag da una risorsa esistente

L’esempio untag-resource seguente rimuove i tag specificati da una risorsa di un abbonato esistente.

aws securitylake untag-resource \ --resource-arn "arn:aws:securitylake:us-east-1:123456789012:subscriber/1234abcd-12ab-34cd-56ef-1234567890ab" \ --tags Environment Owner

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Associazione di tag alle risorse di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareupdate-data-lake-exception-subscription.

AWS CLI

Come aggiornare l’abbonamento alle notifiche per le eccezioni di Security Lake

L’esempio update-data-lake-exception-subscription seguente aggiorna la sottoscrizione alle notifiche che notifica agli utenti le eccezioni di Security Lake.

aws securitylake update-data-lake-exception-subscription \ --notification-endpoint "123456789012" \ --exception-time-to-live 30 \ --subscription-protocol "email"

Questo comando non produce alcun output.

Per ulteriori informazioni, consulta Risoluzione dei problemi di Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareupdate-data-lake.

AWS CLI

Esempio 1: come aggiornare le impostazioni del data lake

L’esempio update-data-lake seguente aggiorna le impostazioni del tuo data lake Amazon Security Lake. È possibile utilizzare questa operazione per specificare le impostazioni di crittografia dei dati, archiviazione e Regione di rollup.

aws securitylake update-data-lake \ --configurations '[{"encryptionConfiguration": {"kmsKeyId":"S3_MANAGED_KEY"},"region":"us-east-1","lifecycleConfiguration": {"expiration":{"days":365},"transitions":[{"days":60,"storageClass":"ONEZONE_IA"}]}}, {"encryptionConfiguration": {"kmsKeyId":"S3_MANAGED_KEY"},"region":"us-east-2","lifecycleConfiguration": {"expiration":{"days":365},"transitions":[{"days":60,"storageClass":"ONEZONE_IA"}]}}]' \ --meta-store-manager-role-arn "arn:aws:iam:us-east-1:123456789012:role/service-role/AmazonSecurityLakeMetaStoreManager"

Output:

{ "dataLakes": [ { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-1:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "S3_MANAGED_KEY" }, "lifecycleConfiguration": { "expiration": { "days": 365 }, "transitions": [ { "days": 60, "storageClass": "ONEZONE_IA" } ] }, "region": "us-east-1", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-1-gnevt6s8z7bzby8oi3uiaysbr8v2ml", "updateStatus": { "exception": {}, "requestId": "f20a6450-d24a-4f87-a6be-1d4c075a59c2", "status": "INITIALIZED" } }, { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-2:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "S3_MANAGED_KEY" }, "lifecycleConfiguration": { "expiration": { "days": 365 }, "transitions": [ { "days": 60, "storageClass": "ONEZONE_IA" } ] }, "region": "us-east-2", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-2-cehuifzl5rwmhm6m62h7zhvtseogr9", "updateStatus": { "exception": {}, "requestId": "f20a6450-d24a-4f87-a6be-1d4c075a59c2", "status": "INITIALIZED" } } ] }

Per ulteriori informazioni, consulta Guida introduttiva ad Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Esempio 2: come configurare il data lake in un’unica Regione

L'create-data-lakeesempio seguente abilita Amazon Security Lake in una singola AWS regione e configura il tuo data lake.

aws securitylake create-data-lake \ --configurations '[{"encryptionConfiguration": {"kmsKeyId":"1234abcd-12ab-34cd-56ef-1234567890ab"},"region":"us-east-2","lifecycleConfiguration": {"expiration":{"days":500},"transitions":[{"days":30,"storageClass":"GLACIER"}]}}]' \ --meta-store-manager-role-arn "arn:aws:iam:us-east-1:123456789012:role/service-role/AmazonSecurityLakeMetaStoreManager"

Output:

{ "dataLakes": [ { "createStatus": "COMPLETED", "dataLakeArn": "arn:aws:securitylake:us-east-2:522481757177:data-lake/default", "encryptionConfiguration": { "kmsKeyId": "1234abcd-12ab-34cd-56ef-1234567890ab" }, "lifecycleConfiguration": { "expiration": { "days": 500 }, "transitions": [ { "days": 30, "storageClass": "GLACIER" } ] }, "region": "us-east-2", "replicationConfiguration": { "regions": [ "ap-northeast-3" ], "roleArn": "arn:aws:securitylake:ap-northeast-3:522481757177:data-lake/default" }, "s3BucketArn": "arn:aws:s3:::aws-security-data-lake-us-east-2-cehuifzl5rwmhm6m62h7zhvtseogr9", "updateStatus": { "exception": {}, "requestId": "77702a53-dcbf-493e-b8ef-518e362f3003", "status": "INITIALIZED" } } ] }

Per ulteriori informazioni, consulta Guida introduttiva ad Amazon Security Lake nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareupdate-subscriber-notification.

AWS CLI

Come aggiornare una notifica dell’abbonato

L’esempio update-subscriber-notification seguente mostra come aggiornare il metodo di notifica per un abbonato.

aws securitylake update-subscriber-notification \ --subscriber-id "12345ab8-1a34-1c34-1bd4-12345ab9012" \ --configuration '{"httpsNotificationConfiguration": {"targetRoleArn":"arn:aws:iam::XXX:role/service-role/RoleName", "endpoint":"https://account-management.$3.$2.securitylake.aws.dev/v1/datalake"}}'

Output:

{ "subscriberEndpoint": [ "https://account-management.$3.$2.securitylake.aws.dev/v1/datalake" ] }

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.

Il seguente esempio di codice mostra come utilizzareupdate-subscriber.

AWS CLI

Come aggiornare un abbonato Amazon Security Lake.

L’esempio update-subscriber seguente aggiorna le fonti di accesso ai dati Security Lake per uno specifico abbonato a Security Lake.

aws securitylake update-subscriber \ --subscriber-id a1b2c3d4-5678-90ab-cdef-EXAMPLE11111

Output:

{ "subscriber": { "accessTypes": [ "LAKEFORMATION" ], "createdAt": "2024-04-19T15:19:44.421803+00:00", "resourceShareArn": "arn:aws:ram:eu-west-2:123456789012:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "resourceShareName": "LakeFormation-V3-TKJGBHCKTZ-123456789012", "sources": [ { "awsLogSource": { "sourceName": "LAMBDA_EXECUTION", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "EKS_AUDIT", "sourceVersion": "2.0" } }, { "awsLogSource": { "sourceName": "ROUTE53", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "SH_FINDINGS", "sourceVersion": "1.0" } }, { "awsLogSource": { "sourceName": "VPC_FLOW", "sourceVersion": "1.0" } }, { "customLogSource": { "attributes": { "crawlerArn": "arn:aws:glue:eu-west-2:123456789012:crawler/E1WG1ZNPRXT0D4", "databaseArn": "arn:aws:glue:eu-west-2:123456789012:database/E1WG1ZNPRXT0D4", "tableArn": "arn:aws:glue:eu-west-2:123456789012:table/E1WG1ZNPRXT0D4" }, "provider": { "location": "amzn-s3-demo-bucket--usw2-az1--x-s3", "roleArn": "arn:aws:iam::123456789012:role/AmazonSecurityLake-E1WG1ZNPRXT0D4" }, "sourceName": "testCustom2" } } ], "subscriberArn": "arn:aws:securitylake:eu-west-2:123456789012:subscriber/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "subscriberId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "subscriberIdentity": { "externalId": "123456789012", "principal": "123456789012" }, "subscriberName": "test", "subscriberStatus": "ACTIVE", "updatedAt": "2024-07-18T20:47:37.098000+00:00" } }

Per ulteriori informazioni, consulta Gestione degli abbonati nella Guida per l’utente di Amazon Security Lake.