Serverless Web Apps using Amazon DynamoDB - Part 1
SPL-132 - Version 2.0.6
© 2020 Amazon Web Services, Inc. and its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited.
Errors, corrections or other questions? Contact us at AWS Training and Certification.
Calling all AWS super heroes! Build a mission dossier generator using DynamoDB in this three-part series of labs using DynamoDB. You hold in your hands step-by-step instructions for completing Part 1. In this lab, you will build the infrastructure you will need in the next two labs. You will create a DynamoDB table and add data, and then review the necessary IAM roles and policies that you will use to grant secure access to this data.
In labs 2 and 3, you will create Lambda functions that interact with DynamoDB, build an API through the API Gateway service, and finally publish an app to the public web, utilizing all of the DynamoDB skills you learn through the three labs. At the end of part 3, you will be able to generate mission dossiers and send super heroes off to save the world!
By the end of this lab you will be able to:
- Create an Amazon DynamoDB table
- Add items to your Amazon DynamoDB table
- Understand the structure of IAM roles and policies needed to access your table
You should familiarize yourself with key concepts by taking the Introduction to Amazon DynamoDB and Introduction to AWS Identity and Access Management (IAM) labs. This is the first in a three-part series of labs. Each of the three labs can stand alone, but because the labs build upon what you learned previously, taking all three in order is the best learning experience.
Other AWS Services
Other AWS Services than the ones needed for this lab are disabled by IAM policy during your access time in this lab. In addition, the capabilities of the services used in this lab are limited to what’s required by the lab and in some cases are even further limited as an intentional aspect of the lab design. Expect errors when accessing other services or performing actions beyond those provided in this lab guide.
Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed cloud database and supports both document and key-value store models. Its flexible data model and reliable performance make it a great fit for mobile, web, gaming, ad tech, IoT, and many other applications.
You can use Amazon DynamoDB to create a database table that can store and retrieve any amount of data, and serve any level of request traffic. Amazon DynamoDB automatically spreads the data and traffic for the table over a sufficient number of servers to handle the request capacity specified by the customer and the amount of data stored, while maintaining consistent and fast performance.
Similar to other database management systems, DynamoDB stores data in tables. A table is a collection of data. For example, in this lab you will create a table named SuperMission, where you will store mission information. You could also have a People table to store data about friends, family, or anyone else of interest, or a Cars table to store information about vehicles that people drive.
Each table contains multiple items. An item is a group of attributes that is uniquely identifiable among all of the other items. In a People table, each item would represent one person. For a Cars table, each item represents one vehicle. Items are similar in many ways to rows, records, or tuples in relational database systems. In DynamoDB, there is no limit to the number of items that you can store in a table.
Each item is composed of one or more attributes. An attribute is a fundamental data element, something that does not need to be broken down any further. In this lab, you will create a Mission item with attributes like SuperHero, MissionStatus, Villain1, Villain2, Villain3 and SecretIdentity. As another example, a Department item might have attributes such as DepartmentID, Name, Manager, and so on. An item in a People table could contain attributes such as PersonID, LastName, FirstName, and so on. Attributes in DynamoDB are similar in many ways to fields or columns in other database management systems.
When you create a table, in addition to the table name, you must specify the primary key of the table. As in other databases, a primary key in DynamoDB uniquely identifies each item in the table, so that no two items can have the same key. When you add, update, or delete an item in the table, you must specify the primary key attribute values for that item. The key values are required; you cannot omit them. DynamoDB supports two different kinds of primary keys: Partition Key and Partition Key and Sort Key.
In DynamoDB, you can read data in a table by providing primary key attribute values. If you want to read the data using non-key attributes, you can use a secondary index to do this. After you create a secondary index on a table, you can read data from the index in much the same way as you do from the table. By using secondary indexes, your applications can use many different query patterns, in addition to accessing the data by primary key values.
AWS Identity and Access Management Documentation
AWS Identity and Access Management (IAM) is a web service that enables Amazon Web Services (AWS) customers to manage users and user permissions in AWS. The service is targeted at organizations with multiple users or systems in the cloud that use AWS products such as Amazon DynamoDB, AWS Lambda, and the AWS Management Console. With IAM, you can centrally manage users, security credentials such as access keys, and permissions that control which AWS resources users can access. For more information, see https://aws.amazon.com/iam/.
AWS Lambda is a compute service that provides resizable compute capacity in the cloud to make web-scale computing easier for developers. Upload your code to AWS Lambda and AWS Lambda takes care of provisioning and managing the servers that you use to run the code. AWS Lambda supports multiple coding languages: Node.js, Java, or Python.
You can use AWS Lambda in two ways:
- As an event-driven compute service where AWS Lambda runs your code in response to events, such as uploading image files as you’ll see in this lab.
- As a compute service to run your code in response to HTTP requests using Amazon API Gateway or API calls.
AWS Lambda passes on the financial benefits of Amazon’s scale to you. Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. Lambda makes it easy to build data processing triggers for AWS services like Amazon S3 and Amazon DynamoDB, process streaming data stored in Amazon Kinesis, or create your own back end that operates at AWS scale, performance, and security.
This lab guide explains basic concepts of AWS in a step by step fashion. However, it can only give a brief overview of Lambda concepts. For further information, see the official Amazon Web Services Documentation for Lambda at https://aws.amazon.com/documentation/lambda/. For pricing details, see https://aws.amazon.com/lambda/pricing/.
- At the top of your screen, launch your lab by clicking
This will start the process of provisioning your lab resources. An estimated amount of time to provision your lab resources will be displayed. You must wait for your resources to be provisioned before continuing.
If you are prompted for a token, use the one distributed to you (or credits you have purchased).
- Open your lab by clicking
This will automatically log you into the AWS Management Console.
Please do not change the Region unless instructed.
Common login errors
Error : Federated login credentials
If you see this message:
- Close the browser tab to return to your initial lab window
- Wait a few seconds
- Click again
You should now be able to access the AWS Management Console.
Error: You must first log out
If you see the message, You must first log out before logging into a different AWS account:
- Click click here
- Close your browser tab to return to your initial Qwiklabs window
- Click again
이 실습의 나머지 부분과 기타 사항에 대해 알아보려면 Qwiklabs에 가입하세요.
- Amazon Web Services 콘솔에 대한 임시 액세스 권한을 얻습니다.
- 초급부터 고급 수준까지 200여 개의 실습이 준비되어 있습니다.
- 자신의 학습 속도에 맞춰 학습할 수 있도록 적은 분량으로 나누어져 있습니다.