Reputation: 155
I have application what uses DynamoDB. I raise Dynamo with docker and work with it using DynamoDbClient. Actually, I have been using docker for dynamo for some time. I used testcontainers lib and created GenericContainer with "amazon/dynamodb-local:latest" image. And all was fine. But recently I started using other AWS technologies such as S3 and SQS, so I decided to use LocalStack Container for all this technologies. Use the same clients and configuration. And all is good with S3 and SQS, but Dynamo started failing on executeStatement method which process my PartiQL statments(it is important to me to use exactly PartiQL, not embedded methods in sdk for Java) with exception "DynamoDbException: An unknown operation was requested". I cant understand where is the problem because I changed only docker container. Here is me code for docker raising:
private static final DockerImageName DOCKER_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
.withTag("latest");
GenericContainer<?> localStackContainer = new LocalStackContainer(DOCKER_IMAGE_NAME)
.withServices(SQS, S3, DYNAMODB)
localStackContainer.start();
Configuration: (It is written on scala, but it's not important for this question) *Port in endpoint dynamically replaced with a docker-created port
dynamodb {
region = "eu-central-1"
endpoint = "http://localhost:4569"
accessKeyId = "DEFAULT_ACCESS_KEY"
secretAccessKey = "DEFAULT_SECRET"
sessionToken = "DEFAULT_SESSION_TOKEN"
}
Client creating:
@Bean
public DynamoDbClient dynamodb(final GlobalConfiguration globalConfiguration) {
GlobalConfiguration.Dynamodb ddb = globalConfiguration.dynamodb();
URI uri = URI.create(ddb.endpoint());
Region region = Region.of(ddb.region());
AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(ddb.accessKeyId(), ddb.secretAccessKey());
StaticCredentialsProvider staticCredentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials);
return DynamoDbClient.builder()
.endpointOverride(uri)
.region(region)
.credentialsProvider(staticCredentialsProvider)
.build();
}
Place where code fails:
dynamoDbClient.executeStatement(builder -> builder.statement(query));
Upvotes: 1
Views: 693
Reputation: 5776
Looks like localstack's DynamoDB implementation doesn't support PartiQL just yet. Hopefully soon!
Upvotes: 0