Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petrgazarov/salami
Infrastructure as Natural Language
https://github.com/petrgazarov/salami
cloud-infrastructure declarative-language infrastructure-as-code llm natural-language salami
Last synced: 2 months ago
JSON representation
Infrastructure as Natural Language
- Host: GitHub
- URL: https://github.com/petrgazarov/salami
- Owner: petrgazarov
- License: apache-2.0
- Created: 2023-08-23T07:41:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-28T00:52:05.000Z (about 1 year ago)
- Last Synced: 2024-08-01T13:31:46.507Z (5 months ago)
- Topics: cloud-infrastructure, declarative-language, infrastructure-as-code, llm, natural-language, salami
- Language: Go
- Homepage:
- Size: 851 KB
- Stars: 43
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - petrgazarov/salami - Infrastructure as Natural Language (Go)
README
# Salami
Infrastructure As Natural Language
## 🤔 What is this?
Salami is a declarative domain-specific language for cloud infrastructure based on natural language descriptions. Salami compiler uses GPT4 to convert the natural language to Terraform code. You can think of Salami as writing documentation for each cloud resource object, and letting the compiler take care of converting that to IaC (Infrastructure as Code).
**[Short demo video](https://youtu.be/ej629E0WOIY)** |
**[Release blog post](https://www.petrgazarov.com/posts/infrastructure-as-natural-language)**## 🚀 Getting Started
### Installation
Homebrew (Mac OS, Linux):
```bash
brew tap petrgazarov/salami
brew install salami
```Manual:
Download the latest binaries for Mac OS, Linux and Windows from the [releases page](https://github.com/petrgazarov/salami/releases).
### Config
The root of your project should contain a `salami.yaml` config file.
Example:
```yaml
compiler:
target:
platform: terraform
llm:
provider: openai
model: gpt4
api_key: ${OPENAI_API_KEY}
source_dir: salami
target_dir: terraform
```| Configuration Setting | Description | Required |
| --------------------------- | ----------------------------------------------------------------------------- | -------- |
| compiler.target.platform | Platform to target. Only `terraform` value is currently supported. | Yes |
| compiler.llm.provider | Provider for the LLM. Only `openai` value is currently supported. | Yes |
| compiler.llm.model | Model used by the provider. Only `gpt4` value is currently supported. | Yes |
| compiler.llm.api_key | OpenAI API key. To set it to an env variable, use the `${ENV_VAR}` delimeter. | Yes |
| compiler.llm.max_concurrent | Maximum number of concurrent API calls to OpenAI API. Default is 5. | No |
| compiler.source_dir | The directory where your Salami files are located. | Yes |
| compiler.target_dir | The directory where the Terraform files should be written. | Yes |### Usage
From the root of your project, run:
```bash
salami compile
```For verbose output, run:
```bash
salami -v compile
```## 🎨 Design
### Constructs
Salami files are mostly comprised of natural language, with several special constructs:
1. **Blocks** - multiline blocks of text that each represent either a resource or a variable; delimited by double newlines.
2. **Constructor functions** - functions that are used to specify the nature of the block; start with an `@` symbol.
3. **Variable references** - references to variables that are defined in the program; delimited by curly braces.
4. **Resource references** - references to resources that are defined in the program; start with a dollar sign.Example Salami code with 3 blocks: VPC resource, Security Group resource and the
container_port
variable:
For more examples, see the `examples` directory. Each example has a README file with instructions on how to run it.
### Constructor function signatures
**@resource**
| Position | Argument | Type | Required? | Examples |
| -------- | ------------- | ------ | --------- | -------------------------------- |
| 1 | resource type | string | Yes | `aws.s3.bucket`, `AWS S3 Bucket` |
| 2 | logical name | string | Yes | `ApiCluster`, `prod_bucket_1` |
**@variable**
| Position | Argument | Type | Required | Examples |
| -------- | ------------- | ------ | -------- | ------------------------------------ |
| 1 | name | string | Yes | `container_port`, `logs_bucket_name` |
| 2 | variable type | string | Yes | `string`, `number`, `boolean` |
| 3 | default | any | No | `8080`, `logs_bucket_1fdretbnHUdfn` |### Lock file
The compiler generates a lock file that includes parsed Salami objects and the resulting Terraform code. It is used to determine which objects have changed since the last compilation. Unchanged objects are not sent to LLM, which makes the compilation process much faster.
### File extension
`.sami` is the extension for Salami files.
## ✅ VS Code Extension
It's recommended to install the [Salami VS Code extension](https://marketplace.visualstudio.com/items?itemName=Salami.salami). It provides highlighting functionality for the `.sami` files.
## 😍 Contributing
Contributions are welcome! For non-trivial contributions, please open an issue first to discuss the proposed changes.