Visually design your application with AWS Application Composer
This post is written by Paras Jain, Senior Technical Account Manager and Curtis Darst, Senior Solutions Architect.
AWS Application Composer allows you to design and build applications visually using 13 AWS CloudFormation resource types. Today, the service expands the support to all available CloudFormation resource types.
AWS Application Composer provides you with an interactive canvas for visually designing your applications. You use a drag-and-drop interface to create an application design from scratch or import an existing application definition to edit it.
Modern event-driven applications are built on many services. Visualizing an architecture helps you better understand the relationship between those services and identify gaps and areas of improvements.
You can use AWS Application Composer in local sync mode to connect to your local file system. That way your changes are updated to your file system. This way, you can integrate with existing version control systems and development and deployment workflow.
AWS Application Composer provides a drag-and-drop canvas view and a code editor template view. Changes made to one view reflect on the other view. Similarly, changes made in AWS Application Composer are reflected in your local code editor and vice versa.
What is AWS releasing today?
AWS Application Composer already supports 13 serverless resource types. For these resource types, AWS Application Composer provides enhanced component cards.
Enhanced component cards allow you to configure and join components together. Today’s release gives you the ability to drag and drop 1,134 resource types to the canvas and configure these using resource configuration pane.
This blog post shows how you can create a fault tolerant compute architecture involving an Application Load Balancer, two Amazon Elastic Compute Cloud (EC2) instances in different Availability Zones, and an Amazon Relational Database Service (RDS) instance.
Conceptually, this is the application design:
Designing a scalable and fault tolerant compute stack
For this blog post, you create a fault tolerant compute stack consisting of an ALB, two EC2 instances in two different Availability Zones with automatic scaling capabilities and an RDS instance.
- Navigate to the AWS Application Composer service in the AWS Management Console. Create a new project by choosing Create Project.
- If you are using one of the browsers that support local sync (Google Chrome and Microsoft Edge at this time), you can connect the project to the local file system and edit using command line interface or integrated development environment. To do so:
- Choose Menu, and Local sync.
- Select a folder on your file system and allow the necessary permissions from the browser when prompted.
- Some components in architecture diagrams, like security groups, can be visualized in the canvas but you don’t necessarily want to represent them as prominent part of architectures. Therefore, for brevity, instead of dragging and dropping, you only configure them in the template mode.
- Choose Template to switch to the template view.
- Paste the following code in the template editor:
Resources: DBEC2SecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Open database for access SecurityGroupIngress: - IpProtocol: tcp FromPort: '3306' ToPort: '3306' SourceSecurityGroupId: !Ref WebServerSecurityGroup VpcId: ParameterId: VpcId Format: AWS::EC2::VPC::Id WebServerSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Enable HTTP access via port 80 locked down to the load balancer + SSH access. SecurityGroupIngress: - IpProtocol: tcp FromPort: '80' ToPort: '80' SourceSecurityGroupId: !Select - 0 - !GetAtt LoadBalancer.SecurityGroups - IpProtocol: tcp FromPort: '22' ToPort: '22' CidrIp: ParameterId: SSHLocation Format: String Default: 0.0.0.0/0 VpcId: ParameterId: VpcId Format: AWS::EC2::VPC::Id WebServerGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: VPCZoneIdentifier: ParameterId: Subnets Format: List<AWS::EC2::Subnet::Id> LaunchConfigurationName: !Ref LaunchConfiguration MinSize: '1' MaxSize: '5' DesiredCapacity: ParameterId: WebServerCapacity Format: Number Default: '1' TargetGroupARNs: - !Ref TargetGroup
- Switch back to canvas view.
- Add an Application Load Balancer, Load Balancer Listener, Load Balancer Target Group, Auto Scaling Launch Configuration and an RDS DB instance.
- Under the resources pane on the left, enter loadbalancer in the search bar.
- Drag and drop AWS::ElasticLoadBalancingV2::LoadBalancer from the resources pane to the canvas.
- Repeat these steps for other four resource types. Choose Arrange. Your canvas now appears as follows:
- Start configuring the remaining component cards. You can connect two cards visually by connecting the right connection port of one card to the left connection port of another card. At the moment, not all component cards support visual connectivity. For those cards you can establish connectivity using the resource configuration pane. You can also update the template code directly. Either way, the connectivity is reflected in the canvas.
- You configure the components in the architecture using the Resource configuration pane. First, configure the Application Load Balancer listener:
- Choose the Listener Card in the canvas.
- Choose Details.
- Paste the following code in the Resource Configuration Section:
DefaultActions: Type: forward TargetGroupArn: !Ref TargetGroup LoadBalancerArn: !Ref LoadBalancer Port: '80' Protocol: HTTP
- Choose Save.
- Repeat the same for remaining resource types with the following code. The code for the Load Balancer Card is:
- The code for the Target Group card is:
HealthCheckPath: / HealthCheckIntervalSeconds: 10 HealthCheckTimeoutSeconds: 5 HealthyThresholdCount: 2 Port: 80 Protocol: HTTP UnhealthyThresholdCount: 5 VpcId: ParameterId: VpcId Format: AWS::EC2::VPC::Id TargetGroupAttributes: - Key: stickiness.enabled Value: 'true' - Key: stickiness.type Value: lb_cookie - Key: stickiness.lb_cookie.duration_seconds Value: '30'
- This is the code for the Launch Configuration. Replace <image-id>with the right image id for your Region.
ImageId: <image-id> InstanceType: t2.small SecurityGroups: !Ref WebServerSecurityGroup
- The code for DBInstance is:
DBName: ParameterId: DBName Format: String Default: wordpressdb Engine: MySQL MultiAZ: ParameterId: MultiAZDatabase Format: String Default: 'false' MasterUsername: ParameterId: DBUser Format: String MasterUserPassword: ParameterId: DBPassword Format: String DBInstanceClass: ParameterId: DBClass Format: String Default: db.t2.small AllocatedStorage: ParameterId: DBAllocatedStorage Format: Number Default: '5' VPCSecurityGroups: - !GetAtt DBEC2SecurityGroup.GroupId
- Choose Arrange. Your canvas looks like this:
- This completes the visualization portion of the application architecture. You can export this visualization by using the Export Canvas option in the menu.
After adding the core application components, you now add observability to your application. Observability enables you to collect and analyze important events and metrics for your applications.
To be notified of any changes to the RDS database configuration, use a serverless design pattern to avoid running instances when they are not needed. Conceptually, your observability stack looks like:
- Amazon EventBridge captures the events emitted by Amazon RDS.
- For any event matching the EventBridge rule, EventBridge invokes AWS Lambda.
- Lambda runs the custom logic and send an email to an Amazon Simple Notification Service(SNS) topic. You can subscribe interested parties to this SNS topic.
There are now two distinct sets of components in the architecture. One set of components comprises the core application while another comprises the observability logic.
AWS Application Composer allows you to organize different components in groups. This allows you and your team to focus on one portion of the architecture at a time. Before adding observability components, first create a group of the existing components.
- Select a component card.
- While holding the ‘shift’ key, select the other cards. Once all resources are selected, select Group action.
Once the group is created, follow these steps to rename the group.
- Select the Group card.
- Rename the group to Application Stack.
- Choose Save.
Now add the observability components. Repeat the process of searching then dragging and dropping of the following components from the Resources pane to the canvas outside the Application Stack group.
- EventBridge Event rule
- Lambda Function
- SNS Topic
- SNS Subscription
Repeat the process for grouping these 4 components in a group with the name Observability.
Some of the components have a small circle on their sides. These are connector ports. A port on the right side of a card indicates an opportunity for the card to invoke another card. A port on the left side indicates an opportunity for a card to be invoked by another card. You can connect two cards by clicking the right port of a card and dragging to the left port of another card.
Create the observability stack by following the following steps:
- Connect the right port of EventBridge Event Rule card to the left port of Lambda Function Card. This makes the Lambda function a target for the EventBridge rule.
- Connect the right port of the Lambda function to the left port of the SNS topic. This adds the necessary AWS Identity and Management(IAM) permissions policies and environment variable to the Lambda function to provide it the ability to interact with the SNS topic.
- Select the EventBridge event rule card and replace the event pattern code in the resource properties pane with the following code. This event pattern monitors the RDS instance for an instance change event and pushes this event to Lambda.
source: - aws.rds detail-type: - RDS DB Instance Event
- Select the SNS subscription to see the resource configuration pane. Add the following code to the resource configuration. Replace email@example.com with your email address.
Endpoint: firstname.lastname@example.org Protocol: email TopicArn: !Ref Topic
- Repeat the group creating steps to create an observability group comprising an EventBridge event rule, Lambda function, SNS topic, and SNS subscription. Name the group Observability. Your group appears as follows:
Deploying your AWS Architecture
Before you can provision the resources for your architecture, you must make the configuration changes as per development and deployment best practices for your organization.
For example, you must provide a strong DB password, name the resources as per the naming conventions of your organization. You must also add the Lambda code with your custom logic.
AWS Application Composer provides you the ability to configure each resource via resource configuration panel. This enables you to always stay in-context while creating a complex architecture. You can quickly find the resource you want to edit instead of scrolling through a large template file. If you prefer to edit the template file directly, you can use the Template View of AWS Application Composer.
Alternatively, if you have enabled the local sync, you can edit the file directly in your integrated development environment (IDE) where changes made in AWS Application Composer are saved in real-time. If you have not enabled the local sync, you can export the template using the Save Template File option in the menu. After concluding your changes, you can provision the AWS infrastructure either by using AWS CloudFormation Console or by command line interface.
AWS Application Composer does not provision any AWS resources. Using AWS Application Composer to design your application architecture is free. You are only charged when you provision AWS Resources using the template file created by AWS Application Composer.
This blog post shows how to use AWS Application Composer to create and update an application architecture using any of the 1,134 CloudFormation resource types. It covers how to configure local sync mode to integrate the AWS Application to your development workflow. The post demonstrates how to organize your architecture into two distinct groups. Changes made in Canvas view are reflected in the template view and vice versa.
To learn more about AWS Application Composer visit https://aws.amazon.com/application-composer/.
For more serverless learning resources, visit Serverless Land.