1. Packages
  2. Prefect Provider
  3. API Docs
  4. BlockSchema
prefect 2.27.1 published on Wednesday, Jun 11, 2025 by prefecthq

prefect.BlockSchema

Explore with Pulumi AI

prefect logo
prefect 2.27.1 published on Wednesday, Jun 11, 2025 by prefecthq

    The resource block_schema allows creating and managing Prefect Block Schemas.

    This feature is available in the following product plan(s): .

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as prefect from "@pulumi/prefect";
    
    const testBlockType = new prefect.BlockType("testBlockType", {
        slug: "my-block-type",
        logoUrl: "https://example.com/logo.png",
        documentationUrl: "https://example.com/documentation",
        description: "My custom block type",
        codeExample: "Some code example",
    });
    const testBlockSchema = new prefect.BlockSchema("testBlockSchema", {
        blockTypeId: testBlockType.id,
        capabilities: [
            "read",
            "write",
        ],
        version: "1.0.0",
        fields: JSON.stringify({
            title: "x",
            type: "object",
            properties: {
                foo: {
                    title: "Foo",
                    type: "string",
                },
            },
        }),
    });
    
    import pulumi
    import json
    import pulumi_prefect as prefect
    
    test_block_type = prefect.BlockType("testBlockType",
        slug="my-block-type",
        logo_url="https://example.com/logo.png",
        documentation_url="https://example.com/documentation",
        description="My custom block type",
        code_example="Some code example")
    test_block_schema = prefect.BlockSchema("testBlockSchema",
        block_type_id=test_block_type.id,
        capabilities=[
            "read",
            "write",
        ],
        version="1.0.0",
        fields=json.dumps({
            "title": "x",
            "type": "object",
            "properties": {
                "foo": {
                    "title": "Foo",
                    "type": "string",
                },
            },
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/prefect/v2/prefect"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		testBlockType, err := prefect.NewBlockType(ctx, "testBlockType", &prefect.BlockTypeArgs{
    			Slug:             pulumi.String("my-block-type"),
    			LogoUrl:          pulumi.String("https://example.com/logo.png"),
    			DocumentationUrl: pulumi.String("https://example.com/documentation"),
    			Description:      pulumi.String("My custom block type"),
    			CodeExample:      pulumi.String("Some code example"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"title": "x",
    			"type":  "object",
    			"properties": map[string]interface{}{
    				"foo": map[string]interface{}{
    					"title": "Foo",
    					"type":  "string",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = prefect.NewBlockSchema(ctx, "testBlockSchema", &prefect.BlockSchemaArgs{
    			BlockTypeId: testBlockType.ID(),
    			Capabilities: pulumi.StringArray{
    				pulumi.String("read"),
    				pulumi.String("write"),
    			},
    			Version: pulumi.String("1.0.0"),
    			Fields:  pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Prefect = Pulumi.Prefect;
    
    return await Deployment.RunAsync(() => 
    {
        var testBlockType = new Prefect.BlockType("testBlockType", new()
        {
            Slug = "my-block-type",
            LogoUrl = "https://example.com/logo.png",
            DocumentationUrl = "https://example.com/documentation",
            Description = "My custom block type",
            CodeExample = "Some code example",
        });
    
        var testBlockSchema = new Prefect.BlockSchema("testBlockSchema", new()
        {
            BlockTypeId = testBlockType.Id,
            Capabilities = new[]
            {
                "read",
                "write",
            },
            Version = "1.0.0",
            Fields = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["title"] = "x",
                ["type"] = "object",
                ["properties"] = new Dictionary<string, object?>
                {
                    ["foo"] = new Dictionary<string, object?>
                    {
                        ["title"] = "Foo",
                        ["type"] = "string",
                    },
                },
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.prefect.BlockType;
    import com.pulumi.prefect.BlockTypeArgs;
    import com.pulumi.prefect.BlockSchema;
    import com.pulumi.prefect.BlockSchemaArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 testBlockType = new BlockType("testBlockType", BlockTypeArgs.builder()
                .slug("my-block-type")
                .logoUrl("https://example.com/logo.png")
                .documentationUrl("https://example.com/documentation")
                .description("My custom block type")
                .codeExample("Some code example")
                .build());
    
            var testBlockSchema = new BlockSchema("testBlockSchema", BlockSchemaArgs.builder()
                .blockTypeId(testBlockType.id())
                .capabilities(            
                    "read",
                    "write")
                .version("1.0.0")
                .fields(serializeJson(
                    jsonObject(
                        jsonProperty("title", "x"),
                        jsonProperty("type", "object"),
                        jsonProperty("properties", jsonObject(
                            jsonProperty("foo", jsonObject(
                                jsonProperty("title", "Foo"),
                                jsonProperty("type", "string")
                            ))
                        ))
                    )))
                .build());
    
        }
    }
    
    resources:
      testBlockType:
        type: prefect:BlockType
        properties:
          slug: my-block-type
          logoUrl: https://example.com/logo.png
          documentationUrl: https://example.com/documentation
          description: My custom block type
          codeExample: Some code example
      testBlockSchema:
        type: prefect:BlockSchema
        properties:
          blockTypeId: ${testBlockType.id}
          capabilities:
            - read
            - write
          version: 1.0.0
          fields:
            fn::toJSON:
              title: x
              type: object
              properties:
                foo:
                  title: Foo
                  type: string
    

    Create BlockSchema Resource

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

    Constructor syntax

    new BlockSchema(name: string, args: BlockSchemaArgs, opts?: CustomResourceOptions);
    @overload
    def BlockSchema(resource_name: str,
                    args: BlockSchemaArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def BlockSchema(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    block_type_id: Optional[str] = None,
                    account_id: Optional[str] = None,
                    capabilities: Optional[Sequence[str]] = None,
                    fields: Optional[str] = None,
                    version: Optional[str] = None,
                    workspace_id: Optional[str] = None)
    func NewBlockSchema(ctx *Context, name string, args BlockSchemaArgs, opts ...ResourceOption) (*BlockSchema, error)
    public BlockSchema(string name, BlockSchemaArgs args, CustomResourceOptions? opts = null)
    public BlockSchema(String name, BlockSchemaArgs args)
    public BlockSchema(String name, BlockSchemaArgs args, CustomResourceOptions options)
    
    type: prefect:BlockSchema
    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 BlockSchemaArgs
    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 BlockSchemaArgs
    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 BlockSchemaArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BlockSchemaArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BlockSchemaArgs
    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 blockSchemaResource = new Prefect.BlockSchema("blockSchemaResource", new()
    {
        BlockTypeId = "string",
        AccountId = "string",
        Capabilities = new[]
        {
            "string",
        },
        Fields = "string",
        Version = "string",
        WorkspaceId = "string",
    });
    
    example, err := prefect.NewBlockSchema(ctx, "blockSchemaResource", &prefect.BlockSchemaArgs{
    	BlockTypeId: pulumi.String("string"),
    	AccountId:   pulumi.String("string"),
    	Capabilities: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Fields:      pulumi.String("string"),
    	Version:     pulumi.String("string"),
    	WorkspaceId: pulumi.String("string"),
    })
    
    var blockSchemaResource = new BlockSchema("blockSchemaResource", BlockSchemaArgs.builder()
        .blockTypeId("string")
        .accountId("string")
        .capabilities("string")
        .fields("string")
        .version("string")
        .workspaceId("string")
        .build());
    
    block_schema_resource = prefect.BlockSchema("blockSchemaResource",
        block_type_id="string",
        account_id="string",
        capabilities=["string"],
        fields="string",
        version="string",
        workspace_id="string")
    
    const blockSchemaResource = new prefect.BlockSchema("blockSchemaResource", {
        blockTypeId: "string",
        accountId: "string",
        capabilities: ["string"],
        fields: "string",
        version: "string",
        workspaceId: "string",
    });
    
    type: prefect:BlockSchema
    properties:
        accountId: string
        blockTypeId: string
        capabilities:
            - string
        fields: string
        version: string
        workspaceId: string
    

    BlockSchema 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 BlockSchema resource accepts the following input properties:

    BlockTypeId string
    The ID of the block type.
    AccountId string
    Account ID (UUID) where the Block is located
    Capabilities List<string>
    The capabilities of the block schema.
    Fields string
    The fields of the block schema.
    Version string
    The version of the block schema.
    WorkspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    BlockTypeId string
    The ID of the block type.
    AccountId string
    Account ID (UUID) where the Block is located
    Capabilities []string
    The capabilities of the block schema.
    Fields string
    The fields of the block schema.
    Version string
    The version of the block schema.
    WorkspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    blockTypeId String
    The ID of the block type.
    accountId String
    Account ID (UUID) where the Block is located
    capabilities List<String>
    The capabilities of the block schema.
    fields String
    The fields of the block schema.
    version String
    The version of the block schema.
    workspaceId String
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    blockTypeId string
    The ID of the block type.
    accountId string
    Account ID (UUID) where the Block is located
    capabilities string[]
    The capabilities of the block schema.
    fields string
    The fields of the block schema.
    version string
    The version of the block schema.
    workspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    block_type_id str
    The ID of the block type.
    account_id str
    Account ID (UUID) where the Block is located
    capabilities Sequence[str]
    The capabilities of the block schema.
    fields str
    The fields of the block schema.
    version str
    The version of the block schema.
    workspace_id str
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    blockTypeId String
    The ID of the block type.
    accountId String
    Account ID (UUID) where the Block is located
    capabilities List<String>
    The capabilities of the block schema.
    fields String
    The fields of the block schema.
    version String
    The version of the block schema.
    workspaceId String
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.

    Outputs

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

    BlockType string
    The type of the block.
    Checksum string
    The checksum of the block schema.
    Created string
    Timestamp of when the resource was created (RFC3339)
    Id string
    The provider-assigned unique ID for this managed resource.
    Updated string
    Timestamp of when the resource was updated (RFC3339)
    BlockType string
    The type of the block.
    Checksum string
    The checksum of the block schema.
    Created string
    Timestamp of when the resource was created (RFC3339)
    Id string
    The provider-assigned unique ID for this managed resource.
    Updated string
    Timestamp of when the resource was updated (RFC3339)
    blockType String
    The type of the block.
    checksum String
    The checksum of the block schema.
    created String
    Timestamp of when the resource was created (RFC3339)
    id String
    The provider-assigned unique ID for this managed resource.
    updated String
    Timestamp of when the resource was updated (RFC3339)
    blockType string
    The type of the block.
    checksum string
    The checksum of the block schema.
    created string
    Timestamp of when the resource was created (RFC3339)
    id string
    The provider-assigned unique ID for this managed resource.
    updated string
    Timestamp of when the resource was updated (RFC3339)
    block_type str
    The type of the block.
    checksum str
    The checksum of the block schema.
    created str
    Timestamp of when the resource was created (RFC3339)
    id str
    The provider-assigned unique ID for this managed resource.
    updated str
    Timestamp of when the resource was updated (RFC3339)
    blockType String
    The type of the block.
    checksum String
    The checksum of the block schema.
    created String
    Timestamp of when the resource was created (RFC3339)
    id String
    The provider-assigned unique ID for this managed resource.
    updated String
    Timestamp of when the resource was updated (RFC3339)

    Look up Existing BlockSchema Resource

    Get an existing BlockSchema 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?: BlockSchemaState, opts?: CustomResourceOptions): BlockSchema
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            block_type: Optional[str] = None,
            block_type_id: Optional[str] = None,
            capabilities: Optional[Sequence[str]] = None,
            checksum: Optional[str] = None,
            created: Optional[str] = None,
            fields: Optional[str] = None,
            updated: Optional[str] = None,
            version: Optional[str] = None,
            workspace_id: Optional[str] = None) -> BlockSchema
    func GetBlockSchema(ctx *Context, name string, id IDInput, state *BlockSchemaState, opts ...ResourceOption) (*BlockSchema, error)
    public static BlockSchema Get(string name, Input<string> id, BlockSchemaState? state, CustomResourceOptions? opts = null)
    public static BlockSchema get(String name, Output<String> id, BlockSchemaState state, CustomResourceOptions options)
    resources:  _:    type: prefect:BlockSchema    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:
    AccountId string
    Account ID (UUID) where the Block is located
    BlockType string
    The type of the block.
    BlockTypeId string
    The ID of the block type.
    Capabilities List<string>
    The capabilities of the block schema.
    Checksum string
    The checksum of the block schema.
    Created string
    Timestamp of when the resource was created (RFC3339)
    Fields string
    The fields of the block schema.
    Updated string
    Timestamp of when the resource was updated (RFC3339)
    Version string
    The version of the block schema.
    WorkspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    AccountId string
    Account ID (UUID) where the Block is located
    BlockType string
    The type of the block.
    BlockTypeId string
    The ID of the block type.
    Capabilities []string
    The capabilities of the block schema.
    Checksum string
    The checksum of the block schema.
    Created string
    Timestamp of when the resource was created (RFC3339)
    Fields string
    The fields of the block schema.
    Updated string
    Timestamp of when the resource was updated (RFC3339)
    Version string
    The version of the block schema.
    WorkspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    accountId String
    Account ID (UUID) where the Block is located
    blockType String
    The type of the block.
    blockTypeId String
    The ID of the block type.
    capabilities List<String>
    The capabilities of the block schema.
    checksum String
    The checksum of the block schema.
    created String
    Timestamp of when the resource was created (RFC3339)
    fields String
    The fields of the block schema.
    updated String
    Timestamp of when the resource was updated (RFC3339)
    version String
    The version of the block schema.
    workspaceId String
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    accountId string
    Account ID (UUID) where the Block is located
    blockType string
    The type of the block.
    blockTypeId string
    The ID of the block type.
    capabilities string[]
    The capabilities of the block schema.
    checksum string
    The checksum of the block schema.
    created string
    Timestamp of when the resource was created (RFC3339)
    fields string
    The fields of the block schema.
    updated string
    Timestamp of when the resource was updated (RFC3339)
    version string
    The version of the block schema.
    workspaceId string
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    account_id str
    Account ID (UUID) where the Block is located
    block_type str
    The type of the block.
    block_type_id str
    The ID of the block type.
    capabilities Sequence[str]
    The capabilities of the block schema.
    checksum str
    The checksum of the block schema.
    created str
    Timestamp of when the resource was created (RFC3339)
    fields str
    The fields of the block schema.
    updated str
    Timestamp of when the resource was updated (RFC3339)
    version str
    The version of the block schema.
    workspace_id str
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.
    accountId String
    Account ID (UUID) where the Block is located
    blockType String
    The type of the block.
    blockTypeId String
    The ID of the block type.
    capabilities List<String>
    The capabilities of the block schema.
    checksum String
    The checksum of the block schema.
    created String
    Timestamp of when the resource was created (RFC3339)
    fields String
    The fields of the block schema.
    updated String
    Timestamp of when the resource was updated (RFC3339)
    version String
    The version of the block schema.
    workspaceId String
    Workspace ID (UUID) where the Block is located. In Prefect Cloud, either the prefect.Block resource or the provider's workspace_id must be set.

    Import

    prefect_block_schema resources can be imported by the block_schema_id

    $ pulumi import prefect:index/blockSchema:BlockSchema my_block_schema 00000000-0000-0000-0000-000000000000
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    prefect prefecthq/terraform-provider-prefect
    License
    Notes
    This Pulumi package is based on the prefect Terraform Provider.
    prefect logo
    prefect 2.27.1 published on Wednesday, Jun 11, 2025 by prefecthq