           groups        = [{ id: group.getId() }]
           hostnameAlias = hostnameAliases[0]
 
-          vm = new JVM {
-            hostnameAlias
-            planCode
-            subscriptionCode
-            webHome
-            groups
-            users
-            vmType: type
-          }
-
-          vm.save (err) =>
-
-            if err
-              return console.warn "Failed to create VM for ", \
-                                   {users, groups, hostnameAlias}
-
-            JVM.createDomains account, hostnameAliases, hostnameAliases[0]
-
-            group.addVm vm, (err)=>
-              return callback err  if err
-              JVM.ensureDomainSettings {account, vm, type, nickname, groupSlug}
-              if type is 'group'
-                @addVmUsers user, vm, group, ->
+          JStack.getStackId {user: nickname, group: groupSlug}, (err, stack)=>
+
+            vm = new JVM {
+              hostnameAlias
+              planCode
+              subscriptionCode
+              webHome
+              groups
+              users
+              vmType : type
+              stack
+            }
+
+            vm.save (err) =>
+
+              if err
+                return console.warn "Failed to create VM for ", \
+                                     {users, groups, hostnameAlias}
+
+              JVM.createDomains {
+                account, stack,
+                domains:hostnameAliases
+                hostnameAlias:hostnameAliases[0]
+              }
+
+              group.addVm vm, (err)=>
+                return callback err  if err
+                JVM.ensureDomainSettings {account, vm, type, nickname, groupSlug, stack}
+                if type is 'group'
+                  @addVmUsers user, vm, group, ->
+                    callback null, vm
+                else
                   callback null, vm
-              else
-                callback null, vm
 
   @addVmUsers = (user, vm, group, callback)->
     # todo - do this operation in batches

                  @ensureDomainSettings {account, vm, type, nickname, groupSlug}
                  @createDomains account, hostnameAliases, hostnameAliases[0]

  @ensureDomainSettings = ({account, vm, type, nickname, groupSlug})->
    domain = 'kd.io'
    if type in ['user', 'expensed']
      requiredDomains = ["#{nickname}.#{groupSlug}.#{domain}"]

        return callback err if err
        callback null, vm.hostnameAlias

  @createDomains = ({account, domains, hostnameAlias, stack})->

    updateRelationship = (domainObj)->
      Relationship.one
