DEV Community

​Andrzej Ressel
​Andrzej Ressel

Posted on • Edited on

Pulumi Wasm/Rust devlog #1

Since my last post more than half a year have passed. The project is still going strong and a lot of improvements have been introduced.

Builders

Last time, all fields were required (even is they are empty):

    let random_string_1 = random_string(
        "test_1",
        RandomStringArgs {
            keepers: None.into(),
            length,
            lower: None.into(),
            min_lower: None.into(),
            min_numeric: None.into(),
            min_special: None.into(),
            min_upper: None.into(),
            number: None.into(),
            numeric: None.into(),
            override_special: None.into(),
            special: None.into(),
            upper: None.into(),
        },
    );
Enter fullscreen mode Exit fullscreen mode

I've migrated all the structs to bon so now they look like this

    let random_string_1 = random_string::create(
        "test_1",
        RandomStringArgs::builder().length(length).build_struct(),
    );
Enter fullscreen mode Exit fullscreen mode

In the future I will experiment with Function Builder to see if it will be a better choice

Code generation

Last time provider was split into two parts - Wasm based provider (generated on Pulumi WASM side and distributed as binary artifact) and glue code (potentially generated on user side, last time still generated by Pulumi Wasm).

I've decided to go 100% for code generation on user side. Thanks to that user can use any provider they want in any version they want. In addition provider does not have to be available in public Pulumi registry - glue code can be generated from schema.json.

# build.rs
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
    pulumi_wasm_build::generate("random", "4.15.0")?;
    Ok(())
}
Enter fullscreen mode Exit fullscreen mode

Examples

Currently Pulumi does not export code examples in easy to ingest format. I've decided to try reading YAML and the results are pretty good - for now it's very basic and things like variables, interpolation and complicated order does not work. Here is example of ACMPCA Permission

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let example = permission::create(
        "example",
        PermissionArgs::builder()
            .actions(vec!["IssueCertificate", "GetCertificate", "ListPermissions",])
            .certificate_authority_arn("${exampleCertificateAuthority. arn}")
            .principal("acm.amazonaws.com")
            .build_struct(),
    );
    let exampleCertificateAuthority = certificate_authority::create(
        "exampleCertificateAuthority",
        CertificateAuthorityArgs::builder()
            .certificate_authority_configuration(
                CertificateAuthorityCertificateAuthorityConfiguration::builder()
                    .keyAlgorithm("RSA_4096")
                    .signingAlgorithm("SHA512WITHRSA")
                    .subject(
                        CertificateAuthorityCertificateAuthorityConfigurationSubject::builder()
                            .commonName("example. com")
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .build_struct(),
    );
}
Enter fullscreen mode Exit fullscreen mode

There are still a lot of things to do - generating the biggest providers (AWS almost works), core improvements (there are non-working edge cases,
like functions without inputs), example generation improvements, documentation and creating PoC of non-rust WASM language.

Links:
Main repository: https://github.com/andrzejressel/pulumi-wasm
Example: https://github.com/andrzejressel/pulumi-wasm-example

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay