1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. Snippet
Cloudflare v6.10.0 published on Thursday, Oct 2, 2025 by Pulumi

cloudflare.Snippet

Explore with Pulumi AI

cloudflare logo
Cloudflare v6.10.0 published on Thursday, Oct 2, 2025 by Pulumi

    Example Usage

    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    resources:
      exampleSnippet:
        type: cloudflare:Snippet
        name: example_snippet
        properties:
          zoneId: 9f1839b6152d298aca64c4e906b6d074
          snippetName: my_snippet
          files:
            - name: main.js
              content: |
                export default {
                  async fetch(request) {
                    return new Response('Hello, World!');
                  }
                }            
          metadata:
            main_module: main.js
    

    Create Snippet Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Snippet(name: string, args: SnippetArgs, opts?: CustomResourceOptions);
    @overload
    def Snippet(resource_name: str,
                args: SnippetArgs,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def Snippet(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                files: Optional[Sequence[SnippetFileArgs]] = None,
                metadata: Optional[SnippetMetadataArgs] = None,
                snippet_name: Optional[str] = None,
                zone_id: Optional[str] = None)
    func NewSnippet(ctx *Context, name string, args SnippetArgs, opts ...ResourceOption) (*Snippet, error)
    public Snippet(string name, SnippetArgs args, CustomResourceOptions? opts = null)
    public Snippet(String name, SnippetArgs args)
    public Snippet(String name, SnippetArgs args, CustomResourceOptions options)
    
    type: cloudflare:Snippet
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args SnippetArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args SnippetArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args SnippetArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SnippetArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SnippetArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var snippetResource = new Cloudflare.Snippet("snippetResource", new()
    {
        Files = new[]
        {
            new Cloudflare.Inputs.SnippetFileArgs
            {
                Content = "string",
                Name = "string",
            },
        },
        Metadata = new Cloudflare.Inputs.SnippetMetadataArgs
        {
            MainModule = "string",
        },
        SnippetName = "string",
        ZoneId = "string",
    });
    
    example, err := cloudflare.NewSnippet(ctx, "snippetResource", &cloudflare.SnippetArgs{
    	Files: cloudflare.SnippetFileArray{
    		&cloudflare.SnippetFileArgs{
    			Content: pulumi.String("string"),
    			Name:    pulumi.String("string"),
    		},
    	},
    	Metadata: &cloudflare.SnippetMetadataArgs{
    		MainModule: pulumi.String("string"),
    	},
    	SnippetName: pulumi.String("string"),
    	ZoneId:      pulumi.String("string"),
    })
    
    var snippetResource = new Snippet("snippetResource", SnippetArgs.builder()
        .files(SnippetFileArgs.builder()
            .content("string")
            .name("string")
            .build())
        .metadata(SnippetMetadataArgs.builder()
            .mainModule("string")
            .build())
        .snippetName("string")
        .zoneId("string")
        .build());
    
    snippet_resource = cloudflare.Snippet("snippetResource",
        files=[{
            "content": "string",
            "name": "string",
        }],
        metadata={
            "main_module": "string",
        },
        snippet_name="string",
        zone_id="string")
    
    const snippetResource = new cloudflare.Snippet("snippetResource", {
        files: [{
            content: "string",
            name: "string",
        }],
        metadata: {
            mainModule: "string",
        },
        snippetName: "string",
        zoneId: "string",
    });
    
    type: cloudflare:Snippet
    properties:
        files:
            - content: string
              name: string
        metadata:
            mainModule: string
        snippetName: string
        zoneId: string
    

    Snippet Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Snippet resource accepts the following input properties:

    Files List<SnippetFile>
    The list of files belonging to the snippet.
    Metadata SnippetMetadata
    Metadata about the snippet.
    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    Files []SnippetFileArgs
    The list of files belonging to the snippet.
    Metadata SnippetMetadataArgs
    Metadata about the snippet.
    SnippetName string
    The identifying name of the snippet.
    ZoneId string
    The unique ID of the zone.
    files List<SnippetFile>
    The list of files belonging to the snippet.
    metadata SnippetMetadata
    Metadata about the snippet.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.
    files SnippetFile[]
    The list of files belonging to the snippet.
    metadata SnippetMetadata
    Metadata about the snippet.
    snippetName string
    The identifying name of the snippet.
    zoneId string
    The unique ID of the zone.
    files Sequence[SnippetFileArgs]
    The list of files belonging to the snippet.
    metadata SnippetMetadataArgs
    Metadata about the snippet.
    snippet_name str
    The identifying name of the snippet.
    zone_id str
    The unique ID of the zone.
    files List<Property Map>
    The list of files belonging to the snippet.
    metadata Property Map
    Metadata about the snippet.
    snippetName String
    The identifying name of the snippet.
    zoneId String
    The unique ID of the zone.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Snippet resource produces the following output properties:

    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.
    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.
    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.
    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.
    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.
    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.

    Look up Existing Snippet Resource

    Get an existing Snippet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: SnippetState, opts?: CustomResourceOptions): Snippet
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            created_on: Optional[str] = None,
            files: Optional[Sequence[SnippetFileArgs]] = None,
            metadata: Optional[SnippetMetadataArgs] = None,
            modified_on: Optional[str] = None,
            snippet_name: Optional[str] = None,
            zone_id: Optional[str] = None) -> Snippet
    func GetSnippet(ctx *Context, name string, id IDInput, state *SnippetState, opts ...ResourceOption) (*Snippet, error)
    public static Snippet Get(string name, Input<string> id, SnippetState? state, CustomResourceOptions? opts = null)
    public static Snippet get(String name, Output<String> id, SnippetState state, CustomResourceOptions options)
    resources:  _:    type: cloudflare:Snippet    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    CreatedOn string
    The timestamp of when the snippet was created.
    Files List<SnippetFile>
    The list of files belonging to the snippet.
    Metadata SnippetMetadata
    Metadata about the snippet.
    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.
    Files []SnippetFileArgs
    The list of files belonging to the snippet.
    Metadata SnippetMetadataArgs
    Metadata about the snippet.
    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.
    files List<SnippetFile>
    The list of files belonging to the snippet.
    metadata SnippetMetadata
    Metadata about the snippet.
    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.
    files SnippetFile[]
    The list of files belonging to the snippet.
    metadata SnippetMetadata
    Metadata about the snippet.
    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.
    files Sequence[SnippetFileArgs]
    The list of files belonging to the snippet.
    metadata SnippetMetadataArgs
    Metadata about the snippet.
    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.
    files List<Property Map>
    The list of files belonging to the snippet.
    metadata Property Map
    Metadata about the snippet.
    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.

    Supporting Types

    SnippetFile, SnippetFileArgs

    Content string
    Name string
    Content string
    Name string
    content String
    name String
    content string
    name string
    content str
    name str
    content String
    name String

    SnippetMetadata, SnippetMetadataArgs

    MainModule string
    Name of the file that contains the main module of the snippet.
    MainModule string
    Name of the file that contains the main module of the snippet.
    mainModule String
    Name of the file that contains the main module of the snippet.
    mainModule string
    Name of the file that contains the main module of the snippet.
    main_module str
    Name of the file that contains the main module of the snippet.
    mainModule String
    Name of the file that contains the main module of the snippet.

    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.10.0 published on Thursday, Oct 2, 2025 by Pulumi
      AI Agentic Workflows: Register now