Skip to content

OpenSearch API Gateway CLI Guide

The search-hq opensearch-gateway command-line interface (CLI) allows you to manage and operate the OpenSearch API Gateway service. This includes downloading configurations, deploying the service, retrieving API information, and destroying the service.

Getting Started

To get started with the search-hq CLI, run the following command to see an overview of available options and commands:

search-hq opensearch-gateway --help

This command will display a summary of the CLI usage, including available commands and options:

Usage: search-hq opensearch-gateway [OPTIONS] COMMAND [ARGS]...

  Operate OpenSearch API Gateway service.

Options:
  --help  Show this message and exit.

Commands:
  deploy         Deploy OpenSearch API Gateway service.
  destroy        Destroy OpenSearch API Gateway service.
  download-conf  Download configurations used by OpenSearch API Gateway service.
  get-api-info   Get API URL and Key.

Download Configurations

The download-conf command downloads the configurations used by the OpenSearch API Gateway service from Amazon S3. When you deploy the OpenSearch API Gateway service, the configurations are automatically uploaded to Amazon S3. Therefore, you can use this command to download the configurations for comparison. You need to pass the parameter dest_folder to specify the destination folder where the configurations will be saved.

Command:

search-hq opensearch-gateway download-conf \
--dest_folder <DEST_FOLDER>
Option Type Required Description
dest_folder String Required The destination folder where the configurations will be saved.

Example Usage:

search-hq opensearch-gateway download-conf \
--dest_folder dest_conf_folder

Deploy OpenSearch API Gateway service

The deploy command deploys the OpenSearch API Gateway service. This command uses configurations from your project settings to ensure that the service is deployed correctly and synchronized with your AWS environment.

Command:

search-hq opensearch-gateway deploy  \
--auto_approve <AUTO_APPROVE>
Option Type Required Description
auto_approve Boolean Optional Automatically approve all prompts during deployment without manual confirmation. Default is True.

Example Usage:

search-hq opensearch-gateway deploy  \
--auto_approve True

Get API URL and Key

The get-api-info command retrieves the API URL and Key for the OpenSearch API Gateway service. This information is crucial for accessing the service and performing operations via the API.

Command:

search-hq opensearch-gateway get-api-info

List CloudFormation Stack Resources

The search-hq resources command lists the resources for CloudFormation stacks. This is useful for reviewing the components that have been deployed, including infrastructure, services, and other resources managed by the application.

To list resources for all CloudFormation stacks, use:

search-hq resources

To list resources for particular CloudFormation stacks, use:

search-hq resources <STACK_NAMES>

Replace <STACK_NAMES> with the names of the stacks you want to query.

Display CloudFormation Stack Statuses

Use the search-hq status command to display the statuses of CloudFormation stacks, including current status, creation time, and last updated time.

To list the statuses of all CloudFormation stacks, use:

search-hq status

To list the statuses of specific CloudFormation stacks, use:

search-hq status <STACK_NAMES>

Replace <STACK_NAMES> with the names of the stacks you want to query.

Destroy OpenSearch API Gateway service

The destroy command is used to remove the OpenSearch API Gateway service and associated resources. This is necessary when you need to clean up resources or decommission the service from your AWS environment. Properly managing the lifecycle of your services is crucial for maintaining an organized and cost-efficient AWS environment.

Command:

search-hq opensearch-gateway destroy  \
--auto_approve <AUTO_APPROVE>  \
--destroy_infra <DESTROY_INFRA>
Option Type Required Description
auto_approve Boolean Optional Automatically approve all prompts during destruction without manual confirmation. Default is True.
destroy_infra Boolean Required Destroy the application infrastructure if needed.

Example Usage:

search-hq opensearch-gateway destroy  \
--auto_approve True  \
--destroy_infra False

Remove Associated Resources

By default, the destroy command will retain the Amazon S3 bucket and AWS Systems Manager Parameter Store associated with your search-hq deployment. You can choose to manually delete these resources if needed.

  • Remove Objects from Amazon S3 Bucket: To delete the entire Amazon S3 bucket associated with your search-hq deployment, use the following command. This will remove the entire bucket and all objects within it:

    python -m operation.cli.s3 delete_bucket
    

    If you only need to delete a single object from the Amazon S3 bucket, use:

    python -m operation.cli.s3 delete_object --key <S3_OBJECT_KEY>
    

    Replace <S3_OBJECT_KEY> with the key of the object you want to delete from the Amazon S3 bucket.

  • Remove Parameters from AWS Systems Manager Parameter Store: To delete all parameters associated with your search-hq deployment from AWS Systems Manager Parameter Store, use:

    python -m operation.cli.ssm delete_ssm_parameters
    

    If you only need to delete a single parameter, use:

    python -m operation.cli.ssm delete_ssm_parameter --parameter_name <PARAMETER_NAME>
    

    Replace <PARAMETER_NAME> with the name of the parameter you want to delete from the AWS Systems Manager Parameter Store.