1. Packages
  2. Scaleway
  3. API Docs
  4. FunctionCron
Scaleway v1.25.0 published on Saturday, Mar 22, 2025 by pulumiverse

scaleway.FunctionCron

Explore with Pulumi AI

Deprecated: scaleway.index/functioncron.FunctionCron has been deprecated in favor of scaleway.functions/cron.Cron

The scaleway.functions.Cron resource allows you to create and manage CRON triggers for Scaleway Serverless Functions.

Refer to the Functions CRON triggers documentation and API documentation for more information.

Example Usage

The following command allows you to add a CRON trigger to a Serverless Function.

import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@pulumiverse/scaleway";

const main = new scaleway.functions.Namespace("main", {name: "test-cron"});
const mainFunction = new scaleway.functions.Function("main", {
    name: "test-cron",
    namespaceId: main.id,
    runtime: "node14",
    privacy: "private",
    handler: "handler.handle",
});
const mainCron = new scaleway.functions.Cron("main", {
    name: "test-cron",
    functionId: mainFunction.id,
    schedule: "0 0 * * *",
    args: JSON.stringify({
        test: "scw",
    }),
});
const func = new scaleway.functions.Cron("func", {
    functionId: mainFunction.id,
    schedule: "0 1 * * *",
    args: JSON.stringify({
        my_var: "terraform",
    }),
});
Copy
import pulumi
import json
import pulumiverse_scaleway as scaleway

main = scaleway.functions.Namespace("main", name="test-cron")
main_function = scaleway.functions.Function("main",
    name="test-cron",
    namespace_id=main.id,
    runtime="node14",
    privacy="private",
    handler="handler.handle")
main_cron = scaleway.functions.Cron("main",
    name="test-cron",
    function_id=main_function.id,
    schedule="0 0 * * *",
    args=json.dumps({
        "test": "scw",
    }))
func = scaleway.functions.Cron("func",
    function_id=main_function.id,
    schedule="0 1 * * *",
    args=json.dumps({
        "my_var": "terraform",
    }))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway/functions"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		main, err := functions.NewNamespace(ctx, "main", &functions.NamespaceArgs{
			Name: pulumi.String("test-cron"),
		})
		if err != nil {
			return err
		}
		mainFunction, err := functions.NewFunction(ctx, "main", &functions.FunctionArgs{
			Name:        pulumi.String("test-cron"),
			NamespaceId: main.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 = functions.NewCron(ctx, "main", &functions.CronArgs{
			Name:       pulumi.String("test-cron"),
			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 = functions.NewCron(ctx, "func", &functions.CronArgs{
			FunctionId: mainFunction.ID(),
			Schedule:   pulumi.String("0 1 * * *"),
			Args:       pulumi.String(json1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Scaleway = Pulumiverse.Scaleway;

return await Deployment.RunAsync(() => 
{
    var main = new Scaleway.Functions.Namespace("main", new()
    {
        Name = "test-cron",
    });

    var mainFunction = new Scaleway.Functions.Function("main", new()
    {
        Name = "test-cron",
        NamespaceId = main.Id,
        Runtime = "node14",
        Privacy = "private",
        Handler = "handler.handle",
    });

    var mainCron = new Scaleway.Functions.Cron("main", new()
    {
        Name = "test-cron",
        FunctionId = mainFunction.Id,
        Schedule = "0 0 * * *",
        Args = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["test"] = "scw",
        }),
    });

    var func = new Scaleway.Functions.Cron("func", new()
    {
        FunctionId = mainFunction.Id,
        Schedule = "0 1 * * *",
        Args = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["my_var"] = "terraform",
        }),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.functions.Namespace;
import com.pulumi.scaleway.functions.NamespaceArgs;
import com.pulumi.scaleway.functions.Function;
import com.pulumi.scaleway.functions.FunctionArgs;
import com.pulumi.scaleway.functions.Cron;
import com.pulumi.scaleway.functions.CronArgs;
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 main = new Namespace("main", NamespaceArgs.builder()
            .name("test-cron")
            .build());

        var mainFunction = new Function("mainFunction", FunctionArgs.builder()
            .name("test-cron")
            .namespaceId(main.id())
            .runtime("node14")
            .privacy("private")
            .handler("handler.handle")
            .build());

        var mainCron = new Cron("mainCron", CronArgs.builder()
            .name("test-cron")
            .functionId(mainFunction.id())
            .schedule("0 0 * * *")
            .args(serializeJson(
                jsonObject(
                    jsonProperty("test", "scw")
                )))
            .build());

        var func = new Cron("func", CronArgs.builder()
            .functionId(mainFunction.id())
            .schedule("0 1 * * *")
            .args(serializeJson(
                jsonObject(
                    jsonProperty("my_var", "terraform")
                )))
            .build());

    }
}
Copy
resources:
  main:
    type: scaleway:functions:Namespace
    properties:
      name: test-cron
  mainFunction:
    type: scaleway:functions:Function
    name: main
    properties:
      name: test-cron
      namespaceId: ${main.id}
      runtime: node14
      privacy: private
      handler: handler.handle
  mainCron:
    type: scaleway:functions:Cron
    name: main
    properties:
      name: test-cron
      functionId: ${mainFunction.id}
      schedule: 0 0 * * *
      args:
        fn::toJSON:
          test: scw
  func:
    type: scaleway:functions:Cron
    properties:
      functionId: ${mainFunction.id}
      schedule: 0 1 * * *
      args:
        fn::toJSON:
          my_var: terraform
Copy

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,
                 name: Optional[str] = None,
                 region: Optional[str] = None,
                 schedule: 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 This property is required. string
The unique name of the resource.
args This property is required. FunctionCronArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. FunctionCronArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. FunctionCronArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. FunctionCronArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

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

The FunctionCron resource accepts the following input properties:

Args This property is required. string
The key-value mapping to define arguments that will be passed to your function’s event object
FunctionId This property is required. string
The unique identifier of the function to link to your CRON trigger.
Schedule This property is required. string
CRON format string (refer to the CRON schedule reference for more information).
Name string
The name of the function CRON trigger. If not provided, a random name is generated.
Region Changes to this property will trigger replacement. string
region) The region in which the function was created.
Args This property is required. string
The key-value mapping to define arguments that will be passed to your function’s event object
FunctionId This property is required. string
The unique identifier of the function to link to your CRON trigger.
Schedule This property is required. string
CRON format string (refer to the CRON schedule reference for more information).
Name string
The name of the function CRON trigger. If not provided, a random name is generated.
Region Changes to this property will trigger replacement. string
region) The region in which the function was created.
args This property is required. String
The key-value mapping to define arguments that will be passed to your function’s event object
functionId This property is required. String
The unique identifier of the function to link to your CRON trigger.
schedule This property is required. String
CRON format string (refer to the CRON schedule reference for more information).
name String
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. String
region) The region in which the function was created.
args This property is required. string
The key-value mapping to define arguments that will be passed to your function’s event object
functionId This property is required. string
The unique identifier of the function to link to your CRON trigger.
schedule This property is required. string
CRON format string (refer to the CRON schedule reference for more information).
name string
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. string
region) The region in which the function was created.
args This property is required. str
The key-value mapping to define arguments that will be passed to your function’s event object
function_id This property is required. str
The unique identifier of the function to link to your CRON trigger.
schedule This property is required. str
CRON format string (refer to the CRON schedule reference for more information).
name str
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. str
region) The region in which the function was created.
args This property is required. String
The key-value mapping to define arguments that will be passed to your function’s event object
functionId This property is required. String
The unique identifier of the function to link to your CRON trigger.
schedule This property is required. String
CRON format string (refer to the CRON schedule reference for more information).
name String
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. String
region) The region in which the function 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)
resources:  _:    type: scaleway:FunctionCron    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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
FunctionId string
The unique identifier of the function to link to your CRON trigger.
Name string
The name of the function CRON trigger. If not provided, a random name is generated.
Region Changes to this property will trigger replacement. string
region) The region in which the function was created.
Schedule string
CRON format string (refer to the CRON schedule reference for more information).
Status string
The CRON status.
Args string
The key-value mapping to define arguments that will be passed to your function’s event object
FunctionId string
The unique identifier of the function to link to your CRON trigger.
Name string
The name of the function CRON trigger. If not provided, a random name is generated.
Region Changes to this property will trigger replacement. string
region) The region in which the function was created.
Schedule string
CRON format string (refer to the CRON schedule reference for more information).
Status string
The CRON status.
args String
The key-value mapping to define arguments that will be passed to your function’s event object
functionId String
The unique identifier of the function to link to your CRON trigger.
name String
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. String
region) The region in which the function was created.
schedule String
CRON format string (refer to the CRON schedule reference for more information).
status String
The CRON status.
args string
The key-value mapping to define arguments that will be passed to your function’s event object
functionId string
The unique identifier of the function to link to your CRON trigger.
name string
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. string
region) The region in which the function was created.
schedule string
CRON format string (refer to the CRON schedule reference for more information).
status string
The CRON status.
args str
The key-value mapping to define arguments that will be passed to your function’s event object
function_id str
The unique identifier of the function to link to your CRON trigger.
name str
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. str
region) The region in which the function was created.
schedule str
CRON format string (refer to the CRON schedule reference for more information).
status str
The CRON status.
args String
The key-value mapping to define arguments that will be passed to your function’s event object
functionId String
The unique identifier of the function to link to your CRON trigger.
name String
The name of the function CRON trigger. If not provided, a random name is generated.
region Changes to this property will trigger replacement. String
region) The region in which the function was created.
schedule String
CRON format string (refer to the CRON schedule reference for more information).
status String
The CRON status.

Import

Function Cron can be imported using {region}/{id}, as shown below:

bash

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

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.