tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

How to enable DynamoDB using Roles instead of accesskey?

Open vivekkannan05 opened this issue 7 years ago • 5 comments

If I wanted to use the project spring-data-dynamodb as a lambda service. How can I make the DynamoDB client to make use of roles instead of access key and secret key?

vivekkannan05 avatar Jan 13 '19 06:01 vivekkannan05

@vivekkannan05 could you please let us know to which article you're referring to?

maibin avatar Jan 14 '19 18:01 maibin

@maibin : Thanks you for replying. This is the article(https://www.baeldung.com/spring-data-dynamodb). I'm talking about. In this article we are connecting to Spring Boot application to DynamoDB using Accesskey and secret keys, Say if we are hosting this application in EC2 or lambda then we can use roles. In that case, what would be the best option to make use of roles instead of access key and secret access key. I think this would help many Java developers who would like to make their application serverless.

I was not able to add a comment in the article, that is why raised an issue here. https://www.baeldung.com/spring-data-dynamodb https://github.com/eugenp/tutorials/tree/master/persistence-modules/spring-data-dynamodb

Thanks.

vivekkannan05 avatar Jan 15 '19 07:01 vivekkannan05

@vivekkannan05 , I don't know how roles work in combination with a local DynamoDB instance.

However, with a deployment on Lambda and the AWS-operated DynamoDB, it works for me to just use the default constructor of AmazonDynamoDBClient() in the DynamoDBConfig, without the credentials. Of course, the Lambda function needs an according role attached to it (I guess that the same works for a deployment on EC2).

Please be also advised that the AmazonDynamoDBClient is deprecated now, and you should use AmazonDynamoDBClientBuilder instead.

markusgulden avatar Jan 20 '19 18:01 markusgulden

@vivekkannan05 does it answer your question?

maibin avatar Jan 20 '19 19:01 maibin

@maibin & @markusgulden It works. It was my mistake that I had missed to include DynamoDBMapper. Thanks guys for your time.

vivekkannan05 avatar Jan 20 '19 22:01 vivekkannan05