@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
440 lines • 18.7 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
/**
* The `scaleway.functions.Function` resource allows you to create and manage [Serverless Functions](https://www.scaleway.com/en/docs/serverless/functions/).
*
* Refer to the Serverless Functions [product documentation](https://www.scaleway.com/en/docs/serverless/functions/) and [API documentation](https://www.scaleway.com/en/developers/api/serverless-functions/) for more information.
*
* For more information on the limitations of Serverless Functions, refer to the [dedicated documentation](https://www.scaleway.com/en/docs/compute/functions/reference-content/functions-limitations/).
*
* ## Example Usage
*
* ### Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.functions.Namespace("main", {
* name: "main-function-namespace",
* description: "Main function namespace",
* });
* const mainFunction = new scaleway.functions.Function("main", {
* namespaceId: main.id,
* runtime: "go124",
* handler: "Handle",
* privacy: "private",
* });
* ```
*
* ### With sources and deploy
*
* You can easily create a zip file containing your function (ex: `zip function.zip -r go.mod go.sum handler.go`) to deploy it with Terraform seamlessly. Refer to our [dedicated documentation](https://www.scaleway.com/en/docs/serverless/functions/how-to/package-function-dependencies-in-zip/) for more information on how to package a function into a zip file.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
* import * as std from "@pulumi/std";
*
* const main = new scaleway.functions.Namespace("main", {
* name: "main-function-namespace",
* description: "Main function namespace",
* });
* const mainFunction = new scaleway.functions.Function("main", {
* namespaceId: main.id,
* description: "function with zip file",
* tags: [
* "tag1",
* "tag2",
* ],
* runtime: "go124",
* handler: "Handle",
* privacy: "private",
* timeout: 10,
* zipFile: "function.zip",
* zipHash: std.filesha256({
* input: "function.zip",
* }).result,
* deploy: true,
* });
* ```
*
* ### Managing authentication of private functions with IAM
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
* import * as std from "@pulumi/std";
*
* // Project to be referenced in the IAM policy
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // IAM resources
* const funcAuth = new scaleway.iam.Application("func_auth", {name: "function-auth"});
* const accessPrivateFuncs = new scaleway.iam.Policy("access_private_funcs", {
* applicationId: funcAuth.id,
* rules: [{
* projectIds: [_default.then(_default => _default.id)],
* permissionSetNames: ["FunctionsPrivateAccess"],
* }],
* });
* const apiKey = new scaleway.iam.ApiKey("api_key", {applicationId: funcAuth.id});
* // Function resources
* const _private = new scaleway.functions.Namespace("private", {name: "private-function-namespace"});
* const privateFunction = new scaleway.functions.Function("private", {
* namespaceId: _private.id,
* runtime: "go124",
* handler: "Handle",
* privacy: "private",
* zipFile: "function.zip",
* zipHash: std.filesha256({
* input: "function.zip",
* }).result,
* deploy: true,
* });
* export const secretKey = apiKey.secretKey;
* export const functionEndpoint = privateFunction.domainName;
* ```
*
* Then you can access your private function using the API key:
*
* Keep in mind that you should revoke your legacy JWT tokens to ensure maximum security.
*
* ## Import
*
* Functions can be imported using, `{region}/{id}`, as shown below:
*
* ```sh
* $ pulumi import scaleway:functions/function:Function main fr-par/11111111-1111-1111-1111-111111111111
* ```
*/
export declare class Function extends pulumi.CustomResource {
/**
* Get an existing Function resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: FunctionState, opts?: pulumi.CustomResourceOptions): Function;
/**
* Returns true if the given object is an instance of Function. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Function;
/**
* The CPU limit in mVCPU for your function.
*/
readonly cpuLimit: pulumi.Output<number>;
/**
* Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
*/
readonly deploy: pulumi.Output<boolean | undefined>;
/**
* The description of the function.
*/
readonly description: pulumi.Output<string | undefined>;
/**
* The native domain name of the function.
*/
readonly domainName: pulumi.Output<string>;
/**
* The [environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#environment-variables) of the function.
*/
readonly environmentVariables: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
*/
readonly handler: pulumi.Output<string>;
/**
* Allows both HTTP and HTTPS (`enabled`) or redirect HTTP to HTTPS (`redirected`). Defaults to `enabled`.
*/
readonly httpOption: pulumi.Output<string | undefined>;
/**
* The maximum number of instances this function can scale to. Default to 20. Your function will scale automatically based on the incoming workload, but will never exceed the configured `maxScale` value.
*/
readonly maxScale: pulumi.Output<number | undefined>;
/**
* The memory resources in MB to allocate to each function. Defaults to 256 MB.
*/
readonly memoryLimit: pulumi.Output<number | undefined>;
/**
* The minimum number of function instances running continuously. Defaults to 0. Functions are billed when executed, and using a `minScale` greater than 0 will cause your function to run constantly.
*/
readonly minScale: pulumi.Output<number | undefined>;
/**
* The unique name of the function name.
*/
readonly name: pulumi.Output<string>;
/**
* The Functions namespace ID of the function.
*
* > **Important** Updating the `name` argument will recreate the function.
*/
readonly namespaceId: pulumi.Output<string>;
/**
* The organization ID the function is associated with.
*/
readonly organizationId: pulumi.Output<string>;
/**
* The privacy type defines the way to authenticate to your function. Please check our dedicated [section](https://www.scaleway.com/en/developers/api/serverless-functions/#protocol-9dd4c8).
*/
readonly privacy: pulumi.Output<string>;
/**
* The ID of the Private Network the function is connected to.
*/
readonly privateNetworkId: pulumi.Output<string | undefined>;
/**
* `projectId`) The ID of the project the functions namespace is associated with.
*/
readonly projectId: pulumi.Output<string>;
/**
* `region`). The region in which the namespace should be created.
*/
readonly region: pulumi.Output<string | undefined>;
/**
* Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
*/
readonly runtime: pulumi.Output<string>;
/**
* Execution environment of the function.
*/
readonly sandbox: pulumi.Output<string>;
/**
* The [secret environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#secrets) of the function.
*/
readonly secretEnvironmentVariables: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* The list of tags associated with the function.
*/
readonly tags: pulumi.Output<string[] | undefined>;
/**
* The maximum amount of time your function can spend processing a request before being stopped. Defaults to 300s.
*/
readonly timeout: pulumi.Output<number>;
/**
* Path to the zip file containing your function sources to upload.
*/
readonly zipFile: pulumi.Output<string | undefined>;
/**
* The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
*/
readonly zipHash: pulumi.Output<string | undefined>;
/**
* Create a Function resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: FunctionArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Function resources.
*/
export interface FunctionState {
/**
* The CPU limit in mVCPU for your function.
*/
cpuLimit?: pulumi.Input<number | undefined>;
/**
* Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
*/
deploy?: pulumi.Input<boolean | undefined>;
/**
* The description of the function.
*/
description?: pulumi.Input<string | undefined>;
/**
* The native domain name of the function.
*/
domainName?: pulumi.Input<string | undefined>;
/**
* The [environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#environment-variables) of the function.
*/
environmentVariables?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
*/
handler?: pulumi.Input<string | undefined>;
/**
* Allows both HTTP and HTTPS (`enabled`) or redirect HTTP to HTTPS (`redirected`). Defaults to `enabled`.
*/
httpOption?: pulumi.Input<string | undefined>;
/**
* The maximum number of instances this function can scale to. Default to 20. Your function will scale automatically based on the incoming workload, but will never exceed the configured `maxScale` value.
*/
maxScale?: pulumi.Input<number | undefined>;
/**
* The memory resources in MB to allocate to each function. Defaults to 256 MB.
*/
memoryLimit?: pulumi.Input<number | undefined>;
/**
* The minimum number of function instances running continuously. Defaults to 0. Functions are billed when executed, and using a `minScale` greater than 0 will cause your function to run constantly.
*/
minScale?: pulumi.Input<number | undefined>;
/**
* The unique name of the function name.
*/
name?: pulumi.Input<string | undefined>;
/**
* The Functions namespace ID of the function.
*
* > **Important** Updating the `name` argument will recreate the function.
*/
namespaceId?: pulumi.Input<string | undefined>;
/**
* The organization ID the function is associated with.
*/
organizationId?: pulumi.Input<string | undefined>;
/**
* The privacy type defines the way to authenticate to your function. Please check our dedicated [section](https://www.scaleway.com/en/developers/api/serverless-functions/#protocol-9dd4c8).
*/
privacy?: pulumi.Input<string | undefined>;
/**
* The ID of the Private Network the function is connected to.
*/
privateNetworkId?: pulumi.Input<string | undefined>;
/**
* `projectId`) The ID of the project the functions namespace is associated with.
*/
projectId?: pulumi.Input<string | undefined>;
/**
* `region`). The region in which the namespace should be created.
*/
region?: pulumi.Input<string | undefined>;
/**
* Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
*/
runtime?: pulumi.Input<string | undefined>;
/**
* Execution environment of the function.
*/
sandbox?: pulumi.Input<string | undefined>;
/**
* The [secret environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#secrets) of the function.
*/
secretEnvironmentVariables?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* The list of tags associated with the function.
*/
tags?: pulumi.Input<pulumi.Input<string>[] | undefined>;
/**
* The maximum amount of time your function can spend processing a request before being stopped. Defaults to 300s.
*/
timeout?: pulumi.Input<number | undefined>;
/**
* Path to the zip file containing your function sources to upload.
*/
zipFile?: pulumi.Input<string | undefined>;
/**
* The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
*/
zipHash?: pulumi.Input<string | undefined>;
}
/**
* The set of arguments for constructing a Function resource.
*/
export interface FunctionArgs {
/**
* Define whether the function should be deployed. Terraform will wait for the function to be deployed. Your function will be redeployed if you update the source zip file.
*/
deploy?: pulumi.Input<boolean | undefined>;
/**
* The description of the function.
*/
description?: pulumi.Input<string | undefined>;
/**
* The [environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#environment-variables) of the function.
*/
environmentVariables?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* Handler of the function, depends on the runtime. Refer to the [dedicated documentation](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-create-a-new-function) for the list of supported runtimes.
*/
handler: pulumi.Input<string>;
/**
* Allows both HTTP and HTTPS (`enabled`) or redirect HTTP to HTTPS (`redirected`). Defaults to `enabled`.
*/
httpOption?: pulumi.Input<string | undefined>;
/**
* The maximum number of instances this function can scale to. Default to 20. Your function will scale automatically based on the incoming workload, but will never exceed the configured `maxScale` value.
*/
maxScale?: pulumi.Input<number | undefined>;
/**
* The memory resources in MB to allocate to each function. Defaults to 256 MB.
*/
memoryLimit?: pulumi.Input<number | undefined>;
/**
* The minimum number of function instances running continuously. Defaults to 0. Functions are billed when executed, and using a `minScale` greater than 0 will cause your function to run constantly.
*/
minScale?: pulumi.Input<number | undefined>;
/**
* The unique name of the function name.
*/
name?: pulumi.Input<string | undefined>;
/**
* The Functions namespace ID of the function.
*
* > **Important** Updating the `name` argument will recreate the function.
*/
namespaceId: pulumi.Input<string>;
/**
* The privacy type defines the way to authenticate to your function. Please check our dedicated [section](https://www.scaleway.com/en/developers/api/serverless-functions/#protocol-9dd4c8).
*/
privacy: pulumi.Input<string>;
/**
* The ID of the Private Network the function is connected to.
*/
privateNetworkId?: pulumi.Input<string | undefined>;
/**
* `projectId`) The ID of the project the functions namespace is associated with.
*/
projectId?: pulumi.Input<string | undefined>;
/**
* `region`). The region in which the namespace should be created.
*/
region?: pulumi.Input<string | undefined>;
/**
* Runtime of the function. Runtimes can be fetched using [specific route](https://www.scaleway.com/en/developers/api/serverless-functions/#path-functions-get-a-function)
*/
runtime: pulumi.Input<string>;
/**
* Execution environment of the function.
*/
sandbox?: pulumi.Input<string | undefined>;
/**
* The [secret environment variables](https://www.scaleway.com/en/docs/compute/functions/concepts/#secrets) of the function.
*/
secretEnvironmentVariables?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
} | undefined>;
/**
* The list of tags associated with the function.
*/
tags?: pulumi.Input<pulumi.Input<string>[] | undefined>;
/**
* The maximum amount of time your function can spend processing a request before being stopped. Defaults to 300s.
*/
timeout?: pulumi.Input<number | undefined>;
/**
* Path to the zip file containing your function sources to upload.
*/
zipFile?: pulumi.Input<string | undefined>;
/**
* The hash of your source zip file, changing it will redeploy the function. Can be any string, changing it will simply trigger a state change. You can use any Terraform hash function to trigger a change on your zip change (see examples).
*/
zipHash?: pulumi.Input<string | undefined>;
}
//# sourceMappingURL=function.d.ts.map