Creates an EMR cluster ensuring the instance type is supported for the specified EMR release label using a lifecycle precondition.

Terraform Template

data "aws_emr_supported_instance_types" "test" {
  release_label = "local.release_label"
}

resource "aws_emr_cluster" "test" {

  lifecycle {

    precondition {
      condition = contains(data.aws_emr_supported_instance_types.test.supported_instance_types[*].type, local.instance_type)
      error_message = "${local.instance_type} is not supported with this EMR release label!"
    }
  }

  master_instance_group {
    instance_type = "local.instance_type"
  }
  release_label = "local.release_label"
}