Book Image

AWS CDK in Practice

By : Mark Avdi, Leo Lam
Book Image

AWS CDK in Practice

By: Mark Avdi, Leo Lam

Overview of this book

As cloud applications are becoming more complex, multiple tools and services have emerged to cater to the challenges of running reliable solutions. Although infrastructure as code, containers, and orchestration tools, such as Kubernetes, have proved to be efficient in solving these challenges, AWS CDK represents a paradigm shift in building easily developed, extended, and maintained applications. With AWS CDK in Practice, you’ll start by setting up basic day-to-day infrastructure while understanding the new prospects that CDK offers. You’ll learn how to set up pipelines for building CDK applications on the cloud that are long-lasting, agile, and maintainable. You’ll also gain practical knowledge of container-based and serverless application development. Furthermore, you’ll discover how to leverage AWS CDK to build cloud solutions using code instead of configuration files. Finally, you’ll explore current community best practices for solving production issues when dealing with CDK applications. By the end of this book, you’ll have practical knowledge of CDK, and you’ll be able to leverage the power of AWS with code that is simple to write and maintain using AWS CDK.
Table of Contents (17 chapters)
Part 1: An Introduction to AWS CDK
Part 2: Practical Cloud Development with AWS CDK
Part 3: Serverless Development with AWS CDK
Part 4: Advanced Architectural Concepts

Using LocalStack to simulate AWS services

Remember when we said that the lack of a proper local development environment is a bit of a pain when developing serverless applications? To fix that, instead of deploying our code to AWS every time we want to test it, we can use LocalStack to run it locally. LocalStack allows us to mimic the functionality of AWS services, such as DynamoDB and S3, on our own machine. This way, we can test and develop our cloud and serverless apps offline.

Installing LocalStack

To use LocalStack, we first need to install its command-line interface (CLI). The following is a detailed set of instructions:

  1. To be able to install the CLI, you need to have the following installed on your computer:
    • Python (3.7 up to 3.10)
    • Pip (Python package manager)
    • Docker
  2. Once you have those set up, you can proceed to your terminal and run the following command:
    $ python3 -m pip install localstack
  3. If everything goes well, you should see this prompt upon the command...