Scaleway

v1.1.0 published on Saturday, Sep 17, 2022 by lbrlabs

FunctionCron

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

For more information consult the documentation .

If you want to restrict the access to your function please check this.

For more details about the limitation check functions-limitations.

You can check also our functions cron api documentation.

Example Usage

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Scaleway = Lbrlabs.PulumiPackage.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 main

import (
	"encoding/json"

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

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
	})
}
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());

    }
}
import pulumi
import json
import lbrlabs_pulumi_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",
    }))
import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@lbrlabs/pulumi-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",
    }),
});
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 a FunctionCron Resource

new FunctionCron(name: string, args: FunctionCronArgs, opts?: CustomResourceOptions);
@overload
def FunctionCron(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 args: Optional[str] = None,
                 function_id: Optional[str] = None,
                 region: Optional[str] = None,
                 schedule: Optional[str] = None)
@overload
def FunctionCron(resource_name: str,
                 args: FunctionCronArgs,
                 opts: Optional[ResourceOptions] = 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.

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.

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.

Region string

(Defaults to provider 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.

Region string

(Defaults to provider 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.

region String

(Defaults to provider 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.

region string

(Defaults to provider 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.

region str

(Defaults to provider 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.

region String

(Defaults to provider 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 an 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,
        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.

Region string

(Defaults to provider 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.

Region string

(Defaults to provider 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.

region String

(Defaults to provider 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.

region string

(Defaults to provider 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.

region str

(Defaults to provider 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.

region String

(Defaults to provider 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

Package Details

Repository
https://github.com/lbrlabs/pulumi-scaleway
License
Apache-2.0
Notes

This Pulumi package is based on the scaleway Terraform Provider.