I am experiencing an error on AWS DynamoDB that says:
[Request processing failed; nested exception is com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: VJ8R07B81ANC1047P1ANEDS4CRVV4KQNSO5AEMVJF66Q9ASUAAJG)] with root causecom.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: VJ8R07B81ANC1047P1ANEDS4CRVV4KQNSO5AEMVJF66Q9ASUAAJG)
with an actual DynamoDB Endpoint running in an EC2 instance. However, when I run the application and point it on my local DynamoDB, it works.
Anyone got a solution on this? Thanks.
Here's my config on DynamoDB
@Configuration
@EnableDynamoDBRepositories(basePackages = "**.****.***.repository")
public class DynamoConfig {
@Value("${aws.secret.key}")
private String awsSecretKey;
@Value("${aws.access.key}")
private String awsAccessKey;
@Value("${aws.dynamodb.endpoint}")
private String awsDynamoDBEndpoint;
@Value("${aws.region}")
private String awsRegion;
@Bean
public AmazonDynamoDB amazonDynamoDB() {
AmazonDynamoDBClientBuilder amazonDynamoDB = AmazonDynamoDBClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(amazonAWSCredentials()))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(awsDynamoDBEndpoint, awsRegion));
// amazonDynamoDB.setSignerRegionOverride(Regions.fromName(awsRegion).getName());
// if (!StringUtils.isEmpty(awsDynamoDBEndpoint)) {
// amazonDynamoDB.setEndpoint(awsDynamoDBEndpoint);
// }
return amazonDynamoDB.build();
}
@Bean
public AWSCredentials amazonAWSCredentials() {
return new BasicAWSCredentials(awsAccessKey, awsSecretKey);
}
}
P.S I have also tried running the application pointed to an actual DynamoDB Endpoint, I am encountering the same error.