V2FunctionArgs

data class V2FunctionArgs(val caPort: Output<Int>? = null, val code: Output<V2FunctionCodeArgs>? = null, val codeChecksum: Output<String>? = null, val cpu: Output<Double>? = null, val customContainerConfig: Output<V2FunctionCustomContainerConfigArgs>? = null, val customDns: Output<V2FunctionCustomDnsArgs>? = null, val customHealthCheckConfig: Output<V2FunctionCustomHealthCheckConfigArgs>? = null, val customRuntimeConfig: Output<V2FunctionCustomRuntimeConfigArgs>? = null, val description: Output<String>? = null, val diskSize: Output<Int>? = null, val environmentVariables: Output<Map<String, Any>>? = null, val functionName: Output<String>? = null, val gpuMemorySize: Output<Int>? = null, val handler: Output<String>? = null, val initializationTimeout: Output<Int>? = null, val initializer: Output<String>? = null, val instanceConcurrency: Output<Int>? = null, val instanceLifecycleConfig: Output<V2FunctionInstanceLifecycleConfigArgs>? = null, val instanceType: Output<String>? = null, val layers: Output<List<String>>? = null, val memorySize: Output<Int>? = null, val runtime: Output<String>? = null, val serviceName: Output<String>? = null, val timeout: Output<Int>? = null) : ConvertibleToJava<V2FunctionArgs>

Provides a FCV2 Function resource. Function is the unit of system scheduling and operation. Functions must be subordinate to services. All functions under the same service share some identical settings, such as service authorization and log configuration. For information about FCV2 Function and how to use it, see What is Function.

NOTE: Available since v1.208.0.

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.log.Project;
import com.pulumi.alicloud.log.ProjectArgs;
import com.pulumi.alicloud.log.Store;
import com.pulumi.alicloud.log.StoreArgs;
import com.pulumi.alicloud.ram.Role;
import com.pulumi.alicloud.ram.RoleArgs;
import com.pulumi.alicloud.ram.RolePolicyAttachment;
import com.pulumi.alicloud.ram.RolePolicyAttachmentArgs;
import com.pulumi.alicloud.fc.Service;
import com.pulumi.alicloud.fc.ServiceArgs;
import com.pulumi.alicloud.fc.inputs.ServiceLogConfigArgs;
import com.pulumi.alicloud.fc.V2Function;
import com.pulumi.alicloud.fc.V2FunctionArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionInstanceLifecycleConfigArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionInstanceLifecycleConfigPreFreezeArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionInstanceLifecycleConfigPreStopArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionCodeArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionCustomDnsArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionCustomHealthCheckConfigArgs;
import com.pulumi.alicloud.fc.inputs.V2FunctionCustomRuntimeConfigArgs;
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 defaultProject = new Project("defaultProject", ProjectArgs.builder()
.description(name)
.build());
var defaultStore = new Store("defaultStore", StoreArgs.builder()
.project(defaultProject.name())
.retentionPeriod("3000")
.shardCount(1)
.build());
var defaultRole = new Role("defaultRole", RoleArgs.builder()
.document("""
{
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": [
"fc.aliyuncs.com"
]
}
}
],
"Version": "1"
}
""")
.description(name)
.force(true)
.build());
var defaultRolePolicyAttachment = new RolePolicyAttachment("defaultRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
.roleName(defaultRole.name())
.policyName("AliyunLogFullAccess")
.policyType("System")
.build());
var defaultService = new Service("defaultService", ServiceArgs.builder()
.description(name)
.logConfig(ServiceLogConfigArgs.builder()
.project(defaultProject.name())
.logstore(defaultStore.name())
.build())
.role(defaultRole.arn())
.build());
var defaultV2Function = new V2Function("defaultV2Function", V2FunctionArgs.builder()
.functionName(name)
.memorySize(1024)
.runtime("custom.debian10")
.description(name)
.serviceName(defaultService.name())
.initializer("index.initializer")
.initializationTimeout(10)
.timeout(60)
.handler("index.handler")
.instanceType("e1")
.instanceLifecycleConfig(V2FunctionInstanceLifecycleConfigArgs.builder()
.preFreeze(V2FunctionInstanceLifecycleConfigPreFreezeArgs.builder()
.handler("index.prefreeze")
.timeout(30)
.build())
.preStop(V2FunctionInstanceLifecycleConfigPreStopArgs.builder()
.handler("index.prestop")
.timeout(30)
.build())
.build())
.code(V2FunctionCodeArgs.builder()
.ossBucketName("code-sample-cn-hangzhou")
.ossObjectName("quick-start-sample-codes/quick-start-sample-codes-nodejs/RocketMQ-producer-nodejs14-event/code.zip")
.build())
.customDns(V2FunctionCustomDnsArgs.builder()
.nameServers("223.5.5.5")
.searches("mydomain.com")
.dnsOptions(V2FunctionCustomDnsDnsOptionArgs.builder()
.name(name)
.value("1")
.build())
.build())
.diskSize(512)
.instanceConcurrency(10)
.layers(
"d3fc5de8d120687be2bfab761518d5de#Nodejs-Aliyun-SDK#2",
"d3fc5de8d120687be2bfab761518d5de#Python39#2")
.cpu(1)
.customHealthCheckConfig(V2FunctionCustomHealthCheckConfigArgs.builder()
.httpGetUrl("/healthcheck")
.initialDelaySeconds(3)
.periodSeconds(3)
.timeoutSeconds(3)
.failureThreshold(1)
.successThreshold(1)
.build())
.caPort(9000)
.customRuntimeConfig(V2FunctionCustomRuntimeConfigArgs.builder()
.commands("npm")
.args(
"run",
"start")
.build())
.build());
}
}

Import

FCV2 Function can be imported using the id, e.g.

$ pulumi import alicloud:fc/v2Function:V2Function example <service_name>:<function_name>

Constructors

Link copied to clipboard
fun V2FunctionArgs(caPort: Output<Int>? = null, code: Output<V2FunctionCodeArgs>? = null, codeChecksum: Output<String>? = null, cpu: Output<Double>? = null, customContainerConfig: Output<V2FunctionCustomContainerConfigArgs>? = null, customDns: Output<V2FunctionCustomDnsArgs>? = null, customHealthCheckConfig: Output<V2FunctionCustomHealthCheckConfigArgs>? = null, customRuntimeConfig: Output<V2FunctionCustomRuntimeConfigArgs>? = null, description: Output<String>? = null, diskSize: Output<Int>? = null, environmentVariables: Output<Map<String, Any>>? = null, functionName: Output<String>? = null, gpuMemorySize: Output<Int>? = null, handler: Output<String>? = null, initializationTimeout: Output<Int>? = null, initializer: Output<String>? = null, instanceConcurrency: Output<Int>? = null, instanceLifecycleConfig: Output<V2FunctionInstanceLifecycleConfigArgs>? = null, instanceType: Output<String>? = null, layers: Output<List<String>>? = null, memorySize: Output<Int>? = null, runtime: Output<String>? = null, serviceName: Output<String>? = null, timeout: Output<Int>? = null)

Functions

Link copied to clipboard
open override fun toJava(): V2FunctionArgs

Properties

Link copied to clipboard
val caPort: Output<Int>? = null

The listening port of the HTTP Server when the Custom Runtime or Custom Container is running.

Link copied to clipboard
val code: Output<V2FunctionCodeArgs>? = null

Function Code ZIP package. code and customContainerConfig choose one. See code below.

Link copied to clipboard
val codeChecksum: Output<String>? = null

crc64 of function code.

Link copied to clipboard
val cpu: Output<Double>? = null

The CPU specification of the function. The unit is vCPU, which is a multiple of the 0.05 vCPU.

Link copied to clipboard

Custom-container runtime related function configuration. See custom_container_config below.

Link copied to clipboard
val customDns: Output<V2FunctionCustomDnsArgs>? = null

Function custom DNS configuration. See custom_dns below.

Link copied to clipboard

Custom runtime/container Custom health check configuration. See custom_health_check_config below.

Link copied to clipboard

Detailed configuration of Custom Runtime function. See custom_runtime_config below.

Link copied to clipboard
val description: Output<String>? = null

description of function.

Link copied to clipboard
val diskSize: Output<Int>? = null

The disk specification of the function. The unit is MB. The optional value is 512 MB or 10240MB.

Link copied to clipboard
val environmentVariables: Output<Map<String, Any>>? = null

The environment variable set for the function can get the value of the environment variable in the function. For more information, see Environment Variables.

Link copied to clipboard
val functionName: Output<String>? = null

function name.

Link copied to clipboard
val gpuMemorySize: Output<Int>? = null

The GPU memory specification of the function, in MB, is a multiple of 1024MB.

Link copied to clipboard
val handler: Output<String>? = null

entry point of function.

Link copied to clipboard
val initializationTimeout: Output<Int>? = null

max running time of initializer.

Link copied to clipboard
val initializer: Output<String>? = null

initializer entry point of function.

Link copied to clipboard
val instanceConcurrency: Output<Int>? = null

The maximum concurrency allowed for a single function instance.

Link copied to clipboard

Instance lifecycle configuration. See instance_lifecycle_config below.

Link copied to clipboard
val instanceType: Output<String>? = null

The instance type of the function. Valid values:

Link copied to clipboard
val layers: Output<List<String>>? = null

List of layers.

Link copied to clipboard
val memorySize: Output<Int>? = null

memory size needed by function.

Link copied to clipboard
val runtime: Output<String>? = null

runtime of function code.

Link copied to clipboard
val serviceName: Output<String>? = null

The name of the function Service.

Link copied to clipboard
val timeout: Output<Int>? = null

max running time of function.