Skip to Content
Technical Articles
Author's profile photo Kevin Riedelsheimer

Start development of business apps on Amazon EC2 with macOS AMI

With the Amazon EC2 Mac instance being available for consumption a new opportunity has been opened up for you to develop amazing business iOS apps for your business or customers. Through a VNC connection you can connect to a running mac1.metal instance with macOS Catalina 10.15.7 or macOS Mojave 10.14.6 being installed.

Because AWS EC2 is using physical Apple Mac mini machines instead of virtual machines you can get the full OS experience you need for the development of apps. In this blog post I want to show you how easy the setup is and how you get the SAP SDK for iOS installed.

Allocating a Dedicated Host and Run a mac1.metal Instance

In order to get a Mac instance, it is required that you allocate a dedicated host where the instance can run in. You need a dedicated host because the Mac instance is being provided on a physical Apple Mac mini instead of a virtual machine as you might now it from other EC2 instances.

Steps:

  1. In your Amazon EC2 navigate to Dedicated Hosts and click on Allocate Dedicated Host
  2. Provide the needed information and make sure to select mac1 as Instance FamilyAllocate%20a%20dedicated%20host
  3. Click on allocate

Launch a macOS Catalina Instance

Navigate to Instances > Launch Instance to choose between macOS Catalina 10.15.7 and macOS Mojave 10.14.6 .

After you’ve selected the macOS version of your choice, some additional configurations need to be done in order to use this as a proper development environment.

Choose the mac1.metal instance type and click on Configure Instance Details to continue.

You can leave all the values as is, the only change you need to do (at least I needed too) is to change the Host from Use auto-placement to your previously allocated host.

The auto placement option should tell EC2 to choose any available dedicated host to launch the instance on, as I’ve mentioned this didn’t work for me so choosing the specific host will definitely work.

Click on Next: Add Storage to change the allocated storage size for the instance. By default EC2 provides a SSD storage of 30 GiB which isn’t sufficient enough if you want to install Xcode and the SAP SDK for iOS. Xcode 12 by itself needs roughly 40GiB of storage to run so allocate enough storage to run the development tools as well as for your projects. I would recommend to go with at least 100GiB.

After setting the required storage size, you can Review and Launch the system.

AWS EC2 will ask you to create or select a security key pair. If you have one already in place you should be able to select it out of the dropdown, if not create a new one. The key pair is needed to establish an SSH connection to the system.

The process for AWS to spin up your instance might take a couple of minutes.

Connect to your Instance using SSH

To establish a connection to the instance you can open a secured SSH connection from your local machine.

  1. Before the connection can be established the instance needs certain Inbound rules being set via the security group in the AWS EC2 console. The rules have to allow incoming traffic over port 22, if this is not given your connection will time out.
  2. To connect to the service instance execute the following commands in your CLI:
    ssh -i your-key-pair.pem ec2-user@your-instance-public-dns​

     

    The key pair is the one you’ve created/used and downloaded to your local machine in the beginning. To locate public DNS address open up the AWS EC2 console and open your instance summary.

  3. The CLI will ask you to continue by entering yes
  4. If the connection is established you should see the OS information showing up

 

With the connection established you are automatically on the remote systems CLI, this is indicated through the ec2-user@ip-the-systems-ip-address.

Connect to your Instance over VNC

In order to actually interact with the graphical operating system you can connect to the system via a secured VNC connection. If you’re connecting through a macOS system (how ironic 😄) you can use the installed Screen Sharing application, if you’re connecting from a Windows or Linux system install a VNC client of your choice.

Over the current CLI session you need to do some additional changes on the instance system before you can connect via VNC.

  1. Set the access password to the macOS instalment
    sudo passwd ec2-user​

  2. Start a VNC server on the macOS instance by executing the following command
    sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
    -activate -configure -access -on \
    -restart -agent -privs -all​

    This will start the VNC server with all available privileges and the needed access policies.

  3. Open a new CLI session (you can leave the old one open if you want to) to connect to the VNC Server on the macOS instance.
    ssh -L 5900:localhost:5900 -i your-key-pair.pem ec2-user@your-instance-public-dns

    The -L option enables port forwarding which will forward all traffic on local port 5900 to the VNC server on the macOS instance within EC2.

  4. On your local machine (macOS) you can open Safari Browser and enter vnc://localhost for the Screen Sharing application to start connecting to the EC2 system. There enter the username and the set password. If you’re on Windows or Linux open your VNC client and connect to the public DNS server.
  5. After you’ve signed in you should see the login screen of macOS showing up in your VNC client. Login with the same credentials again.

Resize the APFS drive to use all available storage

By default the macOS EC2 instance is using 32GiB of storage no matter how much you actually assign your instance (I don’t have an explanation why this is). The Apple File System, short APFS, is a proprietary file system which got introduced with macOS High Sierra 10.13 and later. Apples mobile devices are also using the APFS technology for storing all your personal files.

Resizing the APFS container is fairly easy and contains of these steps:

  1. Find the used APFS container
  2. Create a Snapshot of your instance (optional, only needed if you have important data already stored on the system)
  3. Repair Disk
  4. Resize the container

Find the used APFS container

Make sure you are connected to the macOS EC2 instance via CLI or use the terminal application on the macOS EC2 instance directly. Enter the following command to list all physical external drives.

diskutil list physical external

You can see that the disk is identified as disk1s2.

Create a Snapshot of Your Instance (optional)

If you’re using the instance already or want to change the size at a later point again I would recommend to create a Snapshot of your instance to make sure that data is secured in case something breaks.

Make the disk ready for resizing

To make sure the resizing of the disk is going to be successful I would recommend to execute a repairDisk command on the desired APFS drive.

sudo diskutil repairDisk /dev/disk1

When asked enter yes to continue with the process.

Resize the APFS Container

Now that everything is prepared you can start the resizing process of the APFS container. Simply enter the following command.

sudo diskutil apfs resizeContainer disk1s2 0

This will cause the system to use up all available storage, if you don’t want to use all available storage you can specify the size by setting a specific value instead of the 0.

To verify the made changes execute:

sudo diskutil list

With that you’ve successfully resized the APFS container to the wished storage size. Now you’re ready to start setting up your development environment.

Install Xcode and the SAP SDK for iOS

To install Xcode just open the Apple App Store over VNC on the macOS EC2 instance and search for Xcode.

While Xcode is downloading you can go ahead and download the SAP SDK for iOS.

After the download has finished just install Xcode as well as the SAP SDK for iOS to begin development.

Conclussion

With the help of AWS EC2 macOS you have a nice alternative to develop amazing business apps without actually having Mac machines physically inside your company. There are a couple of manual steps you need to do before you can start developing and the performance of the systems are great.

You can also use these systems for testing and building your app projects with ease as its an actual physical machine running.

With that Happy Coding!

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.