V2Function

class V2Function : KotlinCustomResource

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>

Properties

Link copied to clipboard
val caPort: Output<Int>

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

Link copied to clipboard
val code: Output<V2FunctionCode>?

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

Link copied to clipboard
val codeChecksum: Output<String>

crc64 of function code.

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

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

Link copied to clipboard
val createTime: Output<String>

create time of function.

Link copied to clipboard

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

Link copied to clipboard

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>?

description of function.

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

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

Link copied to clipboard

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>

function name.

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

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

Link copied to clipboard
val handler: Output<String>

entry point of function.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

max running time of initializer.

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

initializer entry point of function.

Link copied to clipboard

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>

The instance type of the function. Valid values:

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

List of layers.

Link copied to clipboard
val memorySize: Output<Int>

memory size needed by function.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val runtime: Output<String>

runtime of function code.

Link copied to clipboard
val serviceName: Output<String>

The name of the function Service.

Link copied to clipboard
val timeout: Output<Int>

max running time of function.

Link copied to clipboard
val urn: Output<String>