How to Create DynamoDB Table Using AWS CLI

Traditional databases can’t handle scalability if a large number of data is entered suddenly. AWS DynamoDB is built to handle internet-scale applications in Amazon. It is a fully managed service, so the user doesn’t have to worry about patching or upgrading the databases to the latest version. This post will discuss creating a table in Amazon DynamoDB using AWS CLI.

Create DynamoDB Table Using AWS CLI

To create a table in DynamoDB using AWS CLI, configure the AWS by typing the following command on the Command Prompt:

aws configure

To configure the AWS CLI, provide the credentials mentioned in the following screenshot. After that, the AWS CLI will be configured to use the AWS services:

To check the tables available on the DynamoDB, use the following command:

aws dynamodb list-tables

Running this command will display the list of all the tables present on the AWS DynamoDB:

The following is the syntax for the command to create the table in DynamoDB in AWS:

aws dynamodb create-table
    --table-name [table_name]
    --attribute-definitions [attribute_definition(s)]
    --key-schema [key_schema]
    --provisioned-throughput [provisioned_throughput]
    [other options]

If you wish to create a new table using the Syntax mentioned above, then simply fill in the values of the attributes accordingly, for example, to create a table for Music Collection, then command will become:

aws dynamodb create-table --table-name MusicCollection
--attribute-definitions AttributeName=Artist, AttributeType=S AttributeName=SongTitle, AttributeType=S --key-schema AttributeName=Artist, KeyType=HASH AttributeName=SongTitle, KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5, WriteCapacityUnits=5
--tags Key=Owner, Value=blueTeam

Side Note: Fill in the values of the attributes according to the table that you want to create

Executing the command will produce this output onto the terminal:

The table has been created on DynamoDB using the above command:

You have successfully created the DynamoDB table using the AWS CLI:

Conclusion

To create the DynamoDB table using the AWS CLI, simply configure the AWS CLI using the command prompt. After that, use the syntax and demo command available in the post. Running the command will create the table in AWS DynamoDB. This post has taught you how to create a table in AWS DynamoDB using the AWS CLI.



from https://ift.tt/ArqDzh7

Post a Comment

0 Comments