AWS DynamoDB Setup
In this article will see "How to Generate Access Key and Secret Key" to connect to DynamoDB from our Spring Boot Application.
AWS DynamoDB Tutorial :
- AWS DynamoDB Setup
- Spring Boot + DynamoDB Crud Example
- AWS DynamoDB Interview Questions and Answers
What is DynamoDB?
DynamoDB is NoSQL database, it can handle structured or semi structured data, including JSON documents. DynamoDB scales to accommodate very large amounts of data and very large number of users seamlessly.
SQL is the standard for storing and retrieving data. Relational databases have a wide range of tools available for simplifying the development of database-driven applications, however all of these tools uses SQL.
Generate DynamoDB Access Key And Secret Key
Let's login to AWS account, if you don't have AWS Account, you can signup and get AWS free account.
Login to AWS Account
DynamoDB
Follow below steps to create table in DynamoDB.
- Search for DynamoDB in the search box as shown below:
- Click on 'Create table'.
- Create Customer table with primary key.
Take a look at our suggested posts:
IAM (Identity Access Management)
Now, lets go to IAM (Identity Access Management), in order to generate access key and secret key to connect to DynamoDB from our code.
CREATE USER GROUP
- Click on 'User Group'.
- Click on 'Create group'.
- Provide user group name 'techgeeknext-group'.
- Scroll down after providing user group name and select 'AmazonEC2FullAccess' and click on 'Create group'.
Note: Don't worry in below steps will add restrictions on AmazonEC2FullAccess using Policy, and provide specific crud access. - User group 'techgeeknext-group' will get created.
CREATE USER
Follow below steps to generate access key and secret key.
- Now, Click on 'Users -> Add user'.
- Provide user name 'techgeeknext-user', allow for Programmatic access and click on 'Next: Permissions'.
- Now, select the user group that we have created above as techgeeknext-group and click on 'Next: Tags'.
- It's an optional field, will not provide any value here and click on 'Next: Review'.
- Click on 'Create user' to create the user.
- After user is created, it will generate Access Key and Secret Key. Copy or Download the keys so that we can use these keys in our program to connect to DynamoDB.
CREATE POLICY
Create policy in order to give specific permission to user like PutItem, GetItem etc.
- Click on Policies -> Create policy.
- Click on 'JSON' tab and provide below snippet to allow permission access for crud operations and click on 'Review policy'. Note: Copy below snippet from Statement, and keep your Version as is else it'll give error.
- Click on 'Next: Review'.
- Provide policy name 'techgeeknext-policy' and click on 'Create Policy'.
- Policy got created successfully.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:PutItem"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"dynamodb:DeleteItem"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"sns:Publish"
],
"Resource": [
"*"
]
}
]
}
ATTACH POLICY
- Go in Policies and search for created policy 'techgeeknext-policy', select policy, click on drop-down called 'Policy actions' and click on 'attach'.
- Click on 'Attach policy' and all setup will be done to proceed to our development of Spring Boot +DynamoDB Application.