Authentication Required
Skip to content
Lattice Docs System definitions reference2

System definitions reference 2

System definitions

Schema

{
  type: "System"       // required
  name: <name>,        // required
  subsystems: [        // optional
    <subsystem_0>,
    .
    .
    .
    <subsystem_N>
  ]
}

where subsystem_i is either a System or a Service. With this recursive structure one can form arbitrarily complex System definitions.

Properties

Name Type Required Description
name string true System name
type string true Type. Must be value "System"
subsystems Array false List of subsystems

Example

{
  "type": "System",
  "name": "AirTunes",
  "subsystems": [
    { "$include": { "url": "front-end.json" } },
    { "$include": { "url": "back-end.json" } }
  ]
}

Service definitions

Schema

{
  type: "<ServiceType>"  // required
  name: <name>,          // required
  .
  .                      // type-specific properties
  .
  ]
}

Properties

Name Type Required Description
name string true Service name
type string true Type. Must be a valid service type.

Example

{
  "type": "Service",
  "name": "api",
  "description": "Backend API for Petflix app",

  "components": [
    {
      "name": "api",
      "ports": [
        {
          "name": "http",
          "port": 80,
          "protocol": "HTTP"
        }
      ],
      "build": {
        "git_repository": {
          "url": "https://github.com/mlab-lattice/example-petflix-service",
          "tag": "v1.3.1"
        },
        "language": "node:boron",
        "command": "npm install"
      },
      "exec": {
        "command": [
          "node",
          "index.js"
        ],
        "environment": {
          "MONGODB_URI": "mongodb://mongodb.petflix.local:27017/petflix",
          "PORT": "80"
        }
      }
    }
  ],
  "resources": {
    "num_instances": 1,
    "instance_type": "t2.small"
  }
}

Secrets

Machine Pools

Jobs

Templating

$variables

Templates can define variables via a $variables definition block.

Schema

{
  "$variables": {
    <name_0>: <value_0>,
    .
    .
    .
    <name_N>: <value_N>
  }
}

Example

{
  "$variables": {
    "systemName": "petflix",
  },

  "type": "System",
  "name": "${systemName}",
  .
  .
  .
}

The variables can later be accessed in expressions. In the above example we define the variable systemName and use it via the expression "${systemName}".

${...} expressions

Any rval may contain an expression. Expressions are are enclosed in double quotes and evaluate to a value of whatever type the expression evaluates to (e.g. boolean, string, etc...).

Expressions take the following form:

"${<variable>|<parameter>}"

Example

{
  "$variables": {
    "systemName": "petflix",
  },

  "type": "System",
  "name": "${systemName}",
  .
  .
  .
}

$parameters

Any file that defines a System definition template can formally declare parameters via a $parameters definition block:

Schema

{
  "$parameters": {
    <name_0>: { 
      "required": <boolean>,
      "default": <value>,
    },
    .
    .
    .
    <name_N>: { 
      "required": <boolean>,
      "default": <value>,
    },
  }

  "type": "System",
  "name": "${systemName}",
  .
  .
  .
}

Parameter values can be confured as required (default is false) or with a default (default is null), but not both.

Example

{
  "$parameters": {
    "systemName": {
      "required": true
    }
  }

  "type": "System",
  "name": "${systemName}",
  .
  .
  .
}

$include

Schema

{
  "$include": {
    "url": <string>,
    "parameters": {
      <name_0>: <value_0>,
      .
      .
      .
      <name_N>: <value_N>
    }
  }
}

Example

{
  "type": "System",
  "name": "petflix",
  "subsystems": [
    { "$include": { "url": "www.json" } },
    { "$include": { "url": "api.json" } },
    { 
      "$include": { 
        "url": "mongodb.json",
        "parameters": {
          replicas: 5
        }
      } 
    }
  ]
}