V2Function
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());
}
}
Content copied to clipboard
Import
FCV2 Function can be imported using the id, e.g.
$ pulumi import alicloud:fc/v2Function:V2Function example <service_name>:<function_name>
Content copied to clipboard
Properties
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard