Crate pulumi_wasm_build

source
Expand description

pulumi_wasm_build generates glue code for given Pulumi provider

§Example

Select Pulumi provider you want to use. For demonstration purposes I’ll choose Random

Here we will have the provider glue and our code in single library. Due to compilation times it is recommended to separate glue code and custom code.

$ cargo new --lib random && cd random

First, add pulumi_wasm_build, bon, serde, anyhow and wit-bindgen to Cargo.toml:

$ cargo add --build pulumi_wasm_build
$ cargo add bon
$ cargo add serde --features derive
$ cargo add anyhow
$ cargo add wit-bindgen

To generate glue code, use pulumi_wasm_build in build.rs

use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
    pulumi_wasm_build::generate("random", "4.15.0")?;
    Ok(())
}

Then add generated code to lib.rs and use it in #[pulumi_main]

mod random {
  include_provider!("random");
}

use random::random_string::RandomStringArgs;
use random::random_string;
use pulumi_wasm_rust::pulumi_main;
use anyhow::Result;

#[pulumi_main]
fn main() -> Result<()> {
  let random_string = random_string::create(
    "test",
    RandomStringArgs::builder().length(32).build_struct()
  );
  Ok(())
}

Functions§

  • Generates glue code for given provider and version. Can be included using [pulumi_wasm_rust::include_provider!(provider_name)]
  • Generates glue code for given schema json/yaml. Can be included using [pulumi_wasm_rust::include_provider!(provider_name)]
  • Generates glue code for given schema json/yaml and modules. Can be included using [pulumi_wasm_rust::include_provider!(provider_name)] Modules for provider can be found in Pulumi registry on left side with (M) icon:
  • Generates glue code for given provider, version and modules. Can be included using [pulumi_wasm_rust::include_provider!(provider_name)] Modules for provider can be found in Pulumi registry on left side with (M) icon: