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. |
scope
Required
- Type: com.aliyun.ros.cdk.core.Construct
id
Required
- Type: java.lang.String
enableResourcePropertyConstraint
Optional
- Type: java.lang.Boolean
functionName
Required
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property functionName: Function name.
handler
Required
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property handler: The function execution entry point.
runtime
Required
- 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
serviceName
Required
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property serviceName: Service name.
asyncConfiguration
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR AsyncConfigurationProperty
Property asyncConfiguration: Configuration of asynchronous function calls.
caPort
Optional
- 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
code
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR CodeProperty
Property code: The code that contains the function implementation.
cpu
Optional
- 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.
customContainerConfig
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR CustomContainerConfigProperty
Property customContainerConfig: Custom container runtime related configuration.
After configuration, the function can be replaced with a custom container to execute the function
customDns
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR CustomDNSProperty
Property customDns: The custom DNS configurations of the function.
customHealthCheckConfig
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR CustomHealthCheckConfigProperty
Property customHealthCheckConfig: The health check configurations for the custom runtime and custom container.
customRuntimeConfig
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR CustomRuntimeConfigProperty
Property customRuntimeConfig: Custom runtime related configuration.
description
Optional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property description: Function description.
diskSize
Optional
- 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.
environmentVariables
Optional
- 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.
gpuMemorySize
Optional
- 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.
initializationTimeout
Optional
- Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable
Property initializationTimeout: the max execution time of the initializer, in second.
initializer
Optional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property initializer: the entry point of the initializer.
instanceConcurrency
Optional
- Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable
Property instanceConcurrency: Function instance concurrency.
Value can be between 1 to 100.
instanceLifecycleConfig
Optional
- Type: com.aliyun.ros.cdk.core.IResolvable OR InstanceLifecycleConfigProperty
Property instanceLifecycleConfig: The configuration of the instance lifecycle function.
instanceSoftConcurrency
Optional
- 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.
instanceType
Optional
- 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
memorySize
Optional
- 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.
timeout
Optional
- 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.
- Type: com.aliyun.ros.cdk.core.ISynthesisSession
The synthesis session.
addCondition
public void addCondition(RosCondition condition)
- Type: com.aliyun.ros.cdk.core.RosCondition
addCount
public void addCount(java.lang.Number OR IResolvable count)
- Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable
addDependency
public void addDependency(Resource resource)
- Type: com.aliyun.ros.cdk.core.Resource
addResourceDesc
public void addResourceDesc(java.lang.String desc)
- Type: java.lang.String
applyRemovalPolicy
public void applyRemovalPolicy(RemovalPolicy policy)
- Type: com.aliyun.ros.cdk.core.RemovalPolicy
getAtt
public IResolvable getAtt(java.lang.String name)
- Type: java.lang.String
setMetadata
public void setMetadata(java.lang.String key, java.lang.Object value)
- Type: java.lang.String
- Type: java.lang.Object
codeFromAsset
public void codeFromAsset(java.lang.String path)
Loads the fcFunction code from a local disk path.
- 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.
- Type: com.aliyun.ros.cdk.oss.Bucket
The OSS bucket.
- Type: java.lang.String
The object key.
codeFromInline
public void codeFromInline(java.lang.String code)
Inline code for FC fcFunction handler.
- 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.
- 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. |
node
Required
public ConstructNode getNode();
- Type: com.aliyun.ros.cdk.core.ConstructNode
The construct tree node associated with this construct.
ref
Required
public java.lang.String getRef();
- Type: java.lang.String
stack
Required
public Stack getStack();
- Type: com.aliyun.ros.cdk.core.Stack
The stack in which this resource is defined.
resource
Optional
public RosResource getResource();
- Type: com.aliyun.ros.cdk.core.RosResource
attrArn
Required
public IResolvable getAttrArn();
- Type: com.aliyun.ros.cdk.core.IResolvable
Attribute ARN: The ARN for ALIYUN::ROS::CustomResource.
attrFunctionId
Required
public IResolvable getAttrFunctionId();
- Type: com.aliyun.ros.cdk.core.IResolvable
Attribute FunctionId: The function ID.
attrFunctionName
Required
public IResolvable getAttrFunctionName();
- Type: com.aliyun.ros.cdk.core.IResolvable
Attribute FunctionName: The function name.
attrServiceId
Required
public IResolvable getAttrServiceId();
- Type: com.aliyun.ros.cdk.core.IResolvable
Attribute ServiceId: The service ID.
attrServiceName
Required
public IResolvable getAttrServiceName();
- Type: com.aliyun.ros.cdk.core.IResolvable
Attribute ServiceName: The service name.