Unleash The Power Of MacOS In The Cloud! 🚀 Dive Into A Step-by-Step Guide For Setting Up An EC2 Mac Instance

Frank Haubenschild
10 min readDec 27, 2023

Is it time to bid farewell to your physical Mac hardware, or should you boldly embrace the future of cloud-centric development? Let’s navigate the existing landscape and explore the pros and cons of harnessing an EC2 Mac instance for your development needs.

Photo by Mehmet Ali Peker on Unsplash

In December 2021, Amazon introduced the Elastic Compute (EC2) M1 Mac instance for macOS, which was subsequently updated in the autumn of this year to incorporate Apple's new M2 hardware. Built on Mac mini computers, EC2 Mac instances [9] empower you to seamlessly run any macOS workload in the cloud. This tutorial provides a step-by-step guide on setting up a single instance and leveraging it for your development purposes. We’ll proceed in 3 steps: first, we create an AWS account, then we set up a Dedicated Host, and finally, we create the instance itself and establish a connection to it.

Mac mini computers racked in an AWS Datacenter — © AWS Community

Accessing the Mac Instance in the cloud can be either done through an ssh session [10], or you can access the Mac GUI via a VNC Client [6] [7].

Setting up the AWS account

Before you can start to set up your dedicated Mac Instance, you first need to create an AWS account. To do so, just visit the AWS Free Tier website [3] and set up your account. In a minute or so, you should be ready to go. The AWS Free Tier account provides a limited but generous set of services for 12 months, allowing you to explore and experiment with Amazon Web Services without any costs. Unfortunately, the usage of an EC2 Mac instance is not covered by the Free Tier account, and therefore playing around with this instance type will cost you money.

Pricing

As written above, using an Amazon EC2 Mac instance (whether you use the M1 or M2 processor type) is not covered by the AWS Free Tier account. You have to purchase those instances as Dedicated Hosts either through the so-called On-Demand or Savings Plan pricing model. AWS charges per second you are using an instance with a 24-hour MINIMUM allocation period. If you just want to use them on one particular day for one or two hours, you will be charged for that complete day!

Note: Be aware that following this tutorial will cost you one mac2 instance 24 x $0.65 for the US East region, which is about $15.60 (prices from December 2023). The reason for this 24-hour minimum allocation period is the fact that AWS must comply with the Apple macOS Software License Agreement [4]. Please also be aware that not all Mac instance types are available in all regions.

On-Demand Pricing EC2 Mac Dedicated Hosts (12/2023) — minimum host allocation and billing is 24 hours

If you know that you will need an EC2 Mac Instance for a longer period you can use the AWS Pricing Calculator [5] to estimate costs.

Setting up a Dedicated Host

Before you can start creating a Dedicated Host you should check that your account in your desired region is allowed to set up a Dedicated Host. After logging into your AWS account go to Service -> Service Quotas -> AWS services and search for EC2. Then select the entry Amazon Elastic Compute Cloud (Amazon EC2) from the list. In the upcoming dialog search for mac.

If your quota is 0 you have to request an increase to be able to create a Dedicated Host.
Finally, you have to specify the desired new quota value.

After pressing the Request button a support case is automatically generated and if everything goes well (my case was processed and approved after 9 hours!) and your quota increase request is approved you can continue to create a Dedicated Host. Go to the Amazon EC2 console and choose in the Instance section the Dedicated Hosts entry.

A Dedicated Host will provide you with a Mac EC2 instance that is fully dedicated to you.

Continue and select Allocate Dedicated Host to specify the settings of your desired environment. Major settings are:

  • Name tag: Specify the desired name of your Dedicated Host.
  • Instance family: Currently you can choose between mac1 and mac2 and this has an effect on which instance types you can choose.
  • Instance type: Depending on the instance family you can choose between mac1.metal (M1 family, 12 vCPU, 32GiB Memory) or mac2.metal (M2 family, 8vCPU, 16GiB Memory).
  • Availability Zone: Choose the AZ where your dedicated host will be located.
  • Quantity: The number of dedicated hosts you would like to purchase.
A Dedicated Host is a physical server entirely dedicated to a single customer.

If your Dedicated Host was successfully created, you should see something like the below screenshot, and you are ready for the next steps to fire up your Mac instance(s) in the cloud.

Launching a Mac Instance onto your Dedicated Host

The next step is to select the Dedicated Host you have created before and place some Mac instances into it. To do so, click on Actions→Launch instance(s) onto host.

Continue to specify the instance settings. Those settings will cover the following sections:

Amazon Machine Image: Depending on your region and selected architecture you can choose which macOS version you want to install on your instance. Currently, the following macOS Versions are supported:

  • Mojave (version 10.14) (x86 Mac instances only)
  • Catalina (version 10.15) (x86 Mac instances only)
  • Big Sur (version 11) (x86 and M1 Mac instances)
  • Monterey (version 12) (x86 and M1 Mac instances)
  • Ventura (version 13) (all Mac instances, M2 and M2 Pro Mac instances support macOS Ventura version 13.2 or later)
  • Sonoma (version 14) (all Mac instances)
Pick your processor architecture (x86 or ARM) and the macOS version here.

Instance Type: Depending on your desired processor architecture (x86 or ARM) and region of your Dedicated Host you can choose between the M1 or M2 Mac hardware.

Network setting: Here you can specify the settings of the VPC and you can define the security group inbound rules. To publicly reach your Mac instance, we assign a public IP address to that instance for the simplicity of this step-by-step guide. An alternative would be to use the AWS Session Manager [11] instead which allows you to connect to your instance without the need of a public IP address.

By utilizing the Security Group’s Inbound rules, you gain the ability to manage the flow of network traffic from your instance. This functionality is analogous to a firewall, which empowers you to regulate all incoming and outgoing traffic to safeguard your machine.

As mentioned in the intro of this article, we want to be able to reach our instance via ssh. Thus, the inbound port 22 must be opened. Reaching the macOS GUI with a VNC client [6] [7] can be tunneled via ssh or in case you are using a public IP address also through this address.

Note: Please take care that you are not opening port 22 to the world, and limiting the access to this port only to the IP address you are using to reach the instance.

Configuring the network and security group gives you control over who can reach your instance.

Storage: Under this section, you can specify the amount of disk space you want to allocate to your instance. The first entry in the list will be the root volume drive (/dev/sda1) with a default size of 100 GB, which you can adapt if needed. If you need more volumes, you can add additional ones here by clicking Add new volume.

Key pair: Before we review all our settings you can create and assign a new key pair or assign an existing one to your instance. This key pair will be used to connect to the instance securely. You must store it in a secure place. For example, you could store it in the AWS Secrets Manager [8].

Finally, you can review your settings and press Launch instance button.

After a minute or two, your Mac instance should be up and ready, and you can continue to connect to it.

Connecting to the EC2 Mac Instance via SSH

After downloading your key pair .pem-file you can continue to create an ssh session with your Mac Instance. To do so, choose the Instance you want to connect to and select the tab SSH client. Finally, copy the ssh command directly from that page given to you by AWS under the Example section, and you are ready to go.

After logging into your Mac instance, you should first choose a secure password for the user ec2-user using the following command:

sudo passwd ec2-user

Connecting to the EC2 Mac Instance via VNC

Having a way to connect to your Mac via ssh is one thing, but for developing on a Mac, we certainly need a way to access the GUI remotely.

Via an ssh session to your Mac instance in the cloud, you have to start the macOS Screen Sharing via the following command:

sudo launchctl enable system/com.apple.screensharing
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist

After this service is running in the background, you can exit the above ssh session. The next step is to establish an ssh tunnel from your local PC (port 5900) to the remote port 5900 of your Mac instance, where the Apple Remote Desktop (ARD) is listening.

You will need the key pair you have generated before to establish the above ssh tunnel:

ssh -L 5900:localhost:5900 -i /path/key-pair-name.pem ec2-user@instance-public-dns-name

If the ssh tunnel was established successfully, you should be able to access the VNC server address under vnc://localhost:5900 in your locally installed VNC client.

To do so, you first need to download a VNC client, e.g. [6] [7]. Let's assume you are on Windows, so we have to install for example the TightVNC Client [6] first.

TightVNC Client — Free and Open Source VNC Viewer

After starting the client, you are asked to enter the remote host address. Just enter vnc://localhost:5900 to reach the remote Mac in the cloud.

Setup the remote host address

After a successful VNC connection, you should see the standard macOS login screen.

You can continue with your previously chosen password to finally reach the macOS desktop.

To find more information about EC2 Mac Instances, the AWS documentation [9] is worth looking at.

Conclusion

Besides EC2 instances running Linux, Android, QNX, or Windows the support of MacOS completes the potential development environment AWS offers. Whether you need the x86-based architecture or Apple’s own ARM processor the choice is yours. The only limitation is that currently, not all regions offer both. The pricing model Apple is dictating via its macOS Software License Agreement [4] with a minimum period of 24 hours for charging an instance makes it a bit unattractive for a user to just play around with it. Please beware of this and do a proper cleanup of all the created resources if you do not need them anymore.

Reaching the MacOS Desktop via screen sharing is kind of cool but does not give you the same feeling as working on a Mac right in front of you — it feels slow which may vary what kind of internet connectivity you have. Having the possibility of a hop-on-hop-off Mac in the cloud is IMHO not suitable for using a cloud Mac as a regular development machine but for having the possibility to include it in a CI/CD pipeline to build your bare metal macOS applications in the cloud and run tests on.

EC2 Mac instance seamlessly integrates with other AWS services, allowing users to leverage a wide range of tools and resources within the AWS ecosystem.

I am curious what are your use cases for using an EC2 Mac Instance? Do let me know in the comments section.

References

[1] Amazon EC2 Mac Instances
https://aws.amazon.com/ec2/instance-types/mac

[2] Amazon EC2 Pricing
https://aws.amazon.com/ec2/pricing

[3] Signup for AWS Free Tier
https://aws.amazon.com/free

[4] Apple Software License Agreements
https://www.apple.com/legal/sla

[5] AWS Price Calculator
https://calculator.aws

[6] Tight VNC
https://www.tightvnc.com

[7] Remmina
https://remmina.org/remmina-vnc

[8] AWS Secrets Manager
https://aws.amazon.com/secrets-manager

[9] Amazon EC2 Mac instances
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-mac-instances.html

[10] Secure Shell (SSH)
https://en.wikipedia.org/wiki/Secure_Shell

[11] AWS Systems Manager Session Manager
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html

--

--

Frank Haubenschild

Dad, Software Engineer, Photographer, Reef- & Bee-Keeper, Founder, Drone Pilot — 🤓 💻 📷 🐝 🐠 💡👨‍✈️