Start with AWS CLI and DynamoDB.
Vero O
Posted on April 16, 2021
This guide will teach you the steps that you've to follow in order to start working with DynamoDB.
The main issues that all new users face when working with AWS are:
- Is hard to have a quick and global estimate of your costs. They've in most of it services a free tier, so don't be afraid to try it.
- Is hard to configure initially, because you don't have a step by step screen that'll guide you.
CONFIGURE YOUR ACCOUNT
1 - Create an account on AWS: https://aws.amazon.com/account/sign-up
2 - Create a user in IAM:
https://console.aws.amazon.com/iam/
a) Define the username that this user will have (ex. "publishers", "authors"), and then you have to choose the access method ( public and private key is recommended).
b) Define the policies or permissions that this user will have. This is important because you've to define all of it for the service that'll use.
c) Add tags if you want
d) Copy in a temporarily place the public key and the private key.
INSTALL THE AWS CLI ON YOUR SERVER
1 - Follow the AWS guide to install the CLI, according your server: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)
2 - When you're in the step of "configure", you'll have to add the private and public keys that you've written temporarily in "Configure your account. Step #2d".
Let's suppose you need to add a new service, or a new user.
Go Back to the step "Configure your account. Step #2" and create it.
Then find in your server the "credentials" file that AWS CLI creates (Ex. ~/.aws/credentials) and add a new "Block" of credentials for this new user, which AWS CLI Calls "profiles" to retrieve the information. I'll recommend you to use the same username that you've choose in "Configure your account. Step #2a" to avoid mistakes.
Ex:
~/.aws/credentials
[default]
aws_access_key_id=
aws_secret_access_key=
[authors]
aws_access_key_id=
aws_secret_access_key=
[publishers]
aws_access_key_id=
aws_secret_access_key=
WORK WITH DYNAMODB
1- Go to https://aws.amazon.com/es/dynamodb/ and enable your account
2 - Create your first table.
You'll have to define:
a) Table name
b) Table primary unique key name
c) Table secondary key name, called "order key" which can have duplicate values
3- Depending on your language, you've here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.html
examples of the basic actions that you can do: put
, delete
, describe
, query
You've to have in mind that this information is required to connect with dynamo:
a) The profile name that you'll use to manage the permissions, defined in "Install the AWS cli on your server, Step #2"
b) The region of your DynamoDB. You can find this information in the URL of your AWS DynamoDB account:
Ex:
https://{REGION}.console.aws.amazon.com/dynamodb/home?region={REGION}
About the actions:
- You can retrieve one record or all.
- PutItem works as well for adding new items an updating them, based on your primary key.
That 's all folks!
Posted on April 16, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.