Repository navigation
Home
If you are using mule runtimes in a hybrid mode where your mule runtimes running in your own VPC on AWS, then you might be aware of the fact that that the Mulesoft out of the box does not provide capability to utilize AWS auto scaling of mule runtimes running on EC2 instances. In order to make use of auto scaling on AWS you need to write custom code to register / de-register mule runtime on ec2 instance startup and deploy apps to the newly deployed mule runtimes. Anypoint runtime fabric does provide auto scaling however we found it to be more heavy weight and complex solution.
- Register mule runtimes with Anypoint Runtime Manager(ARM) on EC2 instance startup
- Remove mule runtime from ARM in case auto scaling terminates the instance
- Supports Anypoint connected apps feature to obtain access token to invoke ARM APIs
- Make use of server groups to automatically deploy apps to newly register runtimes
- Solution uses serverless technology - AWS Lambda
- Automated deployment of the solution using AWS SAM templates
- Open source. Open source version only supports non containerized version of mule runtimes. Please contact us if you need container support for auto scaling
- Highly secure - make use of AWS secrets manager and mule connected apps to obtain access token to invoke ARM APIs.
- With auto scaling support you can build a very dynamic mule runtime environment on AWS using cloud native capabilities such as auto scaling groups, use of spot instances and flexibility to scale up or down your mule runtimes based on the traffic policies
- Open source - code is available on github

The heart of the solution is the instance user data script and the lambda functions which manage the setup of mule runtime agent, register / de-register mule runtime on ARM and server group and deploy apps from s3 bucket
Following steps performed when Auto scaling group launch the new instance.
Depending on your configuration this process may take 1 or 2 minuets to complete
- User data script gets the server registration token by invoking lambda function
- Setup mule agent using server registration token. The solution uses AWS instance ID as server name
- Once mule agent is setup, mule runtime is started. At this point of time server is shown up in ARM as running
- Once mule runtime started, the script adds the server to the server group by invoking lambda function
Following steps performed when Auto scaling group terminates the new instance.
Depending on your configuration this process may take 1 or 2 minuets to complete
- AWS Cloudwatch fires instance termination event
- Instance terminate event invokes lambda function which remove the instance from ARM and Server group.
User data script invokes following lambda functions
-
getAccessToken to get the registration and access token from ARM. This function also connects with AWS secrets manager to retrieve following attributes
- Mule Domain URL
- Environment ID
- Organization ID
- Client ID (Created when connected app is configured on Anypoint cloud hub console)
- Client Secret (Created when connected app is configured on Anypoint cloud hub console)
- muleServerGroupAction lambda functions to add the mule server to the server group
Cloudwatch event rule fires muleRemoveServer on following events defined on Auto Scaling Group name MuleRuntimeASG (you can change this name in AWS SAM template file)
- EC2 Instance Terminate Successful
- EC2 Instance Terminate Unsuccessful
The solution implements following security measures to secure the overall solution.
- AWS Secrets Manager - To store configuration items such as Client ID, Secret or Anypoint user credentials
- AWS IAM roles and policies to control the access. Please refer to SAM template file for the exact details
-
Mule Connecte Apps The Connected Apps feature provides a framework that enables an external application to integrate with Anypoint Platform using APIs through OAuth 2.0 and OpenID Connect. Connected apps help users delegate their access without sharing sensitive credentials or giving full control of their accounts to third parties. Actions taken by connected apps are audited, and users can also revoke access at any time. Following scopes needs to be enabled on the connected App
-
Runtime Manager
- Read Servers
- Manage Servers
- Read Applications
- Create Applications
-
General
- View Organizations
- Profile
-
Runtime Manager
Please refer to github page for detailed installation instructions
Infotiate team actively support this solution. Please contact us if you need technical support
Copyright 2020 Infotiate. All rights reserved.