All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::FC3::Function

更新时间:Dec 26, 2025

ALIYUN::FC3::Function is used to create a Function Compute 3.0 function.

Syntax

{
  "Type": "ALIYUN::FC3::Function",
  "Properties": {
    "FunctionName": String,
    "Handler": String,
    "Runtime": String,
    "Cpu": Number,
    "CustomContainerConfig": Map,
    "Code": Map,
    "CustomRuntimeConfig": Map,
    "CustomDns": Map,
    "Description": String,
    "DiskSize": Integer,
    "EnvironmentVariables": Map,
    "GpuConfig": Map,
    "InstanceLifecycleConfig": Map,
    "InternetAccess": Boolean,
    "InstanceConcurrency": Integer,
    "Layers": List,
    "LogConfig": Map,
    "MemorySize": Integer,
    "NasConfig": Map,
    "OssMountConfig": Map,
    "Role": String,
    "TracingConfig": Map,
    "Timeout": Integer,
    "VpcConfig": Map,
    "DisableOndemand": Boolean,
    "SessionAffinityConfig": Map,
    "InstanceIsolationMode": String,
    "SessionAffinity": String,
    "Tags": List
  }
}

Properties

Property Name

Type

Required

Allow updates

Description

Constraint

FunctionName

String

Yes

Yes

The name of the function.

The name can contain letters, digits, underscores (_), and hyphens (-). It must be 1 to 64 characters in length and cannot start with a digit or a hyphen (-).

Handler

String

Yes

Yes

The entry point for the function execution.

None.

Runtime

String

Yes

Yes

The runtime environment of the function.

Supported runtimes include the following: nodejs8, nodejs10, nodejs12, nodejs14, nodejs16, nodejs18, nodejs20, go1, python3, python3.9, python3.10, java8, java11, php7.2, dotnetcore3.1, custom, custom.debian10, and custom-container.

Cpu

Number

No

Yes

The CPU specification of the function.

The unit is vCPU. The value must be a multiple of 0.05 vCPU. The minimum value is 0.05 and the maximum value is 16. The ratio of CPU to memory size (in GB) must be between 1:1 and 1:4.

CustomContainerConfig

Map

No

Yes

The configuration of the custom container runtime.

After configuration, the function can be executed using a custom container image. Specify either Code or CustomContainerConfig. For more information, see CustomContainerConfig properties.

Code

Map

No

Yes

The function code ZIP package.

Specify either Code or customContainerConfig. For more information, see Code properties.

CustomRuntimeConfig

Map

No

Yes

The custom runtime configuration.

For more information, see CustomRuntimeConfig properties.

CustomDns

Map

No

Yes

The custom DNS configuration.

For more information, see CustomDns properties.

Description

String

No

Yes

The description of the function.

None.

DiskSize

Integer

No

Yes

The disk specification of the function.

The unit is MB. Valid values are 512 MB and 10240 MB.

EnvironmentVariables

Map

No

Yes

The environment variables of the function.

The set environment variables can be accessed in the runtime environment. For example:

{'testKey': 'testValue'}

GpuConfig

Map

No

Yes

The function GPU configuration.

For more information, see GpuConfig properties.

InstanceLifecycleConfig

Map

No

Yes

The instance lifecycle hook configuration.

For more information, see InstanceLifecycleConfig properties.

InternetAccess

Boolean

No

Yes

Specifies whether the function can access the public network.

The default value is true.

InstanceConcurrency

Integer

No

Yes

The maximum instance concurrency.

None.

Layers

List

No

Yes

The list of layers.

Multiple layers are merged in descending order of array subscripts. The content of a layer with a smaller subscript overwrites files with the same name in a layer with a larger subscript. For example:

["acs:fc:cn-beijing:186824xxxxxx:layers/fc_layer/versions/1"]

LogConfig

Map

No

Yes

The log configuration.

Logs generated by the function are written to the configured Logstore. For more information, see LogConfig properties.

DisableOndemand

Boolean

No

No

Specifies whether to disable the creation of on-demand instances.

If this feature is enabled, on-demand instances are not created. Only provisioned instances can be used.

SessionAffinityConfig

Map

No

No

The session affinity configuration.

None.

InstanceIsolationMode

String

No

No

The instance isolation mode.

None.

SessionAffinity

String

No

No

The session affinity policy for Function Compute requests.

Valid values:

  • MCP_SSE: implements request affinity for the MCP SSE protocol.

  • GENERATED_COOKIE: cookie-based affinity.

  • HEADER_FIELD: header-based affinity.

  • NONE: No association

MemorySize

Integer

No

Yes

The memory specification of the function.

The unit is MB. The memory size must be a multiple of 64 MB. The minimum value is 128 MB and the maximum value is 32 GB. The ratio of CPU to memory size (in GB) must be between 1:1 and 1:4.

NasConfig

Map

No

Yes

The NAS configuration.

After this parameter is configured, the function can access the specified NAS resources. For more information, see NasConfig properties.

OssMountConfig

Map

No

Yes

The OSS mount configuration.

For more information, see OssMountConfig properties.

Role

String

No

Yes

The RAM role that is granted to Function Compute.

After setting the role, Function Compute assumes the role to generate temporary access credentials. The temporary access credentials of the role can be used in the function to access specified Alibaba Cloud services, such as OSS and Tablestore.

TracingConfig

Map

No

Yes

The Tracing Analysis configuration.

After Function Compute is integrated with Tracing Analysis, you can record the time consumed by a request in Function Compute, view the cold start time of a function, and record the time consumed in the function. For more information, see TracingConfig properties.

Timeout

Integer

No

Yes

The timeout period for the function to run.

The unit is seconds. The minimum value is 1 second, the maximum value is 86400 seconds, and the default value is 3 seconds. The function execution is terminated after this time.

Tags

List

No

No

The list of custom tags.

VpcConfig

Map

No

Yes

The VPC configuration.

After this parameter is configured, the function can access the specified VPC resources. For more information, see VpcConfig properties.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]

Tags properties

Property Name

Type

Required

Allow Updates

Description

Constraint

Value

String

No

No

The tag value.

Length: 0 to 256 characters.

Key

String

Yes

No

The tag key.

Length: 1 to 256 characters.

TracingConfig syntax

"TracingConfig": {
  "Type": String,
  "Params": Map
}

TracingConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

Type

String

No

Yes

The protocol type for Tracing Analysis.

Only Jaeger is supported.

Params

Map

No

Yes

Tracing Analysis Parameters

The parameter is a map[string]string, where the key is "endpoint" and the value is the internal network endpoint for your Tracing Analysis. For example: endpoint: http://tracing-analysis-dc-hz.aliyuncs.com/adapt_xxx/api/otlp/traces.

VpcConfig syntax

"VpcConfig": {
  "VpcId": String,
  "VSwitchIds": List,
  "SecurityGroupId": String
}

VpcConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

VpcId

String

No

Yes

The VPC network ID.

None.

VSwitchIds

List

No

Yes

The list of vSwitches.

None.

SecurityGroupId

String

No

Yes

The security group ID.

None.

InstanceLifecycleConfig syntax

"InstanceLifecycleConfig": {
  "PreStop": Map,
  "Initializer": Map
}

InstanceLifecycleConfig properties

Property Name

Type

Required

Allow Updates

Description

Constraint

PreStop

Map

No

Yes

The configuration of the PreStop method.

For more information, see PreStop properties.

Initializer

Map

No

Yes

The configuration of the initializer method.

For more information, see Initializer properties.

PreStop syntax

"PreStop": {
  "Timeout": Integer,
  "Handler": String
}

PreStop properties

Property Name

Type

Required

Allow Updates

Description

Constraint

Timeout

Integer

No

Yes

The timeout period of the callback method.

The unit is seconds.

Handler

String

No

Yes

The entry point for the callback method execution.

The meaning is similar to that of a handler.

Initializer syntax

"Initializer": {
  "Timeout": Integer,
  "Handler": String
}

Initializer properties

Property Name

Type

Required

Allow updates

Description

Constraint

Timeout

Integer

No

Yes

The timeout period of the callback method.

The unit is seconds.

Handler

String

No

Yes

The entry point for the callback method execution.

The meaning is similar to that of a handler.

CustomContainerConfig syntax

"CustomContainerConfig": {
  "ResolvedImageUri": String,
  "AccelerationInfo": Map,
  "AcrInstanceId": String,
  "Entrypoint": List,
  "Command": List,
  "AccelerationType": String,
  "Port": Integer,
  "HealthCheckConfig": Map,
  "Image": String,
  "RegistryConfig": Map
}

CustomContainerConfig properties

Property

Type

Required

Allow Updates

Description

Constraint

ResolvedImageUri

String

No

Yes

The actual digest version of the deployed image.

When the function starts, the code version specified by this digest is actually used. This is returned by GetFunction and does not need to be provided as a parameter.

AccelerationInfo

Map

No

Yes

The image acceleration information.

For more information, see AccelerationInfo property.

AcrInstanceId

String

No

Yes

The ID of the ACR Enterprise Edition image repository.

This must be passed in when using an ACR Enterprise Edition image.

Entrypoint

List

No

Yes

The container startup command.

None.

Command

List

No

Yes

The container startup parameters.

None.

AccelerationType

String

No

Yes

Specifies whether to enable image acceleration.

Default enables image acceleration. None disables image acceleration.

Port

Integer

No

Yes

The listener port of the HTTP server for the custom container runtime.

None.

HealthCheckConfig

Map

No

Yes

The custom health check configuration for the function.

For more information, see HealthCheckConfig properties.

Image

String

No

Yes

The container image address.

None.

RegistryConfig

Map

No

Yes

The configuration information for the image repository.

For more information, see RegistryConfig properties.

RegistryConfig syntax

"RegistryConfig": {
  "CertConfig": Map,
  "NetworkConfig": Map,
  "AuthConfig": Map
}

RegistryConfig properties

Property Name

Type

Required

Allow Updates

Description

Constraint

CertConfig

Map

Yes

Yes

The certificate configuration.

For more information, see CertConfig properties.

NetworkConfig

Map

No

Yes

The network configuration.

For more information, see NetworkConfig properties.

AuthConfig

Map

No

Yes

The authorization configuration.

For more information, see AuthConfig properties.

CertConfig syntax

"CertConfig": {
  "Insecure": Boolean,
  "RootCaCertBase64": String
}

CertConfig properties

Property Name

Type

Required

Allow Updates

Description

Constraint

Insecure

Boolean

Yes

Yes

Specifies whether to skip certificate verification.

None.

RootCaCertBase64

String

No

Yes

The CA certificate for the image repository.

None.

NetworkConfig syntax

"NetworkConfig": {
  "VSwitchId": String,
  "VpcId": String,
  "SecurityGroupId": String
}

NetworkConfig properties

Property Name

Type

Required

Allow Updates

Description

Constraint

VSwitchId

String

Yes

Yes

The vSwitch ID that can connect to the image repository.

None.

VpcId

String

Yes

Yes

The VPC ID that can connect to the image repository.

None.

SecurityGroupId

String

Yes

Yes

The security group ID that can connect to the image repository.

None.

AuthConfig syntax

"AuthConfig": {
  "Password": String,
  "UserName": String
}

AuthConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

Password

String

Yes

Yes

The password for the image repository.

None.

UserName

String

Yes

Yes

The username for the image repository.

None.

AccelerationInfo syntax

"AccelerationInfo": {
  "Status": String
}

AccelerationInfo property

Property Name

Type

Required

Allow Updates

Description

Constraint

Status

String

No

Yes

The image acceleration status.

None.

HealthCheckConfig syntax

"HealthCheckConfig": {
  "TimeoutSeconds": Integer,
  "InitialDelaySeconds": Integer,
  "HttpGetUrl": String,
  "PeriodSeconds": Integer,
  "FailureThreshold": Integer,
  "SuccessThreshold": Integer
}

HealthCheckConfig properties

Property

Type

Required

Allow updates

Description

Constraint

TimeoutSeconds

Integer

No

Yes

The health check timeout period.

The value must be between 1 and 3. The default value is 1.

InitialDelaySeconds

Integer

No

Yes

The delay from container startup to the initiation of health checks.

The value must be between 0 and 120. The default value is 0.

HttpGetUrl

String

No

Yes

The custom health check URL for the container.

The length cannot exceed 2048 characters.

PeriodSeconds

Integer

No

Yes

The health check period.

The value must be between 1 and 120. The default value is 3.

FailureThreshold

Integer

No

Yes

The health check failure threshold.

The system considers the check to have failed when this value is reached. The value must be between 1 and 120. The default value is 3.

SuccessThreshold

Integer

No

Yes

The health check success threshold.

The system considers the check to be successful when this value is reached. The value must be between 1 and 120. The default value is 1.

Code syntax

"Code": {
  "SourceCode": String,
  "ZipFile": String,
  "Checksum": String,
  "OssObjectName": String,
  "OssBucketName": String
}

Code properties

Property Name

Type

Required

Allow updates

Description

Constraint

SourceCode

String

No

Yes

The function code.

None.

ZipFile

String

No

Yes

The Base64 encoding of the function code ZIP package.

None.

Checksum

String

No

Yes

The CRC-64 value of the function code package.

If a checksum is provided, Function Compute verifies that the checksum of the code package matches the one provided.

OssObjectName

String

No

Yes

The name of the OSS object where the user's function code ZIP package is stored.

None.

OssBucketName

String

No

Yes

The name of the OSS bucket where the user's function code ZIP package is stored.

None.

CustomRuntimeConfig syntax

"CustomRuntimeConfig": {
  "Args": List,
  "Command": List,
  "Port": Integer,
  "HealthCheckConfig": Map
}

CustomRuntimeConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

Args

List

No

Yes

The instance startup parameters.

None.

Command

List

No

Yes

The instance startup command.

None.

Port

Integer

No

Yes

The listener port of the HTTP server.

None.

HealthCheckConfig

Map

No

Yes

The custom health check configuration for the function.

For more information, see HealthCheckConfig properties.

GpuConfig syntax

"GpuConfig": {
  "GpuMemorySize": Integer,
  "GpuType": String
}

GpuConfig properties

Property Name

Type

Required

Allow Updates

Description

Constraint

GpuMemorySize

Integer

No

Yes

The GPU memory specification.

The unit is MB. The value must be a multiple of 1024 MB.

GpuType

String

No

Yes

The GPU instance type.

Valid values:

  • fc.gpu.tesla.1 indicates a GPU Tesla series instance type.

  • fc.gpu.ampere.1 indicates a GPU Ampere series instance type.

  • fc.gpu.ada.1 indicates a GPU Ada series instance type.

OssMountConfig syntax

"OssMountConfig": {
  "MountPoints": List
}

OssMountConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

MountPoints

List

No

Yes

The list of OSS mount targets.

For more information, see MountPoints properties.

MountPoints syntax

"MountPoints": [
  {
    "MountDir": String,
    "BucketName": String,
    "Endpoint": String,
    "ReadOnly": Boolean,
    "BucketPath": String
  }
]

MountPoints properties

Property Name

Type

Required

Allow Updates

Description

Constraint

MountDir

String

No

Yes

The local mount folder.

None.

BucketName

String

No

Yes

The mounted OSS bucket.

None.

Endpoint

String

No

Yes

The OSS endpoint.

None.

ReadOnly

Boolean

No

Yes

This is read-only.

None.

BucketPath

String

No

Yes

The path of the mounted OSS bucket.

None.

CustomDns syntax

"CustomDns": {
  "Searches": List,
  "DnsOptions": List,
  "NameServers": List
}

CustomDns properties

Property

Type

Required

Allow updates

Description

Constraint

Searches

List

No

Yes

The list of DNS search domains.

None.

DnsOptions

List

No

Yes

The list of DNS parsing configurations in the resolv.conf file.

Each item corresponds to a key-value pair in the format key:value, where the key is required. For more information, see DnsOptions properties.

NameServers

List

No

Yes

The list of IP addresses for the DNS servers.

None.

DnsOptions syntax

"DnsOptions": [
  {
    "Value": String,
    "Name": String
  }
]

DnsOptions properties

Property Name

Type

Required

Allow updates

Description

Constraint

Name

String

No

Yes

The name of the configuration item.

None.

Value

String

No

Yes

The value of the configuration item.

None.

NasConfig syntax

"NasConfig": {
  "MountPoints": List,
  "UserId": Integer,
  "GroupId": Integer
}

NasConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

MountPoints

List

No

Yes

The list of mount targets.

For more information, see MountPoints properties.

UserId

Integer

No

Yes

The account ID.

None.

GroupId

Integer

No

Yes

The group ID.

None.

LogConfig syntax

"LogConfig": {
  "Project": String,
  "LogBeginRule": String,
  "Logstore": String,
  "EnableInstanceMetrics": Boolean,
  "EnableRequestMetrics": Boolean
}

LogConfig properties

Property Name

Type

Required

Allow updates

Description

Constraint

Project

String

No

Yes

The name of the Simple Log Service project.

None.

LogBeginRule

String

No

Yes

The matching rule for the first line of a log.

None.

Logstore

String

No

Yes

The name of the Simple Log Service Logstore.

None.

EnableInstanceMetrics

Boolean

No

Yes

Specifies whether to enable instance-level metrics.

When this feature is enabled, you can view core instance-level metrics, such as CPU utilization, memory usage, instance network conditions, and the number of requests within an instance. false: The default value, which disables instance-level metrics. true: enables instance-level metrics.

EnableRequestMetrics

Boolean

No

Yes

Specifies whether to enable request-level metrics.

When this feature is enabled, you can view the time and memory consumed by a specific invocation of any function in this service. false: disables request-level metrics. true: The default value, which enables request-level metrics.

Return values

Fn::GetAtt

  • FunctionId: The unique ID that is generated by the system for the function.

  • FunctionName: The name of the function.

  • ARN: The ARN of the function.

Examples

ROSTemplateFormatVersion: '2015-09-01'
Resources:
  Function:
    Type: ALIYUN::FC3::Function
    Properties:
      Code:
        SourceCode: |
          import time
          import json
          import urllib.request
          import logging


          def handler(event, context):
              logger = logging.getLogger()

              event = json.loads(event)
              logger.info('receive request: %s', event)

              res_props = event['ResourceProperties']

              result = dict(
                  RequestId=event['RequestId'],
                  LogicalResourceId=event['LogicalResourceId'],
                  StackId=event['StackId'],
                  Status='SUCCESS',
                  PhysicalResourceId='dummy'
              )
              if event['RequestType'] != 'Delete':
                  result['Data'] = dict(z=res_props['X'] + res_props['Y'])

              headers = {
                  'Content-type': 'application/json',
                  'Accept': 'application/json',
                  'Date': time.strftime('%a, %d %b %Y %X GMT', time.gmtime())
              }
              data = json.dumps(result).encode('utf-8')  # Use an encoded byte string.
              req = urllib.request.Request(event['ResponseURL'], data=data, headers=headers, method='PUT')
              with urllib.request.urlopen(req) as resp:
                  resp_content = resp.read().decode('utf-8')  # Read and decode the response.
              logger.info('response: %s', resp_content)
      Handler: index.handler
      FunctionName:
        Ref: FunctionName
      Runtime:
        Ref: Runtime
Parameters:
  Runtime:
    Default: python3.9
    Required: true
    Type: String
    Description:
      en: The programming language of the function.
  FunctionName:
    Default: hello-world
    Required: true
    Type: String
    Description:
      en: The name of the function.
Outputs:
  FunctionId:
    Description: The function ID
    Value:
      Fn::GetAtt:
        - Function
        - FunctionId
  ARN:
    Description: The ARN for ALIYUN::ROS::CustomResource
    Value:
      Fn::GetAtt:
        - Function
        - ARN
  FunctionName:
    Description: The function name
    Value:
      Fn::GetAtt:
        - Function
        - FunctionName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Function": {
      "Type": "ALIYUN::FC3::Function",
      "Properties": {
        "Code": {
          "SourceCode": "import time\nimport json\nimport urllib.request\nimport logging\n\n\ndef handler(event, context):\n    logger = logging.getLogger()\n\n    event = json.loads(event)\n    logger.info('receive request: %s', event)\n\n    res_props = event['ResourceProperties']\n\n    result = dict(\n        RequestId=event['RequestId'],\n        LogicalResourceId=event['LogicalResourceId'],\n        StackId=event['StackId'],\n        Status='SUCCESS',\n        PhysicalResourceId='dummy'\n    )\n    if event['RequestType'] != 'Delete':\n        result['Data'] = dict(z=res_props['X'] + res_props['Y'])\n\n    headers = {\n        'Content-type': 'application/json',\n        'Accept': 'application/json',\n        'Date': time.strftime('%a, %d %b %Y %X GMT', time.gmtime())\n    }\n    data = json.dumps(result).encode('utf-8')  # Use an encoded byte string.\n    req = urllib.request.Request(event['ResponseURL'], data=data, headers=headers, method='PUT')\n    with urllib.request.urlopen(req) as resp:\n        resp_content = resp.read().decode('utf-8')  # Read and decode the response.\n    logger.info('response: %s', resp_content)\n"
        },
        "Handler": "index.handler",
        "FunctionName": {
          "Ref": "FunctionName"
        },
        "Runtime": {
          "Ref": "Runtime"
        }
      }
    }
  },
  "Parameters": {
    "Runtime": {
      "Default": "python3.9",
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "The programming language of the function."
      }
    },
    "FunctionName": {
      "Default": "hello-world",
      "Required": true,
      "Type": "String",
      "Description": {
        "en": "The name of the function."
      }
    }
  },
  "Outputs": {
    "FunctionId": {
      "Description": "The function ID",
      "Value": {
        "Fn::GetAtt": [
          "Function",
          "FunctionId"
        ]
      }
    },
    "ARN": {
      "Description": "The ARN for ALIYUN::ROS::CustomResource",
      "Value": {
        "Fn::GetAtt": [
          "Function",
          "ARN"
        ]
      }
    },
    "FunctionName": {
      "Description": "The function name",
      "Value": {
        "Fn::GetAtt": [
          "Function",
          "FunctionName"
        ]
      }
    }
  }
}