build aws architecture diagrams using amazon q cli and mcp

Build AWS Architecture Diagrams with AWS Q CLI & MCP

By Mark King
AD

Streamlining your AWS architecture just got a whole lot easier with the AWS CloudFormation CLI, also known as AWS CDK (CloudFormation Deployer), and the AWS Cloud Map Client, or MCP for short. In this guide, we'll walk you through the process of creating and managing your AWS architecture diagrams using these powerful tools.

Before we dive in, let's quickly clarify what we mean by 'AWS architecture diagrams'. These are visual representations of your AWS services, helping you understand and manage your infrastructure more effectively. They play a crucial role in ensuring your infrastructure is scalable, secure, and reliable.

Introducing AWS CDK and AWS MCP

AWS CDK is an essential tool for managing your AWS infrastructure using familiar programming languages. It abstracts away the complexities of AWS CloudFormation, making it simpler to create, publish, and manage your AWS resources.

AD
Architecture ( Amazon Web Services)
Architecture ( Amazon Web Services)
AWS ROADMAP (2026)
AWS ROADMAP (2026)
Architect AWS
Architect AWS

AWS MCP, on the other hand, is designed to interact with AWS Cloud Map, a fully managed service that makes it easy for your compute services to discover and connect to one another. Here's how these tools come together to help you design, understand, and manage your AWS architecture.

Setup and Installation

To get started, you'll first need to install AWS CDK and AWS MCP. You can find comprehensive installation instructions on the AWS CDK documentation and the AWS Cloud Map documentation, respectively.

a computer screen with a diagram on it and an image of a server in the background
a computer screen with a diagram on it and an image of a server in the background
What is AWS API Gateway? πŸšͺ | API Gateway Explained for Beginners
What is AWS API Gateway? πŸšͺ | API Gateway Explained for Beginners
Knowledge 11062024
Knowledge 11062024

Once installed, you're ready to start creating and managing your AWS architecture diagrams.

Creating Your First Diagram with AWS CDK

To create your first diagram, you'll use the AWS CDK to define your infrastructure in code. Let's say you want to create a simple VPC with a public subnet and an EC2 instance.

AD

```javascript import 'aws-cdk-lib/aws-ec2'; const vpc = new VpcStack(stack, 'MyVPC', { cidr: '10.0.0.0/16', maxAzs: 2, subnets: [{cidr: '10.0.0.0/24', name: 'Public'}] }); new CfnInstance(stack, 'MyInstance', { imageId: '', instanceType: 't2.micro', subnetId: vpc.publicSubnetId }); ```

the diagram shows how an aws works
the diagram shows how an aws works
A new era of data: a deep look at how JPMorgan Chase runs a data mesh on the AWS cloud - SiliconANGLE
A new era of data: a deep look at how JPMorgan Chase runs a data mesh on the AWS cloud - SiliconANGLE
AWS icons | Design Elements for AWS architecture diagrams
AWS icons | Design Elements for AWS architecture diagrams
Building an AWS MVP for Enterprise AI Projects
Building an AWS MVP for Enterprise AI Projects
What is AWS CloudFront? 🌍 | CDN Explained for Beginners
What is AWS CloudFront? 🌍 | CDN Explained for Beginners
Google Search
Google Search

In this example, we're first defining a new VPC with a public subnet, then deploying an EC2 instance inside that subnet.

Understanding and Managing Your Diagrams with AWS MCP

Once you've created your diagrams with AWS CDK, you can use AWS MCP to manage and interact with your AWS resources. Here's how:

AD

Listing Your Services

You can list all your services registered with AWS Cloud Map using the `list-services` command. Here's an example:

```bash aws cloud-map list-services ```

The command returns a JSON response displaying all your services.

AD

Discovering Service Tasks

To find out which tasks are part of a specific service, you can use the `list-services-for-task` command. For example, to list all tasks for the 'my-service' service, you would run:

```bash aws cloud-map list-services-for-task --service-name my-service ```

This command helps you understand your service composition, enabling you to make informed decisions about your architecture.

With AWS CDK and AWS MCP, you now have a powerful toolset for creating, understanding, and managing your AWS architecture diagrams. Whether you're a seasoned AWS user or just starting out, these tools will streamline your workflow and help you maintain a solid, scalable infrastructure. So why wait? Start diagramming today!

AD