Help Center/ GeminiDB/ GeminiDB DynamoDB-Compatible API/ Best Practices/ Buying and Connecting to a GeminiDB DynamoDB-Compatible Instance
Updated on 2025-07-30 GMT+08:00

Buying and Connecting to a GeminiDB DynamoDB-Compatible Instance

This section describes how to buy and connect to a GeminiDB DynamoDB-Compatible instance running on a Linux ECS.

Buying a GeminiDB DynamoDB-Compatible instance

  1. Log in to the Huawei Cloud console.
  2. In the service list, choose Databases > GeminiDB.
  3. On the Instances page, click Buy DB Instance.
  4. Click Buy DB Instance, select a billing mode, and configure instance parameters. Then, click Next and complete subsequent operations.

    Figure 1 Basic information

    Figure 2 Setting a password

  5. View the purchased GeminiDB DynamoDB-Compatible instance.

    Figure 3 Available instance

Buying an ECS

  1. Log in to the Huawei Cloud console.
  2. In the service list, choose Compute > Elastic Cloud Server. On the Elastic Cloud Server console, click Buy ECS.
  3. Configure basic settings and click Next: Configure Network. The ECS and GeminiDB DynamoDB-Compatible instance must be deployed in the same region, AZ, VPC, and security group.

    Figure 4 Basic settings
    Figure 5 Selecting specifications
    Figure 6 Selecting an image

  4. Configure the network and click Next: Configure Advanced Settings. The ECS and the GeminiDB DynamoDB-Compatible instance must be in the same VPC and security group.

    • If security group rules allow access from the ECS, you can connect to the instance using the ECS.
    • If the security group rules do not allow access from the ECS, add an inbound rule to the security group.
    Figure 7 Network settings
    Figure 8 Selecting an EIP

  5. Configure a password for the ECS and click Next: Confirm.

    Figure 9 Advanced settings

  6. Confirm the configurations and click Submit.

    Figure 10 Confirming the configurations

  7. View the purchased ECS.

Connecting to the GeminiDB DynamoDB-Compatible Instance

  1. In the navigation pane, choose Connections to obtain the private IP address and EIP of the instance.

    Figure 11 Viewing the IP address

  2. Replace the IP address in the following code example with the IP address queried in Step 1.

    Java code example:

    package com.huawei.dbs.test;  
    
    import com.huawei.dbs.RequestHandler;  
    
    import com.amazonaws.SDKGlobalConfiguration;  
    import com.amazonaws.auth.AWSCredentialsProvider;  
    import com.amazonaws.auth.AWSStaticCredentialsProvider;  
    import com.amazonaws.auth.BasicAWSCredentials;  
    import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;  
    import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;  
    import com.amazonaws.services.dynamodbv2.document.DynamoDB;  
    import com.amazonaws.services.dynamodbv2.document.TableCollection;  
    
    import java.net.URI;  
      
    
    public class V1Demo {  
        public static AWSCredentialsProvider myCredentials = new AWSStaticCredentialsProvider(  
            new BasicAWSCredentials("your_ak", "your_sk"));  
        public static String ip = "***.***.***.***";  
        public static void main(String[] args) {  
            disableCertificateChecks();  
            AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()  
                .withRegion("region-a")  
                .withRequestHandlers(new RequestHandler(URI.create("http://" + ip + "8000")))  
                .withCredentials(myCredentials)  
                .build();  
            DynamoDB dynamoDB = new DynamoDB(client);  
            TableCollection res = dynamoDB.listTables();  
            System.out.println(res);  
        }  
      
    }

(Optional) Connecting to the Instance over HTTPS

Prerequisites:

1. For compatibility purposes, you can still use HTTP after SSL is enabled. To meet high security requirements, you can modify a parameter to disable HTTP. For details, choose Service Tickets > Create Service Ticket in the upper right corner of the console and contact the customer service.

2. Currently, an EIP cannot be used over HTTPS.

Add Maven dependencies. Add dependencies related to AWS SDK for Java 2.x to the pom.xml file.
<dependencies>
     <dependency>
         <groupId>software.amazon.awssdk</groupId>
         <artifactId>dynamodb</artifactId>
         <version>2.x.x</version>
     </dependency>
 </dependencies>

Connect to the GeminiDB DynamoDB-Compatible instance using DynamoDBClient over HTTPS.

Java code example:
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.model.*;
public class SourceDemo {
// AK/SK credentials can be automatically obtained from environment variable file home/.aws/credentials.
// If there is no such a file, you need to manually specify the AK/SK.
    public static AWSCredentialsProvider myCredentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials("your_ak", "your_sk"));
    public static void main(String[] args) {
        AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
                .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://127.0.0.1:8000", "region_a"))
                .withCredentials(myCredentials)
                .build();
        System.out.println(client.listTables());
        CreateTableRequest request = new CreateTableRequest()
                .withTableName("test_001")
                .withProvisionedThroughput(new ProvisionedThroughput(1000L, 1000L))
                .withKeySchema(
                        new KeySchemaElement("id", KeyType.HASH)
                )
                .withAttributeDefinitions(
                        new AttributeDefinition("id", ScalarAttributeType.N)
                );
        System.out.println(client.createTable(request));
    }
}

GeminiDB DynamoDB-Compatible API is completely compatible with DynamoDB. For details about common operations, see official DynamoDB documents.