diff --git a/_modules/heatv1/__init__.py b/_modules/heatv1/__init__.py
new file mode 100644
index 0000000..51d90b4
--- /dev/null
+++ b/_modules/heatv1/__init__.py
@@ -0,0 +1,38 @@
+"""
+Module for handling Heat stacks.
+
+:depends:   - os_client_config
+:configuration: This module is not usable until the following are specified
+"""
+
+try:
+    import os_client_config
+    REQUIREMENTS_MET = True
+except ImportError:
+    REQUIREMENTS_MET = False
+
+import os
+import sys
+
+# i failed to load module witjout this
+# seems bugs in salt or it is only me
+sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+
+import stack
+
+stack_create = stack.stack_create
+stack_delete = stack.stack_delete
+stack_list = stack.stack_list
+stack_show = stack.stack_show
+stack_update = stack.stack_update
+
+__all__ = ('stack_create', 'stack_list', 'stack_delete', 'stack_show',
+           'stack_update')
+
+
+def __virtual__():
+    if REQUIREMENTS_MET:
+        return 'heatv1'
+    else:
+        return False, ("The heat execution module cannot be loaded: "
+                       "os_client_config is not available.")
diff --git a/_modules/heatv1/common.py b/_modules/heatv1/common.py
new file mode 100644
index 0000000..06eabff
--- /dev/null
+++ b/_modules/heatv1/common.py
@@ -0,0 +1,109 @@
+import logging
+import six
+import uuid
+
+import os_client_config
+from salt import exceptions
+
+
+log = logging.getLogger(__name__)
+
+SERVICE_KEY = 'orchestration'
+
+
+def get_raw_client(cloud_name):
+    config = os_client_config.OpenStackConfig()
+    cloud = config.get_one_cloud(cloud_name)
+    adapter = cloud.get_session_client(SERVICE_KEY)
+    adapter.version = '1'
+    try:
+        access_info = adapter.session.auth.get_access(adapter.session)
+        endpoints = access_info.service_catalog.get_endpoints()
+    except (AttributeError, ValueError) as exc:
+        six.raise_from(exc, exceptions.SaltInvocationError(
+            "Cannot load keystoneauth plugin. Please check your environment "
+            "configuration."))
+    if SERVICE_KEY not in endpoints:
+        raise exceptions.SaltInvocationError("Cannot find heat endpoint in "
+                                             "environment endpoint list.")
+    return adapter
+
+
+def send(method):
+    def wrap(func):
+        @six.wraps(func)
+        def wrapped_f(*args, **kwargs):
+            cloud_name = kwargs.get('cloud_name', None)
+            if not cloud_name:
+                raise exceptions.SaltInvocationError(
+                    "No cloud_name specified. Please provide cloud_name "
+                    "parameter")
+            adapter = get_raw_client(cloud_name)
+            # Remove salt internal kwargs
+            kwarg_keys = list(kwargs.keys())
+            for k in kwarg_keys:
+                if k.startswith('__'):
+                    kwargs.pop(k)
+            url, request_kwargs = func(*args, **kwargs)
+            try:
+                response = getattr(adapter, method.lower())(url,
+                                                            **request_kwargs)
+            except Exception as e:
+                log.exception("Error occured when executing request")
+                return {"result": False,
+                        "comment": str(e),
+                        "status_code": getattr(e, "http_status", 500)}
+            try:
+                resp_body = response.json() if response.content else {}
+            except:
+                resp_body = str(response.content)
+            return {"result": True,
+                    "body": resp_body,
+                    "status_code": response.status_code}
+        return wrapped_f
+    return wrap
+
+
+def _check_uuid(val):
+    try:
+        return str(uuid.UUID(val)) == val
+    except (TypeError, ValueError, AttributeError):
+        return False
+
+
+def get_by_name_or_uuid(resource_list, resp_key):
+    def wrap(func):
+        @six.wraps(func)
+        def wrapped_f(*args, **kwargs):
+            if 'name' in kwargs:
+                ref = kwargs.get('name', None)
+                start_arg = 0
+            else:
+                start_arg = 1
+                ref = args[0]
+                kwargs["name"] = ref
+            if _check_uuid(ref):
+                uuid = ref
+            else:
+                # Then we have name not uuid
+                cloud_name = kwargs['cloud_name']
+                resp = resource_list(
+                    name=ref, cloud_name=cloud_name)["body"][resp_key]
+                if len(resp) == 0:
+                    msg = ("Uniq {resource} resource "
+                           "with name={name} not found.").format(
+                        resource=resp_key, name=ref)
+                    return {"result": False,
+                            "body": msg,
+                            "status_code": 404}
+                elif len(resp) > 1:
+                    msg = ("Multiple resource: {resource} "
+                           "with name: {name} found ").format(
+                        resource=resp_key, name=ref)
+                    return {"result": False,
+                            "body": msg,
+                            "status_code": 400}
+                uuid = resp[0]['id']
+            return func(uuid, *args[start_arg:], **kwargs)
+        return wrapped_f
+    return wrap
\ No newline at end of file
diff --git a/_modules/heatv1/stack.py b/_modules/heatv1/stack.py
new file mode 100644
index 0000000..ace3db0
--- /dev/null
+++ b/_modules/heatv1/stack.py
@@ -0,0 +1,147 @@
+from yaml import safe_load
+import json
+import common
+try:
+    from urllib.parse import urlencode
+except ImportError:
+    from urllib import urlencode
+
+HEAT_ROOT = "/srv/heat/env"
+
+TEMPLATE_PATH = "template"
+ENV_PATH = "env"
+
+
+def _read_env_file(name):
+    path = "/".join([
+        HEAT_ROOT,
+        ENV_PATH,
+        name])
+
+    return _read_file(path)
+
+
+def _read_template_file(name):
+    path = "/".join([
+        HEAT_ROOT,
+        TEMPLATE_PATH,
+        name])
+
+    return _read_file(path)
+
+
+def _read_file(full_path):
+    with open(full_path, 'r') as f:
+        data = safe_load(f)
+        return json.dumps(data, default=str)
+
+
+def _read_additional_file(path):
+    full_path = "/".join([
+        HEAT_ROOT,
+        path])
+    with open(full_path) as f:
+        return str(f.read())
+
+
+@common.send("get")
+def stack_list(**kwargs):
+    url = "/stacks?{}".format(urlencode(kwargs))
+    return url, {}
+
+
+@common.get_by_name_or_uuid(stack_list, 'stacks')
+@common.send("get")
+def stack_show(stack_id, **kwargs):
+    stack_name = kwargs.get("name")
+    url = "/stacks/{stack_name}/{stack_id}".format(
+        stack_name=stack_name, stack_id=stack_id)
+    return url, {}
+
+
+@common.get_by_name_or_uuid(stack_list, 'stacks')
+@common.send("delete")
+def stack_delete(stack_id, **kwargs):
+    stack_name = kwargs.get("name")
+    url = "/stacks/{stack_name}/{stack_id}".format(stack_name=stack_name,
+                                                   stack_id=stack_id)
+    return url, {}
+
+
+@common.send("post")
+def stack_create(name, template=None, environment=None, environment_files=None,
+                 files=None, parameters=None, template_url=None,
+                 timeout_mins=5, disable_rollback=True, **kwargs):
+    url = "/stacks"
+    request = {'stack_name': name,
+               'timeout_mins': timeout_mins,
+               'disable_rollback': disable_rollback}
+    if environment:
+        request["environment"] = environment
+    file_items = {}
+    if environment_files:
+        env_names = []
+        env_files = {}
+        for f_name in environment_files:
+            data = _read_env_file(f_name)
+            env_files[f_name] = data
+            env_names.append(f_name)
+        file_items.update(env_files)
+        request["environment_files"] = env_names
+    if files:
+        for f_name, path in files.items():
+            file_items.update((f_name, _read_additional_file(path)))
+    if file_items:
+        request["files"] = file_items
+    if parameters:
+        request["parameters"] = parameters
+    if template:
+        template_file = _read_template_file(template)
+        request["template"] = template_file
+    if template_url:
+        request["template_url"] = template_url
+    # Validate the template and get back the params.
+
+    return url, {"json": request}
+
+
+@common.get_by_name_or_uuid(stack_list, 'stacks')
+@common.send("put")
+def stack_update(stack_id, template=None, environment=None,
+                 environment_files=None, files=None, parameters=None,
+                 template_url=None, timeout_mins=5, disable_rollback=True,
+                 clear_parameters=None, **kwargs):
+    stack_name = kwargs.get("name")
+    url = "/stacks/{stack_name}/{stack_id}".format(
+        stack_name=stack_name, stack_id=stack_id
+    )
+    request = {'stack_name': stack_name,
+               'timeout_mins': timeout_mins,
+               'disable_rollback': disable_rollback}
+    if environment:
+        request["environment"] = environment
+    file_items = {}
+    if environment_files:
+        env_names = []
+        env_files = {}
+        for f_name in environment_files:
+            data = _read_env_file(f_name)
+            env_files[f_name] = data
+            env_names.append(f_name)
+        file_items.update(env_files)
+        request["environment_files"] = env_names
+    if files:
+        for f_name, path in files.items():
+            file_items.update((f_name, _read_additional_file(path)))
+    if file_items:
+        request["files"] = file_items
+    if parameters:
+        request["parameters"] = parameters
+    if template:
+        template_file = _read_template_file(template)
+        request["template"] = template_file
+    if template_url:
+        request["template_url"] = template_url
+    if clear_parameters:
+        request["clear_parameters"] = clear_parameters
+    return url, {"json": request}
diff --git a/_states/heatv1.py b/_states/heatv1.py
new file mode 100644
index 0000000..4ee8cf5
--- /dev/null
+++ b/_states/heatv1.py
@@ -0,0 +1,131 @@
+# Import Python libs
+from __future__ import absolute_import, print_function, unicode_literals
+import logging
+import time
+
+LOG = logging.getLogger(__name__)
+
+
+def __virtual__():
+    return 'heatv1'
+
+
+def _heat_call(fname, *args, **kwargs):
+    return __salt__['heatv1.{}'.format(fname)](*args, **kwargs)
+
+
+def _poll_for_complete(stack_name, cloud_name=None, action=None,
+                       poll_period=5, timeout=60):
+    if action:
+        stop_status = ('{0}_FAILED'.format(action), '{0}_COMPLETE'.format(action))
+        stop_check = lambda a: a in stop_status
+    else:
+        stop_check = lambda a: a.endswith('_COMPLETE') or a.endswith('_FAILED')
+    timeout_sec = timeout * 60
+    msg_template = '\n Stack %(name)s %(status)s \n'
+    while True:
+        stack = _heat_call('stack_show',
+                           name=stack_name,
+                           cloud_name=cloud_name)
+        if not stack["result"]:
+            raise Exception("request for stack failed")
+
+        stack = stack["body"]["stack"]
+        stack_status = stack["stack_status"]
+        msg = msg_template % dict(
+            name=stack_name, status=stack_status)
+        if stop_check(stack_status):
+            return stack_status, msg
+
+        time.sleep(poll_period)
+        timeout_sec -= poll_period
+        if timeout_sec <= 0:
+            stack_status = '{0}_FAILED'.format(action)
+            msg = 'Timeout expired'
+            return stack_status, msg
+
+
+def stack_present(name, cloud_name, template=None,
+                  environment=None, params=None, poll=5, rollback=False,
+                  timeout=60, profile=None, **connection_args):
+    LOG.debug('Deployed with(' +
+              '{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8} {9})'
+              .format(name, cloud_name, template, environment, params,
+                      poll, rollback, timeout, profile, connection_args))
+    ret = {'name': None,
+           'comment': '',
+           'changes': {},
+           'result': True}
+
+    if not name:
+        ret['result'] = False
+        ret['comment'] = 'Name is not valid'
+        return ret
+
+    ret['name'] = name,
+
+    existing_stack = _heat_call('stack_show', name=name,
+                                cloud_name=cloud_name)
+
+    if existing_stack['result']:
+        _heat_call('stack_update', name=name,
+                   template=template,
+                   cloud_name=cloud_name,
+                   environment=environment,
+                   parameters=params,
+                   disable_rollback=not rollback,
+                   timeout=timeout)
+        ret['changes']['comment'] = 'Updated stack'
+        status, res = _poll_for_complete(stack_name=name,
+                                         cloud_name=cloud_name,
+                                         action="UPDATE", timeout=timeout)
+        ret["result"] = status == "UPDATE_COMPLETE"
+        ret['comment'] = res
+    else:
+        _heat_call('stack_create',
+                   name=name,
+                   template=template,
+                   cloud_name=cloud_name,
+                   environment=environment,
+                   parameters=params,
+                   disable_rollback=not rollback,
+                   timeout=timeout)
+        status, res = _poll_for_complete(stack_name=name,
+                                         cloud_name=cloud_name,
+                                         action="CREATE", timeout=timeout)
+        ret["result"] = status == "CREATE_COMPLETE"
+        ret['comment'] = res
+    ret['changes']['stack_name'] = name
+    return ret
+
+
+def stack_absent(name, cloud_name, poll=5, timeout=60):
+    LOG.debug('Absent with(' +
+              '{0}, {1}, {2})'.format(name, poll, cloud_name))
+    ret = {'name': None,
+           'comment': '',
+           'changes': {},
+           'result': True}
+    if not name:
+        ret['result'] = False
+        ret['comment'] = 'Name is not valid'
+        return ret
+
+    ret['name'] = name,
+
+    existing_stack = _heat_call('stack_show',
+                                name=name, cloud_name=cloud_name)
+
+    if not existing_stack['result']:
+        ret['result'] = True
+        ret['comment'] = 'Stack does not exist'
+        return ret
+
+    _heat_call('stack_delete', name=name, cloud_name=cloud_name)
+    status, comment = _poll_for_complete(stack_name=name,
+                                         cloud_name=cloud_name,
+                                         action="DELETE", timeout=timeout)
+    ret['result'] = status == "DELETE_COMPLETE"
+    ret['comment'] = comment
+    ret['changes']['stack_name'] = name
+    return ret
