Mendix is now available in the Amazon marketplace as an App that can run on a virtual server in the cloud. This means you can run your own Mendix server for an hour, day, week, or even a year, and gives you full control over the environment. This how-to will guide you through a couple of simple steps to get your Mendix app up and running.
After completing this how-to you will be able to:
- Add a Mendix image to Amazon Web Serivces (AWS)
- Configure a Mendix Instances in AWS
- Create a Mendix Package
- Connect to a Mendix instance on AWS with SFTP (WinSCP) and SSH (Putty)
- Unpack and start a Mendix app on a Mendix server
- Configure access to a Mendix instance on AWS
Before starting this how-to, please make sure you have completed the following prerequisites:
1. Adding Mendix from the Amazon marketplace
The first thing to do when you want to run a Mendix instance on AWS is adding a Mendix version to your Amazon account.
- Go to http://aws.amazon.com.
- Scroll down and click on aws marketplace or go to https://aws.amazon.com/marketplace:
- Search for mendix.
- Select the Mendix app you want to deploy. This how-to will use Mendix Pro Edition - Linux based Runtime - 50 users. You can use this version for free for 5 days.
- Click Continue to start configuring the instance settings.
- Login with your Amazon Web Services account.
- Under Software Pricing select Hourly.
- For the Applicable Instance Type select m3.medium. This is the default setting. For this how-to we’ll use the default instance type, because we’re only using the application for a short time. When you deploy your own app you’ll need to adjust the instance type to your own requirements.
- In the Region section select the region where you want to server to run. I’ll leave it at US East (N. Virginia) for this how-to. The region where you server runs is not necessarily where you are currently located. If you are in the US and your app users are mostly in Japan it’s better to select Asia Pacific (Tokyo).
In the Security Group section make sure the instance is accessible through SSH, HTTP, and HTTPS. You can change these settings later. Key Pair Before you can launch the instance you have to create a key pair. A key pair consists of a public key that AWS stores, and a private key file that you store. Together, they allow you to connect to your instance securely. For Windows AMIs, the private key file is required to obtain the password used to log into your instance. For Linux AMIs, the private key file allows you to securely SSH into your instance. The selected key pair will be added to the set of keys authorized for this instance. Learn more about removing existing key pairs from a public AMI. Let’s follow the instructions to create a pair.
- Go to the Amazon EC2 Console: https://console.aws.amazon.com/ec2/home?region=us-east-1#s=KeyPairs.
- Click on Create Key Pair.
- Enter a name for the key pair.
- Click Create and download the .pem private key. Save this in a secure location, you will need this later in the how-to.
- Go back to the 1-Click Launch page and refresh it.
- Scroll down to the Key Pair section. Your newly created key should now be selected.
- Review the instance settings and, if you are happy with them, click Accept Terms & Launch with 1-click. The instance will be launched and an overview screen of all your settings will be shown.
- Close the overview screen. You should now see the software subscriptions:
- Refresh the page after a short time to view the running instance.
Congratulations, the Mendix instance is now running!
2. Creating a Deployment Package
Now that you’ve got your Mendix instance up and running it’s time to run an app on it. To do this you need to create a deployment package of your Mendix app and upload it to the AWS instance.
- Open the Mendix Modeler.
- Login with your credentials.
- Open a project you want to run on the Mendix AWS instance.
Create a deployment package of your project (F7).
The deployment package will be stored in the releases folder of your project folder.
Your app must be converted to Mendix 5.18 or higher before it can run on Amazon Web Services.
3. Uploading the Deployment Package to AWS
To upload the deployment package to the instance you need SFTP access. Keep your key pair file ready, you will need it for this step.
- Open WinSCP.
- Select New Site on the left:
Select SFTP as File protocol.
For the hostname you’ll have to go back to AWS.
- Open the AWS EC2 Console: http://console.aws.amazon.com/ec2/.
- Go to Instances.
- Select the instance you launched in the previous section.
From the pane below, copy the Public DNS address:
- Go back to WinSCP and paste the Public DNS address on the Host name field.
- In the username field type admin.
- Click Advanced.
- Go to SSH > Authentication.
- Under Authentication parameters select the private key you generated earlier. If the key doesn’t show up in the select window, change the extension to All Files. Putty doesn’t recognize the file because it has a .pem extension.
- Click Open.
- Click OK when you get the following window: You then need to save the key with the Putty extension (.ppk). You can add a passphrase if you want.
- Click Save private key and save it to your computer.
- Open the select window for the private key file again, this time selecting the private key with the .pkk extension:
- Click OK to save the settings.
- Click Save to save this configuration. Give it a recognizable name:
- Select the site in the left pane and click Login.
- Click Yes to add the server and host key to a cache.
- On the remote server browse to /srv/app/data/model-upload/.
- On your computer browse to the releases folder of the app you want to deploy.
- Upload the deployment package to the model-upload folder on the server: Learn more about transferring files to your Linux Instance Using WinSCP.
4. Running the Mendix App on AWS
Now that the deployment package is in place you can deploy it on the instance. You’ll use PuTTY to connect to the instance with SSH.
- Open PuTTY.
- In the Host Name field type admin@.
- Add the Public DNS address behind the admin@ part. This is the same address you used for WinSCP.
- Enter a name in the Saved Sessions field and click Save.
- In the tree on the left navigate to Connection > SSH > Auth.
- Click Browse and select your saved private key.
- Click Open and click Yes when you receive the security message. You now have SSH access to the AWS instance.
- In the console type m2ee. This will allow you to configure a Mendix app.
Execute the following command:
m2ee(admin): unpack [Deployment_Package]
- Enter y to confirm that all content will be overwritten.
If this is the first time you are unpacking a deployment package, Mendix may give a warning that it cannot find the Mendix Runtime. To solve this execute the following command, which will download the Mendix runtime:
Execute the following command:
- You may receive a message that the database needs to be updated. Enter e to execute and save the changes. If successful, you will receive a message that the MXRuntime has started.
Finally, make the app accessible by configuring a password for the administrator by executing the following command:
- Enter a new password for the user. It needs to be at least 8 characters. The app can now be accessed through the browser.
5. Accessing the App
The Mendix instance on AWS is now fully configured and ready for use. Let’s try and see if the app works!
- Open a browser and enter the Public DNS address in the address bar. The browser will load the page over HTTP by default. The app is also accessible over HTTPS. Simply add https:// before the Public DNS. Alternatively you can also use the Public IP. If you want to configure access to your app read more here.
- Login with MxAdmin and your admin password.
Congratulations! You have deployed a Mendix app on Amazon Web Services.