1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. getSnippet
Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi

cloudflare.getSnippet

Explore with Pulumi AI

cloudflare logo
Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const exampleSnippet = cloudflare.getSnippet({
        zoneId: "9f1839b6152d298aca64c4e906b6d074",
        snippetName: "my_snippet",
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    example_snippet = cloudflare.get_snippet(zone_id="9f1839b6152d298aca64c4e906b6d074",
        snippet_name="my_snippet")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := cloudflare.LookupSnippet(ctx, &cloudflare.LookupSnippetArgs{
    			ZoneId:      "9f1839b6152d298aca64c4e906b6d074",
    			SnippetName: "my_snippet",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleSnippet = Cloudflare.GetSnippet.Invoke(new()
        {
            ZoneId = "9f1839b6152d298aca64c4e906b6d074",
            SnippetName = "my_snippet",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.CloudflareFunctions;
    import com.pulumi.cloudflare.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) {
            final var exampleSnippet = CloudflareFunctions.getSnippet(GetSnippetArgs.builder()
                .zoneId("9f1839b6152d298aca64c4e906b6d074")
                .snippetName("my_snippet")
                .build());
    
        }
    }
    
    variables:
      exampleSnippet:
        fn::invoke:
          function: cloudflare:getSnippet
          arguments:
            zoneId: 9f1839b6152d298aca64c4e906b6d074
            snippetName: my_snippet
    

    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(snippet_name: Optional[str] = None,
                    zone_id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetSnippetResult
    def get_snippet_output(snippet_name: Optional[pulumi.Input[str]] = None,
                    zone_id: 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: cloudflare:index/getSnippet:getSnippet
      arguments:
        # arguments dictionary

    The following arguments are supported:

    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.
    snippetName string
    The identifying name of the snippet.
    zoneId string
    The unique ID of the zone.
    snippet_name str
    The identifying name of the snippet.
    zone_id str
    The unique ID of the zone.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.

    getSnippet Result

    The following output properties are available:

    CreatedOn string
    The timestamp of when the snippet was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModifiedOn string
    The timestamp of when the snippet was last modified.
    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    CreatedOn string
    The timestamp of when the snippet was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModifiedOn string
    The timestamp of when the snippet was last modified.
    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    createdOn String
    The timestamp of when the snippet was created.
    id String
    The provider-assigned unique ID for this managed resource.
    modifiedOn String
    The timestamp of when the snippet was last modified.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.
    createdOn string
    The timestamp of when the snippet was created.
    id string
    The provider-assigned unique ID for this managed resource.
    modifiedOn string
    The timestamp of when the snippet was last modified.
    snippetName string
    The identifying name of the snippet.
    zoneId string
    The unique ID of the zone.
    created_on str
    The timestamp of when the snippet was created.
    id str
    The provider-assigned unique ID for this managed resource.
    modified_on str
    The timestamp of when the snippet was last modified.
    snippet_name str
    The identifying name of the snippet.
    zone_id str
    The unique ID of the zone.
    createdOn String
    The timestamp of when the snippet was created.
    id String
    The provider-assigned unique ID for this managed resource.
    modifiedOn String
    The timestamp of when the snippet was last modified.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v6.8.0 published on Saturday, Aug 30, 2025 by Pulumi