Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robert-oleynik/tf-bindgen
Automatically generates bindings for Rust to build Terraform infrastructure.
https://github.com/robert-oleynik/tf-bindgen
codegen rust terraform
Last synced: 4 months ago
JSON representation
Automatically generates bindings for Rust to build Terraform infrastructure.
- Host: GitHub
- URL: https://github.com/robert-oleynik/tf-bindgen
- Owner: robert-oleynik
- License: bsd-3-clause
- Created: 2023-02-24T16:49:54.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-18T15:57:32.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T05:16:50.256Z (10 months ago)
- Topics: codegen, rust, terraform
- Language: Rust
- Homepage: https://robert-oleynik.github.io/tf-bindgen/
- Size: 313 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tf-bindgen
[![docs](https://img.shields.io/badge/docs-online-success)](https://robert-oleynik.github.io/tf-bindgen/)
[![crates](https://img.shields.io/crates/v/tf-bindgen)](https://crates.io/crates/tf-bindgen)`tf-bindgen` can be used to generate Rust bindings for [Terraform] providers and
to deploy your infrastructure.
This library will replicate most features of [CDK for Terraform] but written in Rust.[Terraform]: https://www.terraform.io/
[CDK for Terraform]: https://developer.hashicorp.com/terraform/cdktf## Requirements
Required tools:
- `cargo`
- `terraform`## What is `tf-bindgen`?
`tf-bindgen` is a code generator which will generate Rust code to configure infrastructure using [Terraform](https://www.terraform.io/). The following example shows how to use `tf-bindgen` to configure a Kubernetes pod running nginx:
```rust
fn init() -> Stack {
let stack = Stack::new("nginx");/// Configure Resources using a builder
let metadata = KubernetesNamespaceMetadata::builder()
.name("nginx")
.build();
let namespace = KubernetesNamespace::create(&stack, "nginx-namespace")
.metadata(metadata)
.build();/// Configure Resources using the resource! macro
resource! {
&stack, resource "kubernetes_pod" "nginx" {
metadata {
namespace = &namespace.metadata[0].name
name = "nginx"
}
spec {
container {
name = "nginx"
image = "nginx"
port {
container_port = 80
}
}
}
}
};stack
}
```See [Documentation](https://robert-oleynik.github.io/tf-bindgen/introduction.html) for a full introduction into `tf-bindgen`.
## Examples
For a list of examples, see the [Examples](https://robert-oleynik.github.io/tf-bindgen/examples.html) section of the documentation.
## Issues
### Compile Performance
Some Providers like [tf-kubernetes](https://github.com/robert-oleynik/tf-kubernetes) will generate large bindings, resulting in long compile durations. If you have this issue, please see the [Improving Compile Duration](https://robert-oleynik.github.io/tf-bindgen/advanced/improving_compile_duration.html) section.
## Roadmap
**v0.1:**
- [x] generate Rust code for Terraform provider
- [x] implement data blocks
- [x] implement resource blocks
- [x] add support for variable references
- [x] generate Rust code from Terraform modules
- [x] add code generator `tf_bindgen::codegen::resource`
- [x] add Construct derive macro
- [x] create Markdown book**v0.2:**
- [ ] Add support for Outputs in constructs
- [ ] Add Macro to generate CLI application
- [ ] Add `format!` for Value types
- [ ] Remove derive macros from generated source code## Limitations
As mentioned above, this library will replicate features provided by [CDK for Terraform].
It is not a one to one replacement for Rust and will be different in some aspects
of the implementation:1. `cdktf` (library and CLI application) are not needed to use this library
2. `tf-bindgen` constructs are not compatible with CDK constructs.## Contributing
## License
This project is licensed under the [BSD-3-Clause](./LICENSE) license.