Skip to content

Function

This class encapsulates and extends the ROS resource type ALIYUN::FC::Function, which is used to create a function.

Functions must be associated with services. All functions of a service share the same attributes as the service, such as service authorization and log configurations.

Initializers

import com.aliyun.ros.cdk.fc.Function;
Function.Builder.create(Construct scope, java.lang.String id, java.lang.Boolean enableResourcePropertyConstraint)
    .functionName(java.lang.String)
    .functionName(IResolvable)
    .handler(java.lang.String)
    .handler(IResolvable)
    .runtime(java.lang.String)
    .runtime(IResolvable)
    .serviceName(java.lang.String)
    .serviceName(IResolvable)
//  .asyncConfiguration(IResolvable)
//  .asyncConfiguration(AsyncConfigurationProperty)
//  .caPort(java.lang.Number)
//  .caPort(IResolvable)
//  .code(IResolvable)
//  .code(CodeProperty)
//  .cpu(java.lang.Number)
//  .cpu(IResolvable)
//  .customContainerConfig(IResolvable)
//  .customContainerConfig(CustomContainerConfigProperty)
//  .customDns(IResolvable)
//  .customDns(CustomDNSProperty)
//  .customHealthCheckConfig(IResolvable)
//  .customHealthCheckConfig(CustomHealthCheckConfigProperty)
//  .customRuntimeConfig(IResolvable)
//  .customRuntimeConfig(CustomRuntimeConfigProperty)
//  .description(java.lang.String)
//  .description(IResolvable)
//  .diskSize(java.lang.Number)
//  .diskSize(IResolvable)
//  .environmentVariables(IResolvable)
//  .environmentVariables(java.util.Map<java.lang.String, java.lang.Object>)
//  .gpuMemorySize(java.lang.Number)
//  .gpuMemorySize(IResolvable)
//  .initializationTimeout(java.lang.Number)
//  .initializationTimeout(IResolvable)
//  .initializer(java.lang.String)
//  .initializer(IResolvable)
//  .instanceConcurrency(java.lang.Number)
//  .instanceConcurrency(IResolvable)
//  .instanceLifecycleConfig(IResolvable)
//  .instanceLifecycleConfig(InstanceLifecycleConfigProperty)
//  .instanceSoftConcurrency(java.lang.Number)
//  .instanceSoftConcurrency(IResolvable)
//  .instanceType(java.lang.String)
//  .instanceType(IResolvable)
//  .memorySize(java.lang.Number)
//  .memorySize(IResolvable)
//  .timeout(java.lang.Number)
//  .timeout(IResolvable)
    .build();
Name Type Description
scope com.aliyun.ros.cdk.core.Construct No description.
id java.lang.String No description.
enableResourcePropertyConstraint java.lang.Boolean No description.
functionName java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property functionName: Function name.
handler java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property handler: The function execution entry point.
runtime java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property runtime: The function runtime environment.
serviceName java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property serviceName: Service name.
asyncConfiguration com.aliyun.ros.cdk.core.IResolvable OR AsyncConfigurationProperty Property asyncConfiguration: Configuration of asynchronous function calls.
caPort java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property caPort: Custom runtime and custom container runtime dedicated fields, which represent the port that the started custom http server listens to.
code com.aliyun.ros.cdk.core.IResolvable OR CodeProperty Property code: The code that contains the function implementation.
cpu java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property cpu: The number of vCPUs of the function.
customContainerConfig com.aliyun.ros.cdk.core.IResolvable OR CustomContainerConfigProperty Property customContainerConfig: Custom container runtime related configuration.
customDns com.aliyun.ros.cdk.core.IResolvable OR CustomDNSProperty Property customDns: The custom DNS configurations of the function.
customHealthCheckConfig com.aliyun.ros.cdk.core.IResolvable OR CustomHealthCheckConfigProperty Property customHealthCheckConfig: The health check configurations for the custom runtime and custom container.
customRuntimeConfig com.aliyun.ros.cdk.core.IResolvable OR CustomRuntimeConfigProperty Property customRuntimeConfig: Custom runtime related configuration.
description java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property description: Function description.
diskSize java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property diskSize: The disk size of the function.
environmentVariables com.aliyun.ros.cdk.core.IResolvable OR java.util.Map Property environmentVariables: The environment variable set for the function, you can get the value of the environment variable in the function.
gpuMemorySize java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property gpuMemorySize: The GPU memory capacity for the function.
initializationTimeout java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property initializationTimeout: the max execution time of the initializer, in second.
initializer java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property initializer: the entry point of the initializer.
instanceConcurrency java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property instanceConcurrency: Function instance concurrency.
instanceLifecycleConfig com.aliyun.ros.cdk.core.IResolvable OR InstanceLifecycleConfigProperty Property instanceLifecycleConfig: The configuration of the instance lifecycle function.
instanceSoftConcurrency java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property instanceSoftConcurrency: The soft concurrency of the instance.
instanceType java.lang.String OR com.aliyun.ros.cdk.core.IResolvable Property instanceType: Instance type.
memorySize java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property memorySize: The amount of memory that’s used to run function, in MB.
timeout java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable Property timeout: The maximum time duration a function can run, in seconds.

scopeRequired

  • Type: com.aliyun.ros.cdk.core.Construct

idRequired

  • Type: java.lang.String

enableResourcePropertyConstraintOptional

  • Type: java.lang.Boolean

functionNameRequired

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property functionName: Function name.


handlerRequired

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property handler: The function execution entry point.


runtimeRequired

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property runtime: The function runtime environment.

Supporting nodejs16、nodejs14、nodejs12、nodejs10、nodejs8、nodejs6、nodejs4.4、python3.10、python3.9、python3、python2.7、java11、java8、go1、php7.2、dotnetcore3.1、dotnetcore2.1、custom.debian10、custom和custom-container and so on


serviceNameRequired

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property serviceName: Service name.


asyncConfigurationOptional

Property asyncConfiguration: Configuration of asynchronous function calls.


caPortOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property caPort: Custom runtime and custom container runtime dedicated fields, which represent the port that the started custom http server listens to.

The default value is 9000


codeOptional

Property code: The code that contains the function implementation.


cpuOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property cpu: The number of vCPUs of the function.

The value must be a multiple of 0.05.


customContainerConfigOptional

Property customContainerConfig: Custom container runtime related configuration.

After configuration, the function can be replaced with a custom container to execute the function


customDnsOptional

Property customDns: The custom DNS configurations of the function.


customHealthCheckConfigOptional

Property customHealthCheckConfig: The health check configurations for the custom runtime and custom container.


customRuntimeConfigOptional

Property customRuntimeConfig: Custom runtime related configuration.


descriptionOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property description: Function description.


diskSizeOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property diskSize: The disk size of the function.

Unit: MB. Valid values: 512 and 10240.


environmentVariablesOptional

  • Type: com.aliyun.ros.cdk.core.IResolvable OR java.util.Map

Property environmentVariables: The environment variable set for the function, you can get the value of the environment variable in the function.


gpuMemorySizeOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property gpuMemorySize: The GPU memory capacity for the function.

Unit: MB. The value must be a multiple of 1,024.


initializationTimeoutOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property initializationTimeout: the max execution time of the initializer, in second.


initializerOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property initializer: the entry point of the initializer.


instanceConcurrencyOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property instanceConcurrency: Function instance concurrency.

Value can be between 1 to 100.


instanceLifecycleConfigOptional

Property instanceLifecycleConfig: The configuration of the instance lifecycle function.


instanceSoftConcurrencyOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property instanceSoftConcurrency: The soft concurrency of the instance.

You can use this parameter to implement graceful scale-up of instances. If the number of concurrent requests on an instance is greater than the value of soft concurrency, an instance scale-up is triggered. For example, if your instance requires a long time to start, you can specify a suitable soft concurrency to start the instance in advance.The value must be less than or equal to that of the instanceConcurrency parameter.


instanceTypeOptional

  • Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable

Property instanceType: Instance type.

Value:e1: flexible instance. Memory size between 128 and 3072c1: performance instance. Memory size allow values are 4096, 8192, 16384 and 32768


memorySizeOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property memorySize: The amount of memory that’s used to run function, in MB.

Function Compute uses this value to allocate CPU resources proportionally. Defaults to 128 MB. It can be multiple of 64 MB and between 128 MB and 3072 MB.


timeoutOptional

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

Property timeout: The maximum time duration a function can run, in seconds.

After which Function Compute terminates the execution. Defaults to 3 seconds, and can be between 1 to 86400 seconds.


Methods

Name Description
toString Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
addCondition No description.
addCount No description.
addDependency No description.
addResourceDesc No description.
applyRemovalPolicy No description.
getAtt No description.
setMetadata No description.
codeFromAsset Loads the fcFunction code from a local disk path.
codeFromBucket Function handler code as an OSS object.
codeFromInline Inline code for FC fcFunction handler.

toString

public java.lang.String toString()

Returns a string representation of this construct.

synthesize

public void synthesize(ISynthesisSession session)

Allows this construct to emit artifacts into the cloud assembly during synthesis.

This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.

sessionRequired

  • Type: com.aliyun.ros.cdk.core.ISynthesisSession

The synthesis session.


addCondition

public void addCondition(RosCondition condition)

conditionRequired

  • Type: com.aliyun.ros.cdk.core.RosCondition

addCount

public void addCount(java.lang.Number OR IResolvable count)

countRequired

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

addDependency

public void addDependency(Resource resource)

resourceRequired

  • Type: com.aliyun.ros.cdk.core.Resource

addResourceDesc

public void addResourceDesc(java.lang.String desc)

descRequired

  • Type: java.lang.String

applyRemovalPolicy

public void applyRemovalPolicy(RemovalPolicy policy)

policyRequired

  • Type: com.aliyun.ros.cdk.core.RemovalPolicy

getAtt

public IResolvable getAtt(java.lang.String name)

nameRequired

  • Type: java.lang.String

setMetadata

public void setMetadata(java.lang.String key, java.lang.Object value)

keyRequired

  • Type: java.lang.String

valueRequired

  • Type: java.lang.Object

codeFromAsset

public void codeFromAsset(java.lang.String path)

Loads the fcFunction code from a local disk path.

pathRequired

  • Type: java.lang.String

Either a directory with the Lambda code bundle or a .zip file.


codeFromBucket

public void codeFromBucket(Bucket bucket, java.lang.String key)

Function handler code as an OSS object.

bucketRequired

  • Type: com.aliyun.ros.cdk.oss.Bucket

The OSS bucket.


keyRequired

  • Type: java.lang.String

The object key.


codeFromInline

public void codeFromInline(java.lang.String code)

Inline code for FC fcFunction handler.

codeRequired

  • Type: java.lang.String

The actual handler code (limited to 4KiB).


Static Functions

Name Description
isConstruct Return whether the given object is a Construct.

isConstruct

import com.aliyun.ros.cdk.fc.Function;
Function.isConstruct(java.lang.Object x)

Return whether the given object is a Construct.

xRequired

  • Type: java.lang.Object

Properties

Name Type Description
node com.aliyun.ros.cdk.core.ConstructNode The construct tree node associated with this construct.
ref java.lang.String No description.
stack com.aliyun.ros.cdk.core.Stack The stack in which this resource is defined.
resource com.aliyun.ros.cdk.core.RosResource No description.
attrArn com.aliyun.ros.cdk.core.IResolvable Attribute ARN: The ARN for ALIYUN::ROS::CustomResource.
attrFunctionId com.aliyun.ros.cdk.core.IResolvable Attribute FunctionId: The function ID.
attrFunctionName com.aliyun.ros.cdk.core.IResolvable Attribute FunctionName: The function name.
attrServiceId com.aliyun.ros.cdk.core.IResolvable Attribute ServiceId: The service ID.
attrServiceName com.aliyun.ros.cdk.core.IResolvable Attribute ServiceName: The service name.

nodeRequired

public ConstructNode getNode();
  • Type: com.aliyun.ros.cdk.core.ConstructNode

The construct tree node associated with this construct.


refRequired

public java.lang.String getRef();
  • Type: java.lang.String

stackRequired

public Stack getStack();
  • Type: com.aliyun.ros.cdk.core.Stack

The stack in which this resource is defined.


resourceOptional

public RosResource getResource();
  • Type: com.aliyun.ros.cdk.core.RosResource

attrArnRequired

public IResolvable getAttrArn();
  • Type: com.aliyun.ros.cdk.core.IResolvable

Attribute ARN: The ARN for ALIYUN::ROS::CustomResource.


attrFunctionIdRequired

public IResolvable getAttrFunctionId();
  • Type: com.aliyun.ros.cdk.core.IResolvable

Attribute FunctionId: The function ID.


attrFunctionNameRequired

public IResolvable getAttrFunctionName();
  • Type: com.aliyun.ros.cdk.core.IResolvable

Attribute FunctionName: The function name.


attrServiceIdRequired

public IResolvable getAttrServiceId();
  • Type: com.aliyun.ros.cdk.core.IResolvable

Attribute ServiceId: The service ID.


attrServiceNameRequired

public IResolvable getAttrServiceName();
  • Type: com.aliyun.ros.cdk.core.IResolvable

Attribute ServiceName: The service name.