1. Packages
  2. Strata Cloud Manager Provider
  3. API Docs
  4. getSnippet
Strata Cloud Manager v0.4.3 published on Saturday, Nov 8, 2025 by Pulumi
scm logo
Strata Cloud Manager v0.4.3 published on Saturday, Nov 8, 2025 by Pulumi

    Snippet data source

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as scm from "@pulumi/scm";
    
    const scmLabel1 = new scm.Label("scm_label_1", {name: "scm_label"});
    const scmSnippet1 = new scm.Snippet("scm_snippet_1", {
        name: "scm_snippet",
        description: "Adding a Description from Terraform",
        labels: [scmLabel1.name],
    });
    // Look up the "scm_snippet" tag by its id
    const scmSnippetOutputsDs = scm.getSnippetOutput({
        id: scmSnippet1.id,
    });
    export const snippetOutputs = {
        productionId: scmSnippetOutputsDs.apply(scmSnippetOutputsDs => scmSnippetOutputsDs.id),
        productionName: scmSnippetOutputsDs.apply(scmSnippetOutputsDs => scmSnippetOutputsDs.name),
        productionDescription: scmSnippetOutputsDs.apply(scmSnippetOutputsDs => scmSnippetOutputsDs.description),
        productionLabels: scmSnippetOutputsDs.apply(scmSnippetOutputsDs => scmSnippetOutputsDs.labels),
    };
    
    import pulumi
    import pulumi_scm as scm
    
    scm_label1 = scm.Label("scm_label_1", name="scm_label")
    scm_snippet1 = scm.Snippet("scm_snippet_1",
        name="scm_snippet",
        description="Adding a Description from Terraform",
        labels=[scm_label1.name])
    # Look up the "scm_snippet" tag by its id
    scm_snippet_outputs_ds = scm.get_snippet_output(id=scm_snippet1.id)
    pulumi.export("snippetOutputs", {
        "productionId": scm_snippet_outputs_ds.id,
        "productionName": scm_snippet_outputs_ds.name,
        "productionDescription": scm_snippet_outputs_ds.description,
        "productionLabels": scm_snippet_outputs_ds.labels,
    })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-scm/sdk/go/scm"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    scmLabel1, err := scm.NewLabel(ctx, "scm_label_1", &scm.LabelArgs{
    Name: pulumi.String("scm_label"),
    })
    if err != nil {
    return err
    }
    scmSnippet1, err := scm.NewSnippet(ctx, "scm_snippet_1", &scm.SnippetArgs{
    Name: pulumi.String("scm_snippet"),
    Description: pulumi.String("Adding a Description from Terraform"),
    Labels: pulumi.StringArray{
    scmLabel1.Name,
    },
    })
    if err != nil {
    return err
    }
    // Look up the "scm_snippet" tag by its id
    scmSnippetOutputsDs := scm.LookupSnippetOutput(ctx, scm.GetSnippetOutputArgs{
    Id: scmSnippet1.ID(),
    }, nil);
    ctx.Export("snippetOutputs", pulumi.Map{
    "productionId": scmSnippetOutputsDs.ApplyT(func(scmSnippetOutputsDs scm.GetSnippetResult) (*string, error) {
    return &scmSnippetOutputsDs.Id, nil
    }).(pulumi.StringPtrOutput),
    "productionName": scmSnippetOutputsDs.ApplyT(func(scmSnippetOutputsDs scm.GetSnippetResult) (*string, error) {
    return &scmSnippetOutputsDs.Name, nil
    }).(pulumi.StringPtrOutput),
    "productionDescription": scmSnippetOutputsDs.ApplyT(func(scmSnippetOutputsDs scm.GetSnippetResult) (*string, error) {
    return &scmSnippetOutputsDs.Description, nil
    }).(pulumi.StringPtrOutput),
    "productionLabels": scmSnippetOutputsDs.ApplyT(func(scmSnippetOutputsDs scm.GetSnippetResult) (interface{}, error) {
    return scmSnippetOutputsDs.Labels, nil
    }).(pulumi.Interface{}Output),
    })
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scm = Pulumi.Scm;
    
    return await Deployment.RunAsync(() => 
    {
        var scmLabel1 = new Scm.Label("scm_label_1", new()
        {
            Name = "scm_label",
        });
    
        var scmSnippet1 = new Scm.Snippet("scm_snippet_1", new()
        {
            Name = "scm_snippet",
            Description = "Adding a Description from Terraform",
            Labels = new[]
            {
                scmLabel1.Name,
            },
        });
    
        // Look up the "scm_snippet" tag by its id
        var scmSnippetOutputsDs = Scm.GetSnippet.Invoke(new()
        {
            Id = scmSnippet1.Id,
        });
    
        return new Dictionary<string, object?>
        {
            ["snippetOutputs"] = 
            {
                { "productionId", scmSnippetOutputsDs.Apply(getSnippetResult => getSnippetResult.Id) },
                { "productionName", scmSnippetOutputsDs.Apply(getSnippetResult => getSnippetResult.Name) },
                { "productionDescription", scmSnippetOutputsDs.Apply(getSnippetResult => getSnippetResult.Description) },
                { "productionLabels", scmSnippetOutputsDs.Apply(getSnippetResult => getSnippetResult.Labels) },
            },
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.scm.Label;
    import com.pulumi.scm.LabelArgs;
    import com.pulumi.scm.Snippet;
    import com.pulumi.scm.SnippetArgs;
    import com.pulumi.scm.ScmFunctions;
    import com.pulumi.scm.inputs.GetSnippetArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var scmLabel1 = new Label("scmLabel1", LabelArgs.builder()
                .name("scm_label")
                .build());
    
            var scmSnippet1 = new Snippet("scmSnippet1", SnippetArgs.builder()
                .name("scm_snippet")
                .description("Adding a Description from Terraform")
                .labels(scmLabel1.name())
                .build());
    
            // Look up the "scm_snippet" tag by its id
            final var scmSnippetOutputsDs = ScmFunctions.getSnippet(GetSnippetArgs.builder()
                .id(scmSnippet1.id())
                .build());
    
            ctx.export("snippetOutputs", Map.ofEntries(
                Map.entry("productionId", scmSnippetOutputsDs.applyValue(_scmSnippetOutputsDs -> _scmSnippetOutputsDs.id())),
                Map.entry("productionName", scmSnippetOutputsDs.applyValue(_scmSnippetOutputsDs -> _scmSnippetOutputsDs.name())),
                Map.entry("productionDescription", scmSnippetOutputsDs.applyValue(_scmSnippetOutputsDs -> _scmSnippetOutputsDs.description())),
                Map.entry("productionLabels", scmSnippetOutputsDs.applyValue(_scmSnippetOutputsDs -> _scmSnippetOutputsDs.labels()))
            ));
        }
    }
    
    resources:
      scmLabel1:
        type: scm:Label
        name: scm_label_1
        properties:
          name: scm_label
      scmSnippet1:
        type: scm:Snippet
        name: scm_snippet_1
        properties:
          name: scm_snippet
          description: Adding a Description from Terraform
          labels:
            - ${scmLabel1.name}
    variables:
      # Look up the "scm_snippet" tag by its id
      scmSnippetOutputsDs:
        fn::invoke:
          function: scm:getSnippet
          arguments:
            id: ${scmSnippet1.id}
    outputs:
      # Output the details of the found tags to verify they were read correctly.
      snippetOutputs:
        productionId: ${scmSnippetOutputsDs.id}
        productionName: ${scmSnippetOutputsDs.name}
        productionDescription: ${scmSnippetOutputsDs.description}
        productionLabels: ${scmSnippetOutputsDs.labels}
    

    Using getSnippet

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSnippet(args: GetSnippetArgs, opts?: InvokeOptions): Promise<GetSnippetResult>
    function getSnippetOutput(args: GetSnippetOutputArgs, opts?: InvokeOptions): Output<GetSnippetResult>
    def get_snippet(id: Optional[str] = None,
                    name: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetSnippetResult
    def get_snippet_output(id: Optional[pulumi.Input[str]] = None,
                    name: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetSnippetResult]
    func LookupSnippet(ctx *Context, args *LookupSnippetArgs, opts ...InvokeOption) (*LookupSnippetResult, error)
    func LookupSnippetOutput(ctx *Context, args *LookupSnippetOutputArgs, opts ...InvokeOption) LookupSnippetResultOutput

    > Note: This function is named LookupSnippet in the Go SDK.

    public static class GetSnippet 
    {
        public static Task<GetSnippetResult> InvokeAsync(GetSnippetArgs args, InvokeOptions? opts = null)
        public static Output<GetSnippetResult> Invoke(GetSnippetInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSnippetResult> getSnippet(GetSnippetArgs args, InvokeOptions options)
    public static Output<GetSnippetResult> getSnippet(GetSnippetArgs args, InvokeOptions options)
    
    fn::invoke:
      function: scm:index/getSnippet:getSnippet
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    The UUID of the snippet
    Name string
    The name of the snippet
    Id string
    The UUID of the snippet
    Name string
    The name of the snippet
    id String
    The UUID of the snippet
    name String
    The name of the snippet
    id string
    The UUID of the snippet
    name string
    The name of the snippet
    id str
    The UUID of the snippet
    name str
    The name of the snippet
    id String
    The UUID of the snippet
    name String
    The name of the snippet

    getSnippet Result

    The following output properties are available:

    Description string
    The description of the snippet
    Id string
    The UUID of the snippet
    Labels List<string>
    Labels applied to the snippet
    Name string
    The name of the snippet
    Tfid string
    Type string
    The snippet type
    Description string
    The description of the snippet
    Id string
    The UUID of the snippet
    Labels []string
    Labels applied to the snippet
    Name string
    The name of the snippet
    Tfid string
    Type string
    The snippet type
    description String
    The description of the snippet
    id String
    The UUID of the snippet
    labels List<String>
    Labels applied to the snippet
    name String
    The name of the snippet
    tfid String
    type String
    The snippet type
    description string
    The description of the snippet
    id string
    The UUID of the snippet
    labels string[]
    Labels applied to the snippet
    name string
    The name of the snippet
    tfid string
    type string
    The snippet type
    description str
    The description of the snippet
    id str
    The UUID of the snippet
    labels Sequence[str]
    Labels applied to the snippet
    name str
    The name of the snippet
    tfid str
    type str
    The snippet type
    description String
    The description of the snippet
    id String
    The UUID of the snippet
    labels List<String>
    Labels applied to the snippet
    name String
    The name of the snippet
    tfid String
    type String
    The snippet type

    Package Details

    Repository
    scm pulumi/pulumi-scm
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the scm Terraform Provider.
    scm logo
    Strata Cloud Manager v0.4.3 published on Saturday, Nov 8, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate