1. Packages
  2. Scaleway
  3. API Docs
  4. FunctionCron
Scaleway v1.14.0 published on Thursday, Jun 6, 2024 by pulumiverse

scaleway.FunctionCron

Explore with Pulumi AI

scaleway logo
Scaleway v1.14.0 published on Thursday, Jun 6, 2024 by pulumiverse

    Creates and manages Scaleway Function Triggers. For the moment, the feature is limited to CRON Schedule (time-based).

    For more details about the limitation check functions-limitations.

    You can check also our functions cron api documentation.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const mainFunctionNamespace = new scaleway.FunctionNamespace("mainFunctionNamespace", {});
    const mainFunction = new scaleway.Function("mainFunction", {
        namespaceId: mainFunctionNamespace.id,
        runtime: "node14",
        privacy: "private",
        handler: "handler.handle",
    });
    const mainFunctionCron = new scaleway.FunctionCron("mainFunctionCron", {
        functionId: mainFunction.id,
        schedule: "0 0 * * *",
        args: JSON.stringify({
            test: "scw",
        }),
    });
    const func = new scaleway.FunctionCron("func", {
        functionId: mainFunction.id,
        schedule: "0 1 * * *",
        args: JSON.stringify({
            my_var: "terraform",
        }),
    });
    
    import pulumi
    import json
    import pulumiverse_scaleway as scaleway
    
    main_function_namespace = scaleway.FunctionNamespace("mainFunctionNamespace")
    main_function = scaleway.Function("mainFunction",
        namespace_id=main_function_namespace.id,
        runtime="node14",
        privacy="private",
        handler="handler.handle")
    main_function_cron = scaleway.FunctionCron("mainFunctionCron",
        function_id=main_function.id,
        schedule="0 0 * * *",
        args=json.dumps({
            "test": "scw",
        }))
    func = scaleway.FunctionCron("func",
        function_id=main_function.id,
        schedule="0 1 * * *",
        args=json.dumps({
            "my_var": "terraform",
        }))
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		mainFunctionNamespace, err := scaleway.NewFunctionNamespace(ctx, "mainFunctionNamespace", nil)
    		if err != nil {
    			return err
    		}
    		mainFunction, err := scaleway.NewFunction(ctx, "mainFunction", &scaleway.FunctionArgs{
    			NamespaceId: mainFunctionNamespace.ID(),
    			Runtime:     pulumi.String("node14"),
    			Privacy:     pulumi.String("private"),
    			Handler:     pulumi.String("handler.handle"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"test": "scw",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = scaleway.NewFunctionCron(ctx, "mainFunctionCron", &scaleway.FunctionCronArgs{
    			FunctionId: mainFunction.ID(),
    			Schedule:   pulumi.String("0 0 * * *"),
    			Args:       pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"my_var": "terraform",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		_, err = scaleway.NewFunctionCron(ctx, "func", &scaleway.FunctionCronArgs{
    			FunctionId: mainFunction.ID(),
    			Schedule:   pulumi.String("0 1 * * *"),
    			Args:       pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var mainFunctionNamespace = new Scaleway.FunctionNamespace("mainFunctionNamespace");
    
        var mainFunction = new Scaleway.Function("mainFunction", new()
        {
            NamespaceId = mainFunctionNamespace.Id,
            Runtime = "node14",
            Privacy = "private",
            Handler = "handler.handle",
        });
    
        var mainFunctionCron = new Scaleway.FunctionCron("mainFunctionCron", new()
        {
            FunctionId = mainFunction.Id,
            Schedule = "0 0 * * *",
            Args = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["test"] = "scw",
            }),
        });
    
        var func = new Scaleway.FunctionCron("func", new()
        {
            FunctionId = mainFunction.Id,
            Schedule = "0 1 * * *",
            Args = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["my_var"] = "terraform",
            }),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.scaleway.FunctionNamespace;
    import com.pulumi.scaleway.Function;
    import com.pulumi.scaleway.FunctionArgs;
    import com.pulumi.scaleway.FunctionCron;
    import com.pulumi.scaleway.FunctionCronArgs;
    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 mainFunctionNamespace = new FunctionNamespace("mainFunctionNamespace");
    
            var mainFunction = new Function("mainFunction", FunctionArgs.builder()        
                .namespaceId(mainFunctionNamespace.id())
                .runtime("node14")
                .privacy("private")
                .handler("handler.handle")
                .build());
    
            var mainFunctionCron = new FunctionCron("mainFunctionCron", FunctionCronArgs.builder()        
                .functionId(mainFunction.id())
                .schedule("0 0 * * *")
                .args(serializeJson(
                    jsonObject(
                        jsonProperty("test", "scw")
                    )))
                .build());
    
            var func = new FunctionCron("func", FunctionCronArgs.builder()        
                .functionId(mainFunction.id())
                .schedule("0 1 * * *")
                .args(serializeJson(
                    jsonObject(
                        jsonProperty("my_var", "terraform")
                    )))
                .build());
    
        }
    }
    
    resources:
      mainFunctionNamespace:
        type: scaleway:FunctionNamespace
      mainFunction:
        type: scaleway:Function
        properties:
          namespaceId: ${mainFunctionNamespace.id}
          runtime: node14
          privacy: private
          handler: handler.handle
      mainFunctionCron:
        type: scaleway:FunctionCron
        properties:
          functionId: ${mainFunction.id}
          schedule: 0 0 * * *
          args:
            fn::toJSON:
              test: scw
      func:
        type: scaleway:FunctionCron
        properties:
          functionId: ${mainFunction.id}
          schedule: 0 1 * * *
          args:
            fn::toJSON:
              my_var: terraform
    

    Create FunctionCron Resource

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

    Constructor syntax

    new FunctionCron(name: string, args: FunctionCronArgs, opts?: CustomResourceOptions);
    @overload
    def FunctionCron(resource_name: str,
                     args: FunctionCronArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def FunctionCron(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     args: Optional[str] = None,
                     function_id: Optional[str] = None,
                     schedule: Optional[str] = None,
                     name: Optional[str] = None,
                     region: Optional[str] = None)
    func NewFunctionCron(ctx *Context, name string, args FunctionCronArgs, opts ...ResourceOption) (*FunctionCron, error)
    public FunctionCron(string name, FunctionCronArgs args, CustomResourceOptions? opts = null)
    public FunctionCron(String name, FunctionCronArgs args)
    public FunctionCron(String name, FunctionCronArgs args, CustomResourceOptions options)
    
    type: scaleway:FunctionCron
    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 FunctionCronArgs
    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 FunctionCronArgs
    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 FunctionCronArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FunctionCronArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FunctionCronArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var functionCronResource = new Scaleway.FunctionCron("functionCronResource", new()
    {
        Args = "string",
        FunctionId = "string",
        Schedule = "string",
        Name = "string",
        Region = "string",
    });
    
    example, err := scaleway.NewFunctionCron(ctx, "functionCronResource", &scaleway.FunctionCronArgs{
    	Args:       pulumi.String("string"),
    	FunctionId: pulumi.String("string"),
    	Schedule:   pulumi.String("string"),
    	Name:       pulumi.String("string"),
    	Region:     pulumi.String("string"),
    })
    
    var functionCronResource = new FunctionCron("functionCronResource", FunctionCronArgs.builder()
        .args("string")
        .functionId("string")
        .schedule("string")
        .name("string")
        .region("string")
        .build());
    
    function_cron_resource = scaleway.FunctionCron("functionCronResource",
        args="string",
        function_id="string",
        schedule="string",
        name="string",
        region="string")
    
    const functionCronResource = new scaleway.FunctionCron("functionCronResource", {
        args: "string",
        functionId: "string",
        schedule: "string",
        name: "string",
        region: "string",
    });
    
    type: scaleway:FunctionCron
    properties:
        args: string
        functionId: string
        name: string
        region: string
        schedule: string
    

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

    Args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    FunctionId string
    The function ID to link with your cron.
    Schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    Name string
    The name of the cron. If not provided, the name is generated.
    Region string
    region) The region in where the job was created.
    Args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    FunctionId string
    The function ID to link with your cron.
    Schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    Name string
    The name of the cron. If not provided, the name is generated.
    Region string
    region) The region in where the job was created.
    args String
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId String
    The function ID to link with your cron.
    schedule String
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    name String
    The name of the cron. If not provided, the name is generated.
    region String
    region) The region in where the job was created.
    args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId string
    The function ID to link with your cron.
    schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    name string
    The name of the cron. If not provided, the name is generated.
    region string
    region) The region in where the job was created.
    args str
    The key-value mapping to define arguments that will be passed to your function’s event object during
    function_id str
    The function ID to link with your cron.
    schedule str
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    name str
    The name of the cron. If not provided, the name is generated.
    region str
    region) The region in where the job was created.
    args String
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId String
    The function ID to link with your cron.
    schedule String
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    name String
    The name of the cron. If not provided, the name is generated.
    region String
    region) The region in where the job was created.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The cron status.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The cron status.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The cron status.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    The cron status.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    The cron status.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The cron status.

    Look up Existing FunctionCron Resource

    Get an existing FunctionCron 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?: FunctionCronState, opts?: CustomResourceOptions): FunctionCron
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            args: Optional[str] = None,
            function_id: Optional[str] = None,
            name: Optional[str] = None,
            region: Optional[str] = None,
            schedule: Optional[str] = None,
            status: Optional[str] = None) -> FunctionCron
    func GetFunctionCron(ctx *Context, name string, id IDInput, state *FunctionCronState, opts ...ResourceOption) (*FunctionCron, error)
    public static FunctionCron Get(string name, Input<string> id, FunctionCronState? state, CustomResourceOptions? opts = null)
    public static FunctionCron get(String name, Output<String> id, FunctionCronState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    Args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    FunctionId string
    The function ID to link with your cron.
    Name string
    The name of the cron. If not provided, the name is generated.
    Region string
    region) The region in where the job was created.
    Schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    Status string
    The cron status.
    Args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    FunctionId string
    The function ID to link with your cron.
    Name string
    The name of the cron. If not provided, the name is generated.
    Region string
    region) The region in where the job was created.
    Schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    Status string
    The cron status.
    args String
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId String
    The function ID to link with your cron.
    name String
    The name of the cron. If not provided, the name is generated.
    region String
    region) The region in where the job was created.
    schedule String
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    status String
    The cron status.
    args string
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId string
    The function ID to link with your cron.
    name string
    The name of the cron. If not provided, the name is generated.
    region string
    region) The region in where the job was created.
    schedule string
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    status string
    The cron status.
    args str
    The key-value mapping to define arguments that will be passed to your function’s event object during
    function_id str
    The function ID to link with your cron.
    name str
    The name of the cron. If not provided, the name is generated.
    region str
    region) The region in where the job was created.
    schedule str
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    status str
    The cron status.
    args String
    The key-value mapping to define arguments that will be passed to your function’s event object during
    functionId String
    The function ID to link with your cron.
    name String
    The name of the cron. If not provided, the name is generated.
    region String
    region) The region in where the job was created.
    schedule String
    Cron format string, e.g. @hourly, as schedule time of its jobs to be created and executed.
    status String
    The cron status.

    Import

    Container Cron can be imported using the {region}/{id}, e.g.

    bash

    $ pulumi import scaleway:index/functionCron:FunctionCron main fr-par/11111111-1111-1111-1111-111111111111
    

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

    Package Details

    Repository
    scaleway pulumiverse/pulumi-scaleway
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the scaleway Terraform Provider.
    scaleway logo
    Scaleway v1.14.0 published on Thursday, Jun 6, 2024 by pulumiverse