tf-bindgen-cli 0.1.0

Wrapper around Terraform to improve usage with tf-bindgen.
Documentation
  • Coverage
  • 87.5%
    7 out of 8 items documented0 out of 7 items with examples
  • Size
  • Source code size: 14.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.62 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 28s Average build duration of successful builds.
  • all releases: 28s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • robert-oleynik/tf-bindgen
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • robert-oleynik

tf-bindgen

docs crates

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.

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. The following example shows how to use tf-bindgen to configure a Kubernetes pod running nginx:

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 for a full introduction into tf-bindgen.

Issues

Compile Performance

Some Providers like tf-kubernetes will generate large bindings, resulting in long compile durations. If you have this issue, please see the Improving Compile Duration section.

Roadmap

v0.1:

  • generate Rust code for Terraform provider
    • implement data blocks
    • implement resource blocks
  • add support for variable references
  • generate Rust code from Terraform modules
  • add code generator tf_bindgen::codegen::resource
  • add Construct derive macro
  • 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.