Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/engineersbox/schematic

A terraform style IaC manager of services
https://github.com/engineersbox/schematic

infrastructure-as-code schema schematic

Last synced: 6 days ago
JSON representation

A terraform style IaC manager of services

Awesome Lists containing this project

README

        

# Schematic

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/EngineersBox/Schematic/Go?style=for-the-badge)

A terraform style IaC (Infrastructure as Code) manager of services

## Declaration Language

### Basic Types (`B`)

* `String`
* `Integer`
* `Float`
* `Boolean`

```JSON
"StringValue" = "some string"
"IntegerValue" = 5821
"FloatValue" = 63.64f
"BooleanValue" = false
```

---

### Expressions (`E`)

```Typescript
= >
```

---

### Variables (`V`)

```HCL
variable "someVar" {
value =
}
```

*or*

```Typescript
variable "anotherVar" =
```

---

### Complex Types (`C`)

* `Block`
* `Array`

#### Block

A composite object of fields and values:

```Typescript
{
... = | V>
}
```

#### Array

A list of values or composites

```Typescript
= [
... | V>
]
```

---

## Schema Strucure

There are three top level components to a schema:

* Instance
* Data
* Capture

Instances are paramterized and filled instantiations of a template, data are a source that can be referenced and templates are skeletons that describe the structure of a custom instance.

---

### Instance

| Field | Type |
|-------------- |---------------------- |
| name | `String` |
| type | `String` |
| hasDependency | `Array` |
| count | `Integer` |
| structure | `Block` |

```HCL
instance "String" "String" {
hasDependency = [
"String"
]
count = Integer

}
```

Example of an instance

```HCL
variable "testcapsule_clsid" {
value = 85831
}

instance "capsule::config" "test_capsule" {
hasDependency = []
count = 2
inbuilt = true
containerId = "testContainer"
config = {
pidsMax = 20
memMax = 4096
netClsId = var.testcapsule_clsid
terminateOnClose = true
}
}
```

---

#### InstBody

There are two variants of the `InstBody`, one as a custom defintion via schema defintion and the second with inbuilt service support. The services are as follows:

* `capsule::config`
* `capsule::boxfile`
* `aws::s3`
* `aws::ec2`
* `aws::route53`
* `docker::config`
* `docker::dockerfile`

A custom schema is defined as a set of `"String" = | V>`

The schema for the inbuilt support is:

| Field | Type |
|-------|------|
| inbuilt | `Boolean` |
| fieldSet | `{... | C | V>}` |

*Capsule (Config)*

```Typescript
inbuilt = true
containerId = >
config = {
pidsMax = >
memMax = >
netClsId = >
terminateOnClose = >
}
```

*Capsule (BoxFile)*

```Typescript
inbuilt = true
boxFileLocation = >
```

*AWS (S3)*

```Typescript
inbuilt = true
instanceType = "s3"
bucketName = >
arn = >
accessPolicy = {
public = <"ALL" | "NONE" | "GROUP">
private = <"ALL" | "NONE" | "GROUP" | "SELF">
}
```

*Docker (Dockerfile)*

```Typescript
inbuilt = true
dockerfileLocation = >
```

An example of a Capsule structure is

```HCL
variable "testcon_clsid" {
value = 85831
}

instance "capsule::config" "test_capsule_structure" {
inbuilt = true
containerId = "testContainer"
config = {
pidsMax = 20
memMax = 4096
netClsId = var.testcon_clsid
terminateOnClose = true
}
}
```

---

### Data

Data declarations are "intakes" for data for a specific existing source such as a running container or active S3 bucket

```Typescript
data <"file" | "service"> "String" {
reference = String<'L' | 'W'>::
schema {... | V>}
}
```

```Typescript
data.>.>.>[.>]
```

```HCL
data "service" "service_manager_container" {
reference = "L::/etc/capsule/containers/service_manager_container"
schema = {
containerId = >
proc = {
pidsMax = >
memMax = >
terminateOnClose = >
}
network = {
netClsId = >
}
}
}

instance "test_inst_type" "example_inst" {
someProperty = data.service.service_manager_container.network.netClsId
...
}
```

---

### Capture

Captures define the source code for instances

```HCL
capture "String" {
source = >
hasDependency = [
...>
]
handler = >
}
```

For example

```HCL
variable "service_manager_net_id" {
value = 2586425
}

capture "capsule" {
source = "github.com/EngineersBox/Capsule"
hasDependency = [
"github.com/google/golang"
]
handler = "capsule"
}

instance "capsule" "test_container" {
hasDependency = []
count = 2
inbuilt = true
containerId = "service_id_573"
config = {
pidsMax = 20
memMax = 4096
netClsId = var.service_manager_net_id
terminateOnClose = true
}
}
```