Skip to main content

pulumi_gestalt_rust/resources/
stash.rs

1use crate::{
2    Context, CustomResourceOptions, Input, Output, PulumiAny, RegisterResourceRequest,
3    ResourceRequestObjectField,
4};
5use bon::Builder;
6
7/// Input arguments used to create a [`Stash`] resource.
8#[derive(Builder)]
9#[builder(finish_fn = build_struct)]
10pub struct StashArgs {
11    /// The value to store in stash state.
12    #[builder(into)]
13    pub input: Input<PulumiAny>,
14}
15
16/// Output object returned from stash creation.
17pub struct StashResult {
18    /// Pulumi ID is the provider-assigned unique ID for this managed resource.
19    /// It is set during deployments and may be missing (unknown) during planning phases.
20    pub id: Output<String>,
21    /// Pulumi URN is the stable logical identity of this resource in the Pulumi stack.
22    pub urn: Output<String>,
23    /// The most recent value passed to the stash resource.
24    pub input: Output<PulumiAny>,
25    /// The value saved in state for the stash.
26    pub output: Output<PulumiAny>,
27}
28
29/// Registers a new stash resource with the given unique name and arguments.
30pub fn create(ctx: &Context, name: &str, args: StashArgs) -> StashResult {
31    __create(ctx, name, args, None)
32}
33
34/// Same as [`create`], but with additional generic options that control registration behavior.
35pub fn create_with_options(
36    ctx: &Context,
37    name: &str,
38    args: StashArgs,
39    options: CustomResourceOptions,
40) -> StashResult {
41    __create(ctx, name, args, Some(options))
42}
43
44fn __create(
45    ctx: &Context,
46    name: &str,
47    args: StashArgs,
48    options: Option<CustomResourceOptions>,
49) -> StashResult {
50    let input_binding = args.input.get_output(ctx);
51    let request = RegisterResourceRequest {
52        type_: "pulumi:index:Stash".into(),
53        name: name.to_string(),
54        version: String::new(),
55        object: &[ResourceRequestObjectField {
56            name: "input".into(),
57            value: &input_binding,
58        }],
59        options,
60    };
61    let composite = ctx.register_resource(request);
62
63    StashResult {
64        id: composite.get_id(),
65        urn: composite.get_urn(),
66        input: composite.get_field_any("input"),
67        output: composite.get_field_any("output"),
68    }
69}