Amazon EC2 Mac Instance — macOS in the Cloud

Leandro Damascena
6 min readDec 4, 2020

--

macOS on AWS Cloud

AWS made a good move to accelerate yet another niche market to adopt cloud computing. As the only public cloud provider to allow its customers to create instances with the macOS operating system, AWS once again commits itself to its customers to bring flexibility and new business possibilities with the adoption of the cloud.

Mac instances are part of the new virtualization family (EC2 instances) and come with AWS Nitro, a platform that brings more security to systems, as it allows isolating the processing of sensitive data using Enclave, among others. In addition, the new AWS Mac instance family makes use of all the computing power and flexibility that AWS offers, as you can use the available cloud resources like EBS, VPC (with NACL and Security Groups), S3, Amazon FSx, etc., which ensures scalability, security and compliance of your environment.

The according AWS definition:

Powered by Mac mini hardware and the AWS Nitro System, you can use Amazon EC2 Mac instances to build, test, package, and sign Xcode applications for the Apple platform including macOS, iOS, iPadOS, tvOS, watchOS, and Safari. The instances feature an 8th generation, 6-core Intel Core i7 (Coffee Lake) processor running at 3.2 GHz, with Turbo Boost up to 4.6 GHz. There’s 32 GiB of memory and access to other AWS services including Amazon Elastic Block Store (EBS), Amazon FSx for Windows File Server, Amazon Simple Storage Service (S3), AWS Systems Manager, and so forth.

Now that you know what’s new with AWS Mac Instances, it’s time to create and access our first EC2 instance with macOS. But before that, you need to know a few things:

  • The instance uses EC2 Dedicated Hosts with a minimum usage of 24 hours.
  • The only family and instance type launched was mac1.metal.
  • The price per hour is $1.083 per hour or $9,487 per year. I recommend buying a Saving Plans.
  • AWS is working on the Apple M1 chip and planning its release for 2021.
  1. Creating Dedicated Host

Go to your EC2 Console -> Dedicated Hosts and Allocate Dedicated Host.

Launching dedicated host

Fill in the form fields. In the “Support multiple instance type” field you must uncheck it because there is only one instance type available and you must choose this one. You might have a problem depending on the region/availability zone that you chose due to mac1.metal is not available in all region/availability zone, I used region us-east-1 and availability zone us-east-1b.

Launching dedicated host

You can also use the command line to create the EC2 dedicated host:

aws ec2 allocate-hosts --availability-zone "us-east-1b" --auto-placement "on" --host-recovery "off" --quantity 1 --instance-type "mac1.metal"

2. Launching instance

Go to you EC2 Console -> Instances and Launch instances

Launching macOS instance

In the next window, you will see the two versions of macOS that AWS currently offers. Currently, only “macOS Catalina 10.15.7” and “macOS Mojave 10.14.6” versions. At the time of this posting, no other images were available. Select one of two and continue.

Launching macOS instance

Since we created a dedicated host with type “mac1.metal”, only the instance type “mac1.metal” will be available for creation. Select this instance type and click in “Next: Configure instance details”.

Launching macOS instance

This is an important creation step, as you must choose the “Host” that this instance will use, as it needs a dedicated host. Select the Host we just created in the Host field. In my case, nothing appears because I already have an instance allocated.

Launching macOS instance

Follow the rest of the steps and create your instance. In the security group options open inbound ports 22 and 5900 for your IP.

Then we have our EC2 Instance mac1.metal running now :D

Launching macOS instance

3. Accessing instance using ssh and VNC

Since macOS is a system that comes with the possibility of built-in ssh access, the most common and quickest way to access the instance is through an ssh connection.

ssh -i mykeyawsinstance.pem ec2-user@PUBLICIP

My example: ssh -i mac-os-test.pem ec2-user@34.227.95.243

Accessing macOS instance

It’s common sense that most people want to use a mac with its graphical interface and we should not leave that aside. To configure this on a Mac instance you need to enable the remote connection (VNC) service for the user “ec2-user” and for that you need to execute the following commands.

  • You must set a password for your ec2-user

sudo passwd ec2-user

  • Enabling remote access

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -configure -users ec2-user -configure -restart -agent -privs -all`

You can use VNC Viewer to access your server. Just open the VNC Viewer and type the public IP address (the same that you used on SSH). In the first authentication screen use ec2-user and the password you defined and press enter. Btw, this screen is in Portuguese because it’s my native language, sorry.

Accessing macOS instance

Voilà, we are connected to our mac instance on AWS using the graphical interface. Retype the ec2-user password to login on your Mac Instance.

Accessing macOS instance
Accessing macOS instance

PS: Anydesk has better performance and rendering than VNC, I suggest installing AnyDesk on the first VNC access and configuring access with a password.

4. Extra commands and curiosities

  • If you want to increase or decrease the size of your EBS, run the following commands on your mac:

PDISK=$(diskutil list physical external | head -n1 | cut -d” “ -f1)

APFSCONT=$(diskutil list physical external | grep “Apple_APFS” | tr -s “ “ | cut -d” “ -f8)

sudo diskutil repairDisk $PDISK

sudo diskutil apfs resizeContainer $APFSCONT 0

  • During our lab, I have no idea why, but AWS has exhausted the ability to launch Mac instances (although a host is reserved for that) and shutdown our server. We had to wait about 3 hours to be able to turn the instance on again.
Instance down
  • AWS still has a small number of resources for Mac instances so creating mac1.metal instances is still limited and you might not be able to immediately. We had to wait 5 hours to be able to create a dedicated host.
  • We have already installed XCode and compiled a simple application

If you want to know more about the new AWS technology, AWS Nitro, follow this repository on Github.

So, that’s it folks! I hope you enjoyed this post.

Article made in collaboration with José Araújo. Founder of https://www.fireclouds.com.br/, Embarcadero MVP and Senior Solutions Architect.

References:
https://aws.amazon.com/pt/blogs/aws/new-use-mac-instances-to-build-test-macos-ios-ipados-tvos-and-watchos-apps/
https://gist.github.com/sebsto/6af5bf3acaf25c00dd938c3bbe722cc1

--

--

Leandro Damascena

Systems architect and developer for over 15 years and passionate about cloud solutions. I have been working with cloud solutions for over 10 years!