Updated on 2026-07-10 GMT+08:00

Connecting to a GeminiDB DynamoDB-Compatible Instance Using HTTPS

When using the GeminiDB DynamoDB-Compatible API to perform data operations, you must connect to the instance using HTTPS to ensure secure data transmission. This section describes how to connect to a GeminiDB DynamoDB-Compatible instance using HTTPS.

Usage Notes

  • The instance and ECS must be in the same region, VPC, and subnet.
  • The ECS must be allowed by the security group associated with the instance.

    Scenario 1: If the instance is associated with the default security group, you do not need to set security group rules.

    Scenario 2: If the instance is not associated with the default security group, check whether the security group rules allow access from the ECS.

  • Before the connection, enable SSL for the GeminiDB instance and download a certificate. Take a Java application as an example. The command for importing the certificate is as follows:
    keytool -importcert -alias hw -file ca.cert -keystore <cacerts_path> -storepass password

    You are advised to set cacerts_path to the default trust store file path of the JDK, for example, /~/jdk/jdk1.8.0_242/jre/lib/security/cacerts.

1. For compatibility purposes, HTTP access remains enabled after SSL is enabled, which may allow data to be transmitted in plaintext. To meet stringent security compliance requirements, disable HTTP access and retain only the HTTPS channel. For details, submit a service ticket on the console to contact the customer service.

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

Prerequisites

  • A GeminiDB DynamoDB-Compatible instance has been created.
  • An ECS has been created. For details about how to create an ECS, see Purchasing an ECS in the Elastic Cloud Server documentation.
  • JDK or Python has been installed on the ECS.

Procedure

GeminiDB is fully compatible with DynamoDB APIs. This section provides only some example code snippets.

  1. 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>

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

    Java 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 HttpsDemo {
        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://your_elb_ip", "cn-north-1"))
                    .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));
        }
    }

    Python example:

    import boto3
    
    ENDPOINT_URL = 'https://your_elb_ip'
    CA_BUNDLE_PATH = 'ca.crt'
    dynamodb = boto3.client(
    'dynamodb',
    aws_access_key_id = 'your_ak',
    aws_secret_access_key = 'your_sk',
    endpoint_url = ENDPOINT_URL,
    region_name = 'cn-north-1',
    verify = CA_BUNDLE_PATH
    )
    
    try:
        response = dynamodb.list_tables()
        print(response.get('TableNames'))
    except Exception as e:
        print(e)