Shape Verification Setup

Learn about shape verification setup.

We'll cover the following


In our quality control step, we plan to use AWS Step Functions' Parallel state. As the name suggests, a Parallel state allows us to create parallel branches of execution in our state machine. It's used to model workflows that require concurrent execution of multiple operations.

Our quality control step consists of two separate checks that can be executed independently and concurrently, making it a great use case for the Parallel state.

Here are the two checks that we'll perform:

  • Shape Verification: For each sweet, we verify that its shape is an allowed shape (per the values stored in AWS Secrets Manager).

  • API Quality Check: This is a simulated check. We'll call a dummy API with a unique identifier for each sweet and determine whether the quality check passed or failed based on the API's response.

Both of these checks can occur at the same time, as they are independent of each other. Therefore, using the Parallel state will allow us to perform these checks simultaneously, increasing the efficiency of our workflow.

Here's how the Parallel state works:

  • When the Parallel state is entered, the state machine execution splits into multiple branches. Each branch is defined by a state in the “Branches” field of the Parallel state.

  • Each branch executes its defined states independently and concurrently.

  • When all branches have completed execution, the Parallel state itself completes.

If any branch fails, the Parallel state is considered failed and the execution will stop (unless error handling is set up to catch and handle the error).

By using a Parallel state, we can make our state machine more efficient by executing independent operations concurrently. It also allows us to structure our state machine in a way that mirrors the logical flow of our operations, making the state machine easier to understand and maintain.

Shape verification

In the context of our AWS Step Functions state machine, we'll use Secrets Manager for storing and verifying the sweet shapes in our quality control step. Secrets Manager is designed to keep secrets secure. It encrypts secrets at rest using encryption keys that we own and control. While our “secret” sweet shapes aren't sensitive information, this demonstrates how we could use Secrets Manager for more sensitive use-cases. Secrets Manager can automatically rotate secrets on a schedule. In our case, this means we could automatically change the valid sweet shapes on a regular basis. Again, while not critical in our use case, this showcases a powerful feature of Secrets Manager.

Let's start by defining our secret in AWS Secrets Manager. In serverless.yml:

Get hands-on with 1400+ tech skills courses.