Skip to main content

Crate pulumi_gestalt_build

Crate pulumi_gestalt_build 

Source
Expand description

pulumi_gestalt_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_gestalt_build, bon, serde, anyhow and wit-bindgen to Cargo.toml:

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

To generate glue code, use pulumi_gestalt_build in build.rs

use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
    pulumi_gestalt_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_gestalt_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§

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