DEV Community

Nao San for AWS Community Builders

Posted on

[AWS] DevTools Evangelism: Infrastructure Composer Edition

This article is a machine translation of the contents of the following URL, which I wrote in Japanese:

https://qiita.com/Nana_777/items/c7ebc842c4557f8d811d

Introduction

This is the second post in the Japan AWS Top Engineers Advent Calendar 2025.

In this post, we'll introduce AWS Infrastructure Composer.
AWS Infrastructure Composer displays CloudFormation templates in a visually easy-to-understand format and makes it easier to define AWS Serverless Application Model (AWS SAM) templates.
We've previously posted about Infrastructure Composer, but this post also explains how to use SAM.

↓ Click here for the Japan AWS Top Engineers Advent Calendar 2025

https://qiita.com/advent-calendar/2025/aws-top-engineers

↓ Previous articles about AWS Infrastructure Composer

https://dev.to/aws-builders/aws-i-want-to-tell-you-how-good-infrastructurecomposer-is-devtools-5bj0

Infrastructure Composer Features

Visually Display CloudFormation Template Configuration

As an example, I created a CloudFormation template that defines an API configuration using API Gateway and Lambda.
By covering this with Infrastructure Composer, the entire AWS service configuration of the template is displayed not just as a list of text, but also in a visually easy-to-understand format using connected units called cards.
Cards do not display individual AWS services, but also group related resources such as roles.
image.png

Easily change definitions with extended components

When defining serverless-related services using cards called extended components, you don't need to manually define all the property names and values ​​in the IaC code.
You can define them by setting values ​​for the resource properties displayed on the Infrastructure Composer screen.
image.png

Can be operated from the AWS console or VSCode on your local PC

Operation from the AWS console

In the AWS CloudFormation console, open the stack details screen and the Templates tab. You'll see a "View in Infrastructure Composer" button.
Selecting this button allows you to visually check the contents of the selected template in Infrastructure Composer and update the template.
image.png
image.png
You can also select Infrastructure Composer when creating a new stack.
image.png

Using VS Code on your local PC

As described in more detail below, you can use Infrastructure Composer by installing the VS Code extension.

↓For other features, please refer to our previous article.

https://dev.to/aws-builders/aws-i-want-to-tell-you-how-good-infrastructurecomposer-is-devtools-5bj0

Using Infrastructure Composer with VS Code

Installing the VS Code Extension

Install the AWS Toolkit extension for VS Code.
This allows you to open CloudFormation templates in Infrastructure Composer on VSCpde.
image.png

Opening YAML Files with Infrastructure Composer

You can open a YAML file in Infrastructure Composer by right-clicking it in VS Code and selecting "Open with Infrastructure Composer."
image.png

Define and deploy serverless configurations using the AWS Serverless Application Model (AWS SAM)

What is the AWS Serverless Application Model (AWS SAM)?

AWS SAM is an open-source framework for building serverless applications using IaC.

Infrastructure Composer can handle services other than serverless, but some serverless services can be more easily defined using cards called extension components.

Setting up the AWS SAM environment

Installing the AWS SAM CLI

The official AWS documentation provides installation instructions for your PC environment.
Official documentation

https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/install-sam-cli.html

Since I'm using Windows, I installed it using the installer.
Installation is complete when the version is displayed using the following command:

sam --version
Enter fullscreen mode Exit fullscreen mode

image.png

Initializing the SAM Application

Execute the following command to initialize the application.

sam init
Enter fullscreen mode Exit fullscreen mode

This time, we'll use the HelloWorldExample, which already has an initial configuration defined.
image.png

Building the SAM Application

Execute the following command to build the application.
When executing the command, run it in the SAM application folder (the sam-app folder in this example).

sam build
Enter fullscreen mode Exit fullscreen mode

image.png

Setting Credentials

Execute the following command to set credentials for your AWS environment.

aws configure sso
Enter fullscreen mode Exit fullscreen mode

Set the values ​​of the access keys (AWS access key ID, AWS secret access key, and AWS session token) obtained from the AWS access portal.
The AWS access portal URL can be found in the IAM Identity Center dashboard.

Deploying the SAM Application

Execute the following command to deploy the application.

sam deploy --guided
Enter fullscreen mode Exit fullscreen mode

You will be prompted for various configuration settings during deployment. Please refer to the official AWS documentation.

https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html

Once deployment is complete, you can confirm the stack has been created in the AWS CloudFormation console.
image.png
In this example, we created an API Gateway and a Lambda function, and we were able to view the created resources in the console.
image.png

Modify and deploy the AWS SAM template with AWS Infrastructure Composer

Modify the definition from AWS Infrastructure Composer

As an example of a change, we will change the AWS Lambda timeout.
The original setting was 30 seconds, but change it to 10 seconds and click Save.
image.png
This has now been reflected in the IaC code.

Deploying with AWS SAM

The deployment procedure is the same as the initial deployment: run the build and deploy commands.

sam build
sam deploy --guided
Enter fullscreen mode Exit fullscreen mode

As a result of the deployment, I confirmed that the timeout period was reflected in the AWS Lambda console screen.
image.png

Conclusion

As introduced in this article, AWS Infrastructure Composer makes IaC code, which is often tedious to maintain and requires only text, visually easier to understand and maintain.
AWS Infrastructure Composer's true value is evident in SAM, but even outside of SAM templates, it can be useful for visually improving the understanding of complex, wordy, and difficult-to-read infrastructure configurations described in CloudFormation templates.

Reference

↓ Official AWS Serverless Application Model documentation

https://docs.aws.amazon.com/ja_jp/serverless-application-model/latest/developerguide/what-is-sam.html

Top comments (0)