Я успешно создал таблицу в AWS DynamodB, но когда я пытаюсь получить данные с помощью «DynamoDBMapper.load ()», я получаю AccessDeniedException
private AmazonDynamoDB client = config.amazonDynamoDB();
private DynamoDBMapper dbMapper = config.dynamoDbMapper(client);
@Value(${SOME_VALUE})
private String tableName;
public void createTable() {
CreateTableRequest request = this.dbMapper
.generateCreateTableRequest(MyEntity.class)
.withTableName(prefix + tableName)
.withProvisionedThroughput(new ProvisionedThroughput(LONG_5, LONG_10));
request.getGlobalSecondaryIndexes().get(0)
.setProvisionedThroughput(new ProvisionedThroughput(LONG_5, LONG_10));
request.getGlobalSecondaryIndexes().get(0)
.setProjection(new Projection().withProjectionType("ALL"));
}
public MyEntity getEntityByName(String name){
MyEntity myEntity = dbMapper.load(MyEntity.class, name);
return myEntity;
}
иесли используется метод "AmazonDynamoDB.query ()", то я получаю ноль
public MyEntity getEntityByName(String name){
Map<String, String> expressionAttributesName = new HashMap<>();
expressionAttributesName.put("#name", "name");
Map<String, AttributeValue> expressionAttributesValue = new
HashMap<String, AttributeValue>();
expressionAttributesValue.put(":name", new
AttributeValue().withS(name));
QueryRequest queryRequest = new QueryRequest()
.withTableName(prefix + tableName)
.withIndexName("eventIdIndex")
.withFilterExpression("#name =:name")
.withExpressionAttributeNames(expressionAttributesName)
.withExpressionAttributeValues(expressionAttributesValue);
QueryResult queryResult = client.query(queryRequest);
List<Map<String, AttributeValue>> attributeValues =
queryResult.getItems();
LOG.debug("attributeValues items size from DB " +
attributeValues.size());
if (attributeValues.size() > 0) {
MyEntity myEntity = dbMapper.marshallIntoObject(MyEntity.class,
attributeValues.get(0));
return myEntity;
}