Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

Snowflake

v0.2.1 published on Monday, Sep 27, 2021 by Pulumi

Procedure

Import

format is database name | schema name | stored procedure name | <list of arg types, separated with ‘-'>

 $ pulumi import snowflake:index/procedure:Procedure example 'dbName|schemaName|procedureName|varchar-varchar-varchar'

Example Usage

using Pulumi;
using Snowflake = Pulumi.Snowflake;

class MyStack : Stack
{
    public MyStack()
    {
        var db = new Snowflake.Schema("db", new Snowflake.SchemaArgs
        {
            DataRetentionDays = 1,
        });
        var schema = new Snowflake.Schema("schema", new Snowflake.SchemaArgs
        {
            Database = snowflake_database.Db.Name,
            DataRetentionDays = 1,
        });
        var proc = new Snowflake.Procedure("proc", new Snowflake.ProcedureArgs
        {
            Database = snowflake_database.Db.Name,
            Schema = schema.Name,
            Arguments = 
            {
                new Snowflake.Inputs.ProcedureArgumentArgs
                {
                    Name = "arg1",
                    Type = "varchar",
                },
                new Snowflake.Inputs.ProcedureArgumentArgs
                {
                    Name = "arg2",
                    Type = "DATE",
                },
            },
            Comment = "Procedure with 2 arguments",
            ReturnType = "VARCHAR",
            ExecuteAs = "CALLER",
            ReturnBehavior = "IMMUTABLE",
            NullInputBehavior = "RETURNS NULL ON NULL INPUT",
            Statement = @"var X=1
return X
",
        });
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-snowflake/sdk/go/snowflake"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := snowflake.NewSchema(ctx, "db", &snowflake.SchemaArgs{
			DataRetentionDays: pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		schema, err := snowflake.NewSchema(ctx, "schema", &snowflake.SchemaArgs{
			Database:          pulumi.Any(snowflake_database.Db.Name),
			DataRetentionDays: pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		_, err = snowflake.NewProcedure(ctx, "proc", &snowflake.ProcedureArgs{
			Database: pulumi.Any(snowflake_database.Db.Name),
			Schema:   schema.Name,
			Arguments: ProcedureArgumentArray{
				&ProcedureArgumentArgs{
					Name: pulumi.String("arg1"),
					Type: pulumi.String("varchar"),
				},
				&ProcedureArgumentArgs{
					Name: pulumi.String("arg2"),
					Type: pulumi.String("DATE"),
				},
			},
			Comment:           pulumi.String("Procedure with 2 arguments"),
			ReturnType:        pulumi.String("VARCHAR"),
			ExecuteAs:         pulumi.String("CALLER"),
			ReturnBehavior:    pulumi.String("IMMUTABLE"),
			NullInputBehavior: pulumi.String("RETURNS NULL ON NULL INPUT"),
			Statement:         pulumi.String(fmt.Sprintf("%v%v", "var X=1\n", "return X\n")),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_snowflake as snowflake

db = snowflake.Schema("db", data_retention_days=1)
schema = snowflake.Schema("schema",
    database=snowflake_database["db"]["name"],
    data_retention_days=1)
proc = snowflake.Procedure("proc",
    database=snowflake_database["db"]["name"],
    schema=schema.name,
    arguments=[
        snowflake.ProcedureArgumentArgs(
            name="arg1",
            type="varchar",
        ),
        snowflake.ProcedureArgumentArgs(
            name="arg2",
            type="DATE",
        ),
    ],
    comment="Procedure with 2 arguments",
    return_type="VARCHAR",
    execute_as="CALLER",
    return_behavior="IMMUTABLE",
    null_input_behavior="RETURNS NULL ON NULL INPUT",
    statement="""var X=1
return X
""")
import * as pulumi from "@pulumi/pulumi";
import * as snowflake from "@pulumi/snowflake";

const db = new snowflake.Schema("db", {dataRetentionDays: 1});
const schema = new snowflake.Schema("schema", {
    database: snowflake_database.db.name,
    dataRetentionDays: 1,
});
const proc = new snowflake.Procedure("proc", {
    database: snowflake_database.db.name,
    schema: schema.name,
    arguments: [
        {
            name: "arg1",
            type: "varchar",
        },
        {
            name: "arg2",
            type: "DATE",
        },
    ],
    comment: "Procedure with 2 arguments",
    returnType: "VARCHAR",
    executeAs: "CALLER",
    returnBehavior: "IMMUTABLE",
    nullInputBehavior: "RETURNS NULL ON NULL INPUT",
    statement: `var X=1
return X
`,
});

Create a Procedure Resource

new Procedure(name: string, args: ProcedureArgs, opts?: CustomResourceOptions);
@overload
def Procedure(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              arguments: Optional[Sequence[ProcedureArgumentArgs]] = None,
              comment: Optional[str] = None,
              database: Optional[str] = None,
              execute_as: Optional[str] = None,
              name: Optional[str] = None,
              null_input_behavior: Optional[str] = None,
              return_behavior: Optional[str] = None,
              return_type: Optional[str] = None,
              schema: Optional[str] = None,
              statement: Optional[str] = None)
@overload
def Procedure(resource_name: str,
              args: ProcedureArgs,
              opts: Optional[ResourceOptions] = None)
func NewProcedure(ctx *Context, name string, args ProcedureArgs, opts ...ResourceOption) (*Procedure, error)
public Procedure(string name, ProcedureArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ProcedureArgs
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 ProcedureArgs
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 ProcedureArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ProcedureArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Procedure Resource Properties

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

Inputs

The Procedure resource accepts the following input properties:

Database string
The database in which to create the procedure. Don’t use the | character.
ReturnType string
The return type of the procedure
Schema string
The schema in which to create the procedure. Don’t use the | character.
Statement string
Specifies the javascript code used to create the procedure.
Arguments List<ProcedureArgumentArgs>
List of the arguments for the procedure
Comment string
Specifies a comment for the procedure.
ExecuteAs string
Sets execute context - see caller’s rights and owner’s rights
Name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
NullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
ReturnBehavior string
Specifies the behavior of the function when returning results
Database string
The database in which to create the procedure. Don’t use the | character.
ReturnType string
The return type of the procedure
Schema string
The schema in which to create the procedure. Don’t use the | character.
Statement string
Specifies the javascript code used to create the procedure.
Arguments []ProcedureArgumentArgs
List of the arguments for the procedure
Comment string
Specifies a comment for the procedure.
ExecuteAs string
Sets execute context - see caller’s rights and owner’s rights
Name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
NullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
ReturnBehavior string
Specifies the behavior of the function when returning results
database string
The database in which to create the procedure. Don’t use the | character.
returnType string
The return type of the procedure
schema string
The schema in which to create the procedure. Don’t use the | character.
statement string
Specifies the javascript code used to create the procedure.
arguments ProcedureArgumentArgs[]
List of the arguments for the procedure
comment string
Specifies a comment for the procedure.
executeAs string
Sets execute context - see caller’s rights and owner’s rights
name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
nullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
returnBehavior string
Specifies the behavior of the function when returning results
database str
The database in which to create the procedure. Don’t use the | character.
return_type str
The return type of the procedure
schema str
The schema in which to create the procedure. Don’t use the | character.
statement str
Specifies the javascript code used to create the procedure.
arguments Sequence[ProcedureArgumentArgs]
List of the arguments for the procedure
comment str
Specifies a comment for the procedure.
execute_as str
Sets execute context - see caller’s rights and owner’s rights
name str
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
null_input_behavior str
Specifies the behavior of the procedure when called with null inputs.
return_behavior str
Specifies the behavior of the function when returning results

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Procedure Resource

Get an existing Procedure 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?: ProcedureState, opts?: CustomResourceOptions): Procedure
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arguments: Optional[Sequence[ProcedureArgumentArgs]] = None,
        comment: Optional[str] = None,
        database: Optional[str] = None,
        execute_as: Optional[str] = None,
        name: Optional[str] = None,
        null_input_behavior: Optional[str] = None,
        return_behavior: Optional[str] = None,
        return_type: Optional[str] = None,
        schema: Optional[str] = None,
        statement: Optional[str] = None) -> Procedure
func GetProcedure(ctx *Context, name string, id IDInput, state *ProcedureState, opts ...ResourceOption) (*Procedure, error)
public static Procedure Get(string name, Input<string> id, ProcedureState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

Arguments List<ProcedureArgumentArgs>
List of the arguments for the procedure
Comment string
Specifies a comment for the procedure.
Database string
The database in which to create the procedure. Don’t use the | character.
ExecuteAs string
Sets execute context - see caller’s rights and owner’s rights
Name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
NullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
ReturnBehavior string
Specifies the behavior of the function when returning results
ReturnType string
The return type of the procedure
Schema string
The schema in which to create the procedure. Don’t use the | character.
Statement string
Specifies the javascript code used to create the procedure.
Arguments []ProcedureArgumentArgs
List of the arguments for the procedure
Comment string
Specifies a comment for the procedure.
Database string
The database in which to create the procedure. Don’t use the | character.
ExecuteAs string
Sets execute context - see caller’s rights and owner’s rights
Name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
NullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
ReturnBehavior string
Specifies the behavior of the function when returning results
ReturnType string
The return type of the procedure
Schema string
The schema in which to create the procedure. Don’t use the | character.
Statement string
Specifies the javascript code used to create the procedure.
arguments ProcedureArgumentArgs[]
List of the arguments for the procedure
comment string
Specifies a comment for the procedure.
database string
The database in which to create the procedure. Don’t use the | character.
executeAs string
Sets execute context - see caller’s rights and owner’s rights
name string
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
nullInputBehavior string
Specifies the behavior of the procedure when called with null inputs.
returnBehavior string
Specifies the behavior of the function when returning results
returnType string
The return type of the procedure
schema string
The schema in which to create the procedure. Don’t use the | character.
statement string
Specifies the javascript code used to create the procedure.
arguments Sequence[ProcedureArgumentArgs]
List of the arguments for the procedure
comment str
Specifies a comment for the procedure.
database str
The database in which to create the procedure. Don’t use the | character.
execute_as str
Sets execute context - see caller’s rights and owner’s rights
name str
Specifies the identifier for the procedure; does not have to be unique for the schema in which the procedure is created. Don’t use the | character.
null_input_behavior str
Specifies the behavior of the procedure when called with null inputs.
return_behavior str
Specifies the behavior of the function when returning results
return_type str
The return type of the procedure
schema str
The schema in which to create the procedure. Don’t use the | character.
statement str
Specifies the javascript code used to create the procedure.

Supporting Types

ProcedureArgument

Name string
The argument name
Type string
The argument type
Name string
The argument name
Type string
The argument type
name string
The argument name
type string
The argument type
name str
The argument name
type str
The argument type

Package Details

Repository
https://github.com/pulumi/pulumi-snowflake
License
Apache-2.0
Notes
This Pulumi package is based on the snowflake Terraform Provider.