Create a DynamoDB Table Using AWS CloudFormation for Cloud and DevOps Engineers
Learning path for the AWS Cloud Practitioner exam
📝Introduction
In this blog post, we will cover a simple and intro hands-on lab, using CloudFormation to write the desired state of the infrastructure using code, which includes a DynamoDB table to hold inventory items.
📝Log in to the AWS Management Console
Using your credentials, make sure you're using the right Region. In my case, I chose us-east-1
.
📝Review and Download the CloudFormation Template
Navigate to the provided CloudFormation template for this lab:
AWSTemplateFormatVersion: 2010-09-09
Description: CloudFormation Template To Create Alfredo's Inventory DynamoDB Table
Resources:
InventoryTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: Inventory
AttributeDefinitions:
-
AttributeName: !Ref HashKeyElementName
AttributeType: !Ref HashKeyElementType
KeySchema:
-
AttributeName: !Ref HashKeyElementName
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Parameters:
HashKeyElementName:
Type: String
Default: InventoryId
Description: Hash Key Name
HashKeyElementType:
Type: String
Default: S
Description: Hash Key Type
Outputs:
Inventory:
Description: Alfredo's Inventory Table
Value: !Ref InventoryTable
Make sure the Format is YAML, and click to Save the file locally in your computer.
📝Launch the CloudFormation Stack
From the top search bar in the AWS Management Console, search for and navigate to CloudFormation.
Click Create stack > With new resources (standard).
Select Template is ready. Select Upload a template file. Click Choose file.
Select the YAML file you downloaded. Click Open. Click Next.
For Stack name, enter <name_stack>
. Click Next.
On the Configure stack options page leave everything as-is, and click Next.
On the Review <name_stack>
page, click Create stack.
Click the refresh icon in the upper-right section of the Events list to check the status of the stack being created.
Note: It will take a few minutes for the stack to create. You can view the progress of the stack creation in the Status column of the Events list.
📝Verify the DynamoDB Table Was Created
Once the stack is created, use the top search bar within the console to search for and navigate to DynamoDB.
From the left menu, click Tables. Click the listed Inventory table.
While there aren't currently any items within the table, it is ready for items to be added.
Congratulations — you've completed this hands-on lab covering the basics to Create a DynamoDB Table Using CloudFormation.
Thank you for reading. I hope you were able to understand and learn something helpful from my blog.
Please follow me on Hashnode and on LinkedIn franciscojblsouza