DEV Community

Cover image for Terraforming mac1.metal at AWS

Terraforming mac1.metal at AWS

Serhii Vasylenko
Hi there! 👋 I am an engineer from Ukraine. I like astronomy and everything related to DevOps. I thrive on developing great product offerings, great people, and great teams.
Originally published at Updated on ・2 min read

Recently AWS announced the support for Mac mini instances. I believe this is huge, even despite the many constraints this solution has. Oh, and the price is as huge as the announcement as well. But still, this offering opens the door to seamless macOS CI/CD integration into existing AWS infrastructure.

Here is a tip for engineers like me who decided to give this new instance type a try: managing a dedicated host for the "mac1.metal" instance using Terraform.

"mac1.metal" instance requires a dedicated host to be placed onto. This is a real Mac mini with a bit of magic from AWS.

As of 10 Jan 2021, the AWS Terraform provider does not have a resource for a dedicated host. So we must solve this using CloudFormation... in Terraform!

variable "availability_zone" {
  default = "us-east-1a"

resource "random_pet" "runner_name" {
  length    = 2
  prefix    = "mac-metal-"
  separator = "-"

resource "aws_cloudformation_stack" "dedicated_host" {
  name =

  timeout_in_minutes = 20

  template_body = <<STACK
  "Resources" : {
    "MyDedicatedHost": {
      "Type" : "AWS::EC2::Host",
      "Properties" : {
          "AutoPlacement" : "on",
          "AvailabilityZone" : "${var.availability_zone}",
          "HostRecovery" : "off",
          "InstanceType" : "mac1.metal"
  "Outputs" : {
    "HostID" : {
      "Description": "Host ID",
      "Value" : { "Ref" : "MyDedicatedHost" }

output "dedicated_host_id" {
  value = aws_cloudformation_stack.dedicated_host.outputs["HostID"]
Enter fullscreen mode Exit fullscreen mode

Then you just pass HostID to aws_instance resource and you have mac1.metal up and running!

I like to make boring technical things a bit less boring, so I decided to add a random pet name. Just for fun, why not.

You can wrap this into a module or add a count meta-argument to make it more versatile.

Simple as that, yes. But now, you can integrate it into your CI system (if you have enough courage and money 😄) and have the Mac instance with the underlying host in a bundle.
Thanks for reading me!

Discussion (3)

danieldias profile image
Daniel Dias

This terraform module will use the same approach to solve the problem:
Terraform AWS provider has a pull request to solve this problem open for more than 1 year :(
If you used this feature, please upvote the PR

svasylenko profile image
Serhii Vasylenko Author

Yeah, that issue already has my vote, as well as related PR. But still no luck :(

kondetiram profile image

Hello Daniel,
Can we create multiple dedicated hosts and mac instances from your script