Infrastructure As Natural Language
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 | Release blog post
Homebrew (Mac OS, Linux):
brew tap petrgazarov/salami
brew install salami
Manual:
Download the latest binaries for Mac OS, Linux and Windows from the releases page.
The root of your project should contain a salami.yaml
config file.
Example:
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 |
From the root of your project, run:
salami compile
For verbose output, run:
salami -v compile
Salami files are mostly comprised of natural language, with several special constructs:
- Blocks - multiline blocks of text that each represent either a resource or a variable; delimited by double newlines.
- Constructor functions - functions that are used to specify the nature of the block; start with an
@
symbol. - Variable references - references to variables that are defined in the program; delimited by curly braces.
- 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.
@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 |
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.
.sami
is the extension for Salami files.
It's recommended to install the Salami VS Code extension. It provides highlighting functionality for the .sami
files.
Contributions are welcome! For non-trivial contributions, please open an issue first to discuss the proposed changes.