AWS

4 Mins Read

Authenticated Access with AWS Cognito Identity Pools: Create a DynamoDB Table Using JavaScript SDK

Voiced by Amazon Polly

Introduction

In modern web and mobile applications, authentication plays a crucial role in ensuring secure access to resources. However, there are scenarios where we want users to interact with our application without requiring them to sign in. This is where AWS Cognito Identity Pools come in, allowing us to manage both authenticated (signed-in) and unauthenticated (guest) users efficiently.

What is an AWS Cognito Identity Pool?

AWS Cognito Identity Pools provide temporary AWS credentials to users so they can access AWS resources securely. These users can be:

Authenticated users (signed in via Cognito User Pools, Google, Facebook, etc.).

Unauthenticated users (guest access without login).

With an Identity Pool, we can define different IAM roles for authenticated and unauthenticated users, ensuring the right level of access control.

Why Do We Need Guest Access?

Guest access is useful when we want users to interact with certain parts of our application without forcing them to create an account. Some common use cases include:

  • Browsing products in an e-commerce app before signing up.
  • Submitting feedback or surveys without registration.
  • Accessing limited features of an app before logging in.
  • Gaming leaderboards or score tracking without requiring a login.

By enabling unauthenticated access through an Identity Pool, we can grant temporary, controlled access to AWS services like DynamoDB, S3, or API Gateway, allowing guest users to perform limited actions without compromising security.

Following are the steps involved in Authenticated Access with AWS Cognito Identity Pools: Create a DynamoDB Table Using JavaScript SDK

Drive Business Growth with AWS's Machine Learning Solutions

  • Scalable
  • Cost-effective
  • User-friendly
Connect Today

Step 1: Setting Up Cognito Identity Pool for Guest Access)

  • Go to AWS Cognito Console

Click on “Create identity pool”

  • Enter Identity Pool Name as shown below

Check “Enable access to unauthenticated identities” (for guest access) and Click Next.

Provide the Role name as “DynamoDBRole” and click Next

Review and Create Identity Pool.

  • Copy Identity Pool ID

Save it anywhere, as it’s needed in our JavaScript app.

Step 2: Update IAM Role Permissions for DynamoDB

Now, we need to allow Cognito guest users to create a DynamoDB table.

  • Go to AWS IAM Console

Open IAM Console and Click “Roles” as shown below.

  • Attach a Managed Policy for DynamoDB Access

Step 3: Build a JavaScript App to Create DynamoDB Table

Now, let’s write a JavaScript app that:
Connects to Cognito Identity Pool and Creates a DynamoDB Table

Replace the AWS Region and Cognito Identity Pool ID in the Code

Create an index.html

 

Step 4: Run & Test the App

Open index.html in a browser and click “Create Table”.

If successful, the DynamoDB table “Employee” is created.

Verify the table in AWS DynamoDB ConsoleTables.

Conclusion

AWS Cognito Identity Pools provide a powerful way to manage both authenticated and unauthenticated (guest) access to AWS resources securely. By enabling guest access, we allow users to interact with our application without requiring a login, which improves user experience while maintaining control over permissions and security.

In this guide, we configured a Cognito Identity Pool, created a DynamoDB table, and used the AWS JavaScript SDK to let guest users write data securely. To ensure security, it’s essential to apply least privilege IAM policies, monitor access through CloudWatch, and encourage users to transition to authenticated access when needed.

By following these best practices, we can balance usability and security, creating a seamless experience for both guest and registered users.

Cloud Consulting for AWS Media Services: Achieve Peak Performance

  • Unlock Efficiency
  • Transform Media Capabilities
Contact Us Now

About CloudThat

Established in 2012, CloudThat is an award-winning company and the first in India to offer cloud training and consulting services for individuals and enterprises worldwide. Recently, it won Google Cloud’s New Training Partner of the Year Award for 2025, becoming the first company in the world in 2025 to hold awards from all three major cloud giants: AWS, Microsoft, and Google. CloudThat notably won consecutive AWS Training Partner of the Year (APJ) awards in 2023 and 2024 and the Microsoft Training Services Partner of the Year Award in 2024, bringing its total award count to an impressive 12 awards in the last 8 years. In addition to this, 20 trainers from CloudThat are ranked among Microsoft’s Top 100 MCTs globally for 2025, demonstrating its exceptional trainer quality on the global stage.  

As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, Google Cloud Platform Partner, and collaborator with leading organizations like HPE and Databricks, CloudThat has trained over 850,000 professionals across 600+ cloud certifications, empowering students and professionals worldwide to advance their skills and careers. 

WRITTEN BY Siddiq Pasha

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!