V3Function Args
Provides a Function Compute Service V3 (FCV3) Function resource. The resource scheduling and running of Function Compute is based on functions. The FC function consists of function code and function configuration. For information about Function Compute Service V3 (FCV3) Function and how to use it, see What is Function.
NOTE: Available since v1.228.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new random.index.Uuid("default", {});
const defaultBucket = new alicloud.oss.Bucket("default", {bucket: `${name}-${_default.result}`});
const defaultBucketObject = new alicloud.oss.BucketObject("default", {
bucket: defaultBucket.bucket,
key: "FCV3Py39.zip",
content: "print('hello')",
});
const defaultV3Function = new alicloud.fc.V3Function("default", {
description: "Create",
memorySize: 512,
layers: ["acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3"],
timeout: 3,
runtime: "custom.debian10",
handler: "index.handler",
diskSize: 512,
customRuntimeConfig: {
commands: [
"python",
"-c",
"example",
],
args: [
"app.py",
"xx",
"x",
],
port: 9000,
healthCheckConfig: {
httpGetUrl: "/ready",
initialDelaySeconds: 1,
periodSeconds: 10,
successThreshold: 1,
timeoutSeconds: 1,
failureThreshold: 3,
},
},
logConfig: {
logBeginRule: "None",
},
code: {
ossBucketName: defaultBucket.bucket,
ossObjectName: defaultBucketObject.key,
checksum: "4270285996107335518",
},
instanceLifecycleConfig: {
initializer: {
timeout: 1,
handler: "index.init",
},
preStop: {
timeout: 1,
handler: "index.stop",
},
},
cpu: 0.5,
instanceConcurrency: 2,
functionName: `${name}-${_default.result}`,
environmentVariables: {
EnvKey: "EnvVal",
},
internetAccess: true,
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = random.index.Uuid("default")
default_bucket = alicloud.oss.Bucket("default", bucket=f"{name}-{default['result']}")
default_bucket_object = alicloud.oss.BucketObject("default",
bucket=default_bucket.bucket,
key="FCV3Py39.zip",
content="print('hello')")
default_v3_function = alicloud.fc.V3Function("default",
description="Create",
memory_size=512,
layers=["acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3"],
timeout=3,
runtime="custom.debian10",
handler="index.handler",
disk_size=512,
custom_runtime_config={
"commands": [
"python",
"-c",
"example",
],
"args": [
"app.py",
"xx",
"x",
],
"port": 9000,
"health_check_config": {
"http_get_url": "/ready",
"initial_delay_seconds": 1,
"period_seconds": 10,
"success_threshold": 1,
"timeout_seconds": 1,
"failure_threshold": 3,
},
},
log_config={
"log_begin_rule": "None",
},
code={
"oss_bucket_name": default_bucket.bucket,
"oss_object_name": default_bucket_object.key,
"checksum": "4270285996107335518",
},
instance_lifecycle_config={
"initializer": {
"timeout": 1,
"handler": "index.init",
},
"pre_stop": {
"timeout": 1,
"handler": "index.stop",
},
},
cpu=0.5,
instance_concurrency=2,
function_name=f"{name}-{default['result']}",
environment_variables={
"EnvKey": "EnvVal",
},
internet_access=True)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = new Random.Index.Uuid("default");
var defaultBucket = new AliCloud.Oss.Bucket("default", new()
{
BucketName = $"{name}-{@default.Result}",
});
var defaultBucketObject = new AliCloud.Oss.BucketObject("default", new()
{
Bucket = defaultBucket.BucketName,
Key = "FCV3Py39.zip",
Content = "print('hello')",
});
var defaultV3Function = new AliCloud.FC.V3Function("default", new()
{
Description = "Create",
MemorySize = 512,
Layers = new[]
{
"acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3",
},
Timeout = 3,
Runtime = "custom.debian10",
Handler = "index.handler",
DiskSize = 512,
CustomRuntimeConfig = new AliCloud.FC.Inputs.V3FunctionCustomRuntimeConfigArgs
{
Commands = new[]
{
"python",
"-c",
"example",
},
Args = new[]
{
"app.py",
"xx",
"x",
},
Port = 9000,
HealthCheckConfig = new AliCloud.FC.Inputs.V3FunctionCustomRuntimeConfigHealthCheckConfigArgs
{
HttpGetUrl = "/ready",
InitialDelaySeconds = 1,
PeriodSeconds = 10,
SuccessThreshold = 1,
TimeoutSeconds = 1,
FailureThreshold = 3,
},
},
LogConfig = new AliCloud.FC.Inputs.V3FunctionLogConfigArgs
{
LogBeginRule = "None",
},
Code = new AliCloud.FC.Inputs.V3FunctionCodeArgs
{
OssBucketName = defaultBucket.BucketName,
OssObjectName = defaultBucketObject.Key,
Checksum = "4270285996107335518",
},
InstanceLifecycleConfig = new AliCloud.FC.Inputs.V3FunctionInstanceLifecycleConfigArgs
{
Initializer = new AliCloud.FC.Inputs.V3FunctionInstanceLifecycleConfigInitializerArgs
{
Timeout = 1,
Handler = "index.init",
},
PreStop = new AliCloud.FC.Inputs.V3FunctionInstanceLifecycleConfigPreStopArgs
{
Timeout = 1,
Handler = "index.stop",
},
},
Cpu = 0.5,
InstanceConcurrency = 2,
FunctionName = $"{name}-{@default.Result}",
EnvironmentVariables =
{
{ "EnvKey", "EnvVal" },
},
InternetAccess = true,
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/fc"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/oss"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := random.NewUuid(ctx, "default", nil)
if err != nil {
return err
}
defaultBucket, err := oss.NewBucket(ctx, "default", &oss.BucketArgs{
Bucket: pulumi.Sprintf("%v-%v", name, _default.Result),
})
if err != nil {
return err
}
defaultBucketObject, err := oss.NewBucketObject(ctx, "default", &oss.BucketObjectArgs{
Bucket: defaultBucket.Bucket,
Key: pulumi.String("FCV3Py39.zip"),
Content: pulumi.String("print('hello')"),
})
if err != nil {
return err
}
_, err = fc.NewV3Function(ctx, "default", &fc.V3FunctionArgs{
Description: pulumi.String("Create"),
MemorySize: pulumi.Int(512),
Layers: pulumi.StringArray{
pulumi.String("acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3"),
},
Timeout: pulumi.Int(3),
Runtime: pulumi.String("custom.debian10"),
Handler: pulumi.String("index.handler"),
DiskSize: pulumi.Int(512),
CustomRuntimeConfig: &fc.V3FunctionCustomRuntimeConfigArgs{
Commands: pulumi.StringArray{
pulumi.String("python"),
pulumi.String("-c"),
pulumi.String("example"),
},
Args: pulumi.StringArray{
pulumi.String("app.py"),
pulumi.String("xx"),
pulumi.String("x"),
},
Port: pulumi.Int(9000),
HealthCheckConfig: &fc.V3FunctionCustomRuntimeConfigHealthCheckConfigArgs{
HttpGetUrl: pulumi.String("/ready"),
InitialDelaySeconds: pulumi.Int(1),
PeriodSeconds: pulumi.Int(10),
SuccessThreshold: pulumi.Int(1),
TimeoutSeconds: pulumi.Int(1),
FailureThreshold: pulumi.Int(3),
},
},
LogConfig: &fc.V3FunctionLogConfigArgs{
LogBeginRule: pulumi.String("None"),
},
Code: &fc.V3FunctionCodeArgs{
OssBucketName: defaultBucket.Bucket,
OssObjectName: defaultBucketObject.Key,
Checksum: pulumi.String("4270285996107335518"),
},
InstanceLifecycleConfig: &fc.V3FunctionInstanceLifecycleConfigArgs{
Initializer: &fc.V3FunctionInstanceLifecycleConfigInitializerArgs{
Timeout: pulumi.Int(1),
Handler: pulumi.String("index.init"),
},
PreStop: &fc.V3FunctionInstanceLifecycleConfigPreStopArgs{
Timeout: pulumi.Int(1),
Handler: pulumi.String("index.stop"),
},
},
Cpu: pulumi.Float64(0.5),
InstanceConcurrency: pulumi.Int(2),
FunctionName: pulumi.Sprintf("%v-%v", name, _default.Result),
EnvironmentVariables: pulumi.StringMap{
"EnvKey": pulumi.String("EnvVal"),
},
InternetAccess: pulumi.Bool(true),
})
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.random.uuid;
import com.pulumi.alicloud.oss.Bucket;
import com.pulumi.alicloud.oss.BucketArgs;
import com.pulumi.alicloud.oss.BucketObject;
import com.pulumi.alicloud.oss.BucketObjectArgs;
import com.pulumi.alicloud.fc.V3Function;
import com.pulumi.alicloud.fc.V3FunctionArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionCustomRuntimeConfigArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionCustomRuntimeConfigHealthCheckConfigArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionLogConfigArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionCodeArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionInstanceLifecycleConfigArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionInstanceLifecycleConfigInitializerArgs;
import com.pulumi.alicloud.fc.inputs.V3FunctionInstanceLifecycleConfigPreStopArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var default_ = new Uuid("default");
var defaultBucket = new Bucket("defaultBucket", BucketArgs.builder()
.bucket(String.format("%s-%s", name,default_.result()))
.build());
var defaultBucketObject = new BucketObject("defaultBucketObject", BucketObjectArgs.builder()
.bucket(defaultBucket.bucket())
.key("FCV3Py39.zip")
.content("print('hello')")
.build());
var defaultV3Function = new V3Function("defaultV3Function", V3FunctionArgs.builder()
.description("Create")
.memorySize(512)
.layers("acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3")
.timeout(3)
.runtime("custom.debian10")
.handler("index.handler")
.diskSize(512)
.customRuntimeConfig(V3FunctionCustomRuntimeConfigArgs.builder()
.commands(
"python",
"-c",
"example")
.args(
"app.py",
"xx",
"x")
.port(9000)
.healthCheckConfig(V3FunctionCustomRuntimeConfigHealthCheckConfigArgs.builder()
.httpGetUrl("/ready")
.initialDelaySeconds(1)
.periodSeconds(10)
.successThreshold(1)
.timeoutSeconds(1)
.failureThreshold(3)
.build())
.build())
.logConfig(V3FunctionLogConfigArgs.builder()
.logBeginRule("None")
.build())
.code(V3FunctionCodeArgs.builder()
.ossBucketName(defaultBucket.bucket())
.ossObjectName(defaultBucketObject.key())
.checksum("4270285996107335518")
.build())
.instanceLifecycleConfig(V3FunctionInstanceLifecycleConfigArgs.builder()
.initializer(V3FunctionInstanceLifecycleConfigInitializerArgs.builder()
.timeout(1)
.handler("index.init")
.build())
.preStop(V3FunctionInstanceLifecycleConfigPreStopArgs.builder()
.timeout(1)
.handler("index.stop")
.build())
.build())
.cpu(0.5)
.instanceConcurrency(2)
.functionName(String.format("%s-%s", name,default_.result()))
.environmentVariables(Map.of("EnvKey", "EnvVal"))
.internetAccess(true)
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: random:uuid
defaultBucket:
type: alicloud:oss:Bucket
name: default
properties:
bucket: ${name}-${default.result}
defaultBucketObject:
type: alicloud:oss:BucketObject
name: default
properties:
bucket: ${defaultBucket.bucket}
key: FCV3Py39.zip
content: print('hello')
defaultV3Function:
type: alicloud:fc:V3Function
name: default
properties:
description: Create
memorySize: '512'
layers:
- acs:fc:cn-shanghai:official:layers/Python39-Aliyun-SDK/versions/3
timeout: '3'
runtime: custom.debian10
handler: index.handler
diskSize: '512'
customRuntimeConfig:
commands:
- python
- -c
- example
args:
- app.py
- xx
- x
port: '9000'
healthCheckConfig:
httpGetUrl: /ready
initialDelaySeconds: '1'
periodSeconds: '10'
successThreshold: '1'
timeoutSeconds: '1'
failureThreshold: '3'
logConfig:
logBeginRule: None
code:
ossBucketName: ${defaultBucket.bucket}
ossObjectName: ${defaultBucketObject.key}
checksum: '4270285996107335518'
instanceLifecycleConfig:
initializer:
timeout: '1'
handler: index.init
preStop:
timeout: '1'
handler: index.stop
cpu: '0.5'
instanceConcurrency: '2'
functionName: ${name}-${default.result}
environmentVariables:
EnvKey: EnvVal
internetAccess: 'true'
Import
Function Compute Service V3 (FCV3) Function can be imported using the id, e.g.
$ pulumi import alicloud:fc/v3Function:V3Function example <id>
Constructors
Properties
Function code ZIP package. code and customContainerConfig. See code
below.
The configuration of the custom container runtime. After the configuration is successful, the function can use the custom container image to execute the function. code and customContainerConfig. See custom_container_config
below.
Function custom DNS configuration See custom_dns
below.
Customize the runtime configuration. See custom_runtime_config
below.
The description of the function. The function compute system does not use this attribute value, but we recommend that you set a concise and clear description for the function.
The environment variable set for the function, you can get the value of the environment variable in the function.
The function name. Consists of uppercase and lowercase letters, digits (0 to 9), underscores (), and dashes (-). It must begin with an English letter (a ~ z), (A ~ Z), or an underscore (). Case sensitive. The length is 1~128 characters.
Function GPU configuration. See gpu_config
below.
Maximum instance concurrency.
Instance lifecycle callback method configuration. See instance_lifecycle_config
below.
Allow function to access public network
The logs generated by the function are written to the configured Logstore. See log_config
below.
The memory specification of the function. The unit is MB. The memory size is a multiple of 64MB. The minimum value is 128MB and the maximum value is 32GB. At the same time, the ratio of cpu to memorySize (calculated by GB) should be between 1:1 and 1:4.
NAS configuration. After this parameter is configured, the function can access the specified NAS resource. See nas_config
below.
OSS mount configuration See oss_mount_config
below.
The user is authorized to the RAM role of function compute. After the configuration, function compute will assume this role to generate temporary access credentials. In the function, you can use the temporary access credentials of the role to access the specified Alibaba cloud service, such as OSS and OTS
VPC configuration. After this parameter is configured, the function can access the specified VPC resources. See vpc_config
below.