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à.
OpenSearch Esempi di servizi che utilizzano AWS CLI
I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface with OpenSearch Service.
Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni di servizio, è possibile visualizzare le azioni nel contesto negli scenari correlati.
Ogni esempio include un collegamento al codice sorgente completo, in cui è possibile trovare istruzioni su come configurare ed eseguire il codice nel contesto.
Argomenti
Azioni
Il seguente esempio di codice mostra come utilizzarecreate-elasticsearch-domain
.
- AWS CLI
-
Per creare un dominio Amazon Elasticsearch Service
Il
create-elasticsearch-domain
comando seguente crea un nuovo dominio Amazon Elasticsearch Service all'interno di un VPC e limita l'accesso a un singolo utente. Amazon ES deduce l'VPCID dalla sottorete e dal gruppo di sicurezza specificati. IDsaws es create-elasticsearch-domain \ --domain-name
vpc-cli-example
\ --elasticsearch-version6.2
\ --elasticsearch-cluster-configInstanceType=m4.large.elasticsearch,InstanceCount=1
\ --ebs-optionsEBSEnabled=true,VolumeType=standard,VolumeSize=10
\ --access-policies '{"Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": {"AWS": "arn:aws:iam::123456789012:root" }, "Action":"es:*", "Resource": "arn:aws:es:us-west-1:123456789012:domain/vpc-cli-example/*" } ] }
' \ --vpc-optionsSubnetIds=subnet-1a2a3a4a,SecurityGroupIds=sg-2a3a4a5a
Output:
{ "DomainStatus": { "ElasticsearchClusterConfig": { "DedicatedMasterEnabled": false, "InstanceCount": 1, "ZoneAwarenessEnabled": false, "InstanceType": "m4.large.elasticsearch" }, "DomainId": "123456789012/vpc-cli-example", "CognitoOptions": { "Enabled": false }, "VPCOptions": { "SubnetIds": [ "subnet-1a2a3a4a" ], "VPCId": "vpc-3a4a5a6a", "SecurityGroupIds": [ "sg-2a3a4a5a" ], "AvailabilityZones": [ "us-west-1c" ] }, "Created": true, "Deleted": false, "EBSOptions": { "VolumeSize": 10, "VolumeType": "standard", "EBSEnabled": true }, "Processing": true, "DomainName": "vpc-cli-example", "SnapshotOptions": { "AutomatedSnapshotStartHour": 0 }, "ElasticsearchVersion": "6.2", "AccessPolicies": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:root\"},\"Action\":\"es:*\",\"Resource\":\"arn:aws:es:us-west-1:123456789012:domain/vpc-cli-example/*\"}]}", "AdvancedOptions": { "rest.action.multi.allow_explicit_index": "true" }, "EncryptionAtRestOptions": { "Enabled": false }, "ARN": "arn:aws:es:us-west-1:123456789012:domain/vpc-cli-example" } }
Per ulteriori informazioni, consulta Creating and Managing Amazon Elasticsearch Service Domains nella Amazon Elasticsearch Service Developer Guide.
-
Per i API dettagli, consulta Command Reference. CreateElasticsearchDomain
AWS CLI
-
Il seguente esempio di codice mostra come utilizzaredescribe-elasticsearch-domain-config
.
- AWS CLI
-
Per ottenere i dettagli sulla configurazione del dominio
L'
describe-elasticsearch-domain-config
esempio seguente fornisce i dettagli di configurazione per un determinato dominio, insieme alle informazioni sullo stato per ogni singolo componente del dominio.aws es describe-elasticsearch-domain-config \ --domain-name
cli-example
Output:
{ "DomainConfig": { "ElasticsearchVersion": { "Options": "7.4", "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "ElasticsearchClusterConfig": { "Options": { "InstanceType": "c5.large.elasticsearch", "InstanceCount": 1, "DedicatedMasterEnabled": true, "ZoneAwarenessEnabled": false, "DedicatedMasterType": "c5.large.elasticsearch", "DedicatedMasterCount": 3, "WarmEnabled": true, "WarmType": "ultrawarm1.medium.elasticsearch", "WarmCount": 2 }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "EBSOptions": { "Options": { "EBSEnabled": true, "VolumeType": "gp2", "VolumeSize": 10 }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "AccessPolicies": { "Options": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",\"Resource\":\"arn:aws:es:us-east-1:123456789012:domain/cli-example/*\"}]}", "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "SnapshotOptions": { "Options": { "AutomatedSnapshotStartHour": 0 }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "VPCOptions": { "Options": {}, "Status": { "CreationDate": 1591210426.162, "UpdateDate": 1591210426.162, "UpdateVersion": 18, "State": "Active", "PendingDeletion": false } }, "CognitoOptions": { "Options": { "Enabled": false }, "Status": { "CreationDate": 1591210426.163, "UpdateDate": 1591210426.163, "UpdateVersion": 18, "State": "Active", "PendingDeletion": false } }, "EncryptionAtRestOptions": { "Options": { "Enabled": true, "KmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/1a2a3a4a-1a2a-1a2a-1a2a-1a2a3a4a5a6a" }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "NodeToNodeEncryptionOptions": { "Options": { "Enabled": true }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "AdvancedOptions": { "Options": { "rest.action.multi.allow_explicit_index": "true" }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "LogPublishingOptions": { "Options": {}, "Status": { "CreationDate": 1591210426.164, "UpdateDate": 1591210426.164, "UpdateVersion": 18, "State": "Active", "PendingDeletion": false } }, "DomainEndpointOptions": { "Options": { "EnforceHTTPS": true, "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589395827.325, "UpdateVersion": 8, "State": "Active", "PendingDeletion": false } }, "AdvancedSecurityOptions": { "Options": { "Enabled": true, "InternalUserDatabaseEnabled": true }, "Status": { "CreationDate": 1589395034.946, "UpdateDate": 1589827485.577, "UpdateVersion": 14, "State": "Active", "PendingDeletion": false } } } }
Per ulteriori informazioni, consulta Creating and Managing Amazon Elasticsearch Service Domains nella Amazon Elasticsearch Service Developer Guide.
-
Per i API dettagli, consulta Command Reference. DescribeElasticsearchDomainConfig
AWS CLI
-
Il seguente esempio di codice mostra come utilizzaredescribe-elasticsearch-domain
.
- AWS CLI
-
Per ottenere dettagli per un singolo dominio
L'
describe-elasticsearch-domain
esempio seguente fornisce i dettagli di configurazione per un determinato dominio.aws es describe-elasticsearch-domain \ --domain-name
cli-example
Output:
{ "DomainStatus": { "DomainId": "123456789012/cli-example", "DomainName": "cli-example", "ARN": "arn:aws:es:us-east-1:123456789012:domain/cli-example", "Created": true, "Deleted": false, "Endpoint": "search-cli-example-1a2a3a4a5a6a7a8a9a0a.us-east-1.es.amazonaws.com", "Processing": false, "UpgradeProcessing": false, "ElasticsearchVersion": "7.4", "ElasticsearchClusterConfig": { "InstanceType": "c5.large.elasticsearch", "InstanceCount": 1, "DedicatedMasterEnabled": true, "ZoneAwarenessEnabled": false, "DedicatedMasterType": "c5.large.elasticsearch", "DedicatedMasterCount": 3, "WarmEnabled": true, "WarmType": "ultrawarm1.medium.elasticsearch", "WarmCount": 2 }, "EBSOptions": { "EBSEnabled": true, "VolumeType": "gp2", "VolumeSize": 10 }, "AccessPolicies": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",\"Resource\":\"arn:aws:es:us-east-1:123456789012:domain/cli-example/*\"}]}", "SnapshotOptions": { "AutomatedSnapshotStartHour": 0 }, "CognitoOptions": { "Enabled": false }, "EncryptionAtRestOptions": { "Enabled": true, "KmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/1a2a3a4a-1a2a-1a2a-1a2a-1a2a3a4a5a6a" }, "NodeToNodeEncryptionOptions": { "Enabled": true }, "AdvancedOptions": { "rest.action.multi.allow_explicit_index": "true" }, "ServiceSoftwareOptions": { "CurrentVersion": "R20200522", "NewVersion": "", "UpdateAvailable": false, "Cancellable": false, "UpdateStatus": "COMPLETED", "Description": "There is no software update available for this domain.", "AutomatedUpdateDate": 0.0 }, "DomainEndpointOptions": { "EnforceHTTPS": true, "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" }, "AdvancedSecurityOptions": { "Enabled": true, "InternalUserDatabaseEnabled": true } } }
Per ulteriori informazioni, consulta Creating and Managing Amazon Elasticsearch Service Domains nella Amazon Elasticsearch Service Developer Guide.
-
Per i API dettagli, consulta Command Reference. DescribeElasticsearchDomain
AWS CLI
-
Il seguente esempio di codice mostra come utilizzaredescribe-elasticsearch-domains
.
- AWS CLI
-
Per ottenere dettagli su uno o più domini
L'
describe-elasticsearch-domains
esempio seguente fornisce i dettagli di configurazione per uno o più domini.aws es describe-elasticsearch-domains \ --domain-names
cli-example-1
cli-example-2
Output:
{ "DomainStatusList": [{ "DomainId": "123456789012/cli-example-1", "DomainName": "cli-example-1", "ARN": "arn:aws:es:us-east-1:123456789012:domain/cli-example-1", "Created": true, "Deleted": false, "Endpoint": "search-cli-example-1-1a2a3a4a5a6a7a8a9a0a.us-east-1.es.amazonaws.com", "Processing": false, "UpgradeProcessing": false, "ElasticsearchVersion": "7.4", "ElasticsearchClusterConfig": { "InstanceType": "c5.large.elasticsearch", "InstanceCount": 1, "DedicatedMasterEnabled": true, "ZoneAwarenessEnabled": false, "DedicatedMasterType": "c5.large.elasticsearch", "DedicatedMasterCount": 3, "WarmEnabled": true, "WarmType": "ultrawarm1.medium.elasticsearch", "WarmCount": 2 }, "EBSOptions": { "EBSEnabled": true, "VolumeType": "gp2", "VolumeSize": 10 }, "AccessPolicies": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",\"Resource\":\"arn:aws:es:us-east-1:123456789012:domain/cli-example-1/*\"}]}", "SnapshotOptions": { "AutomatedSnapshotStartHour": 0 }, "CognitoOptions": { "Enabled": false }, "EncryptionAtRestOptions": { "Enabled": true, "KmsKeyId": "arn:aws:kms:us-east-1:123456789012:key/1a2a3a4a-1a2a-1a2a-1a2a-1a2a3a4a5a6a" }, "NodeToNodeEncryptionOptions": { "Enabled": true }, "AdvancedOptions": { "rest.action.multi.allow_explicit_index": "true" }, "ServiceSoftwareOptions": { "CurrentVersion": "R20200522", "NewVersion": "", "UpdateAvailable": false, "Cancellable": false, "UpdateStatus": "COMPLETED", "Description": "There is no software update available for this domain.", "AutomatedUpdateDate": 0.0 }, "DomainEndpointOptions": { "EnforceHTTPS": true, "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" }, "AdvancedSecurityOptions": { "Enabled": true, "InternalUserDatabaseEnabled": true } }, { "DomainId": "123456789012/cli-example-2", "DomainName": "cli-example-2", "ARN": "arn:aws:es:us-east-1:123456789012:domain/cli-example-2", "Created": true, "Deleted": false, "Processing": true, "UpgradeProcessing": false, "ElasticsearchVersion": "7.4", "ElasticsearchClusterConfig": { "InstanceType": "r5.large.elasticsearch", "InstanceCount": 1, "DedicatedMasterEnabled": false, "ZoneAwarenessEnabled": false, "WarmEnabled": false }, "EBSOptions": { "EBSEnabled": true, "VolumeType": "gp2", "VolumeSize": 10 }, "AccessPolicies": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",\"Resource\":\"arn:aws:es:us-east-1:123456789012:domain/cli-example-2/*\"}]}", "SnapshotOptions": { "AutomatedSnapshotStartHour": 0 }, "CognitoOptions": { "Enabled": false }, "EncryptionAtRestOptions": { "Enabled": false }, "NodeToNodeEncryptionOptions": { "Enabled": false }, "AdvancedOptions": { "rest.action.multi.allow_explicit_index": "true" }, "ServiceSoftwareOptions": { "CurrentVersion": "", "NewVersion": "", "UpdateAvailable": false, "Cancellable": false, "UpdateStatus": "COMPLETED", "Description": "There is no software update available for this domain.", "AutomatedUpdateDate": 0.0 }, "DomainEndpointOptions": { "EnforceHTTPS": false, "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" }, "AdvancedSecurityOptions": { "Enabled": false, "InternalUserDatabaseEnabled": false } } ] }
Per ulteriori informazioni, consulta Creating and Managing Amazon Elasticsearch Service Domains nella Amazon Elasticsearch Service Developer Guide.
-
Per i API dettagli, consulta Command Reference. DescribeElasticsearchDomains
AWS CLI
-
Il seguente esempio di codice mostra come utilizzaredescribe-reserved-elasticsearch-instances
.
- AWS CLI
-
Per visualizzare tutte le istanze riservate
L'
describe-elasticsearch-domains
esempio seguente fornisce un riepilogo di tutte le istanze prenotate in una regione.aws es describe-reserved-elasticsearch-instances
Output:
{ "ReservedElasticsearchInstances": [{ "FixedPrice": 100.0, "ReservedElasticsearchInstanceOfferingId": "1a2a3a4a5-1a2a-3a4a-5a6a-1a2a3a4a5a6a", "ReservationName": "my-reservation", "PaymentOption": "PARTIAL_UPFRONT", "UsagePrice": 0.0, "ReservedElasticsearchInstanceId": "9a8a7a6a-5a4a-3a2a-1a0a-9a8a7a6a5a4a", "RecurringCharges": [{ "RecurringChargeAmount": 0.603, "RecurringChargeFrequency": "Hourly" }], "State": "payment-pending", "StartTime": 1522872571.229, "ElasticsearchInstanceCount": 3, "Duration": 31536000, "ElasticsearchInstanceType": "m4.2xlarge.elasticsearch", "CurrencyCode": "USD" }] }
Per ulteriori informazioni, consulta Reserved Instances nella Amazon Elasticsearch Service Developer Guide.
-
Per API i dettagli, consulta Command DescribeReservedElasticsearchInstances
Reference AWS CLI .
-
Il seguente esempio di codice mostra come utilizzarelist-domain-names
.
- AWS CLI
-
Per elencare tutti i domini
L'
list-domain-names
esempio seguente fornisce un breve riepilogo di tutti i domini della regione.aws es list-domain-names
Output:
{ "DomainNames": [{ "DomainName": "cli-example-1" }, { "DomainName": "cli-example-2" } ] }
Per ulteriori informazioni, consulta Creating and Managing Amazon Elasticsearch Service Domains nella Amazon Elasticsearch Service Developer Guide.
-
Per i API dettagli, consulta Command Reference. ListDomainNames
AWS CLI
-