What is the minimum allocation duration for EC2 Mac instances?
Amazon EC2 Mac instances require a minimum Dedicated Host allocation duration of 24 hours due to the terms of the Apple macOS Software License Agreement. Unlike standard Amazon EC2 instances that support per-second or per-hour billing without a minimum commitment, provisioning an EC2 Mac instance requires allocating a physical Mac Dedicated Host first. Once allocated, you cannot release that Dedicated Host until a full 24-hour period has elapsed, after which billing continues on a per-second basis until you explicitly release the host.
Understanding the 24-Hour Minimum Host Allocation
When you provision an Amazon EC2 Mac instance (such as
mac1.metal, mac2.metal,
mac2-m2.metal, mac2-m2pro.metal, or
mac-m4.metal), AWS allocates a dedicated physical Apple Mac
mini computer to your AWS account. This Dedicated Host model ensures
compliance with Apple's licensing rules, which stipulate that macOS
hardware leased from a service provider must be bound to a single
customer for at least 24 consecutive hours.
Key characteristics of this allocation policy include:
- Mandatory Lock-in Period: From the moment the
Dedicated Host enters the
availableorpendingallocation state, a 24-hour timer begins. During these initial 24 hours, AWS blocks any API call or console action attempting to release the Dedicated Host. - Instance vs. Host Lifecycle: You can launch, stop, start, or terminate EC2 Mac instances on the Dedicated Host as many times as needed during the 24-hour window. However, stopping or terminating the EC2 instance does not stop billing or release the underlying Dedicated Host.
- Post-24-Hour Billing: Once the initial \(T_{\text{min}} = 24\text{ hours}\) (\(86,400\text{ seconds}\)) requirement is satisfied, the Dedicated Host remains allocated to your account and accrues charges per second until you manually or programmatically release it.
Billing Formula and Cost Implications
Because billing is tied directly to the Dedicated Host allocation rather than the running state of the virtualized or bare-metal instance, your total cost \(C\) for a single Mac Dedicated Host with an hourly rate \(R\) allocated for a duration of \(t\) hours is determined by:
\[C = R \times \max(24, t)\]
If you allocate a host, run a build job for 2 hours, terminate the instance, and attempt to release the host, you will still be billed for the full 24 hours (\(24 \times R\)). If you keep the host allocated for 30.5 hours before releasing it, you are billed for the initial 24 hours plus the additional 6.5 hours at per-second granularity.
What Happens During Host Scrubbing and Maintenance
Whenever you terminate or stop an EC2 Mac instance on your Dedicated Host, the underlying physical Apple hardware undergoes an automated scrubbing and firmware verification process before another instance can be launched on it.
- Scrubbing Duration: The scrubbing process typically takes between 40 and 110 minutes depending on the Mac instance family (Intel vs. Apple silicon M1/M2/M4).
- Impact on Allocation Time: Time spent scrubbing the
physical host counts toward your 24-hour minimum allocation period, and
you continue to pay for the Dedicated Host while it is in the
pendingscrubbing state unless you have already passed the 24-hour mark and release the host instead of waiting for it to become available again. - Releasing While Scrubbing: If your host has already
been allocated for more than 24 hours and you terminate the running
instance, you do not need to wait for the scrubbing workflow to complete
before releasing the Dedicated Host. You can release the host
immediately after the instance enters the
terminatedstate.
How to Check Remaining Allocation Time and Release a Host
Before you can release an EC2 Mac Dedicated Host, two conditions must be met:
- No active or stopped EC2 instances are currently associated with the Dedicated Host.
- At least 24 hours have passed since the
AllocationTimetimestamp recorded by EC2.
You can inspect the exact allocation timestamp of your Mac Dedicated Hosts using the AWS CLI:
aws ec2 describe-hosts \
--filter "Name=instance-type,Values=mac2.metal" \
--query "Hosts[*].{HostId:HostId,State:State,AllocationTime:AllocationTime}" \
--output tableIf 24 hours have elapsed since AllocationTime and all
instances on the host are terminated, you can release the host to stop
billing:
aws ec2 release-hosts --host-ids h-0123456789abcdef0If you attempt to run release-hosts before the 24-hour
window has completed, AWS returns a Client.InvalidHostState
error indicating that the host cannot be released prior to the minimum
allocation duration.
Best Practices for Managing EC2 Mac Host Allocations
To optimize costs while working within the 24-hour minimum requirement, engineering teams typically adopt the following strategies:
- Consolidate CI/CD Workloads: Instead of allocating a new host per CI pipeline run, maintain a persistent pool of Dedicated Hosts and reuse the running macOS instances across multiple build jobs using ephemeral build agents or Tart/Anka virtualization on top of the bare-metal Mac instance.
- Automate Host Release Alerts: Configure Amazon EventBridge rules or AWS Lambda functions to monitor idle Mac Dedicated Hosts that have passed their 24-hour allocation window so they are automatically released when no instances are running.
- Use Savings Plans for Steady Workloads: If you run macOS build infrastructure continuously, EC2 Instance Savings Plans or Compute Savings Plans can reduce the hourly rate while maintaining continuous host allocation without worrying about daily allocation cycles.