Aliyun::Serverless::Service

更新时间:
复制 MD 格式

Creates a Function Compute service.

Syntax

{
  "Type": "Aliyun::Serverless::Service",
  "Properties": {
    "Role": String,
    "Policies": List,
    "Description": String,
    "InternetAccess": Boolean,
    "VpcConfig": Map,
    "LogConfig": Map,
    "NasConfig": Map
  }
}

Properties

Property Type Required Update allowed Description Constraints
Role String No Yes The Alibaba Cloud Resource Name (ARN) of the RAM role that grants permissions to Function Compute. None
Policies List No Yes Creates a default RAM role and attaches the specified policies. Example:
[
"AliyunOSSFullAccess",
  {
    "Version": "1",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "oss:Get*",
          "oss:List*"
        ],
        "Resource": "*"
      }
    ]
  }
]

If you specify the Role parameter, the Policies parameter does not take effect and a default RAM role is not created.

Policies can be a system policy name or a policy document. If you specify a system policy name, that policy is attached to the default RAM role. If you provide a policy document, a new policy is created from the document and attached to the default RAM role.

Description String No Yes The description of the service. None
InternetAccess Boolean No Yes Specifies whether the service can access the internet. Valid values:
  • true (default): The service can access the internet.
  • false: The service cannot access the internet.
VpcConfig Map No Yes The virtual private cloud (VPC) configuration. This enables the function to access the specified VPC. For more information, see VpcConfig properties.
LogConfig Map No Yes The log configuration. Function logs are written to the specified Logstore. For more information, see LogConfig properties.
NasConfig Map No Yes The NAS configuration. This enables the function to access the specified NAS file system. For more information, see NasConfig properties.

VpcConfig syntax

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

VpcConfig properties

Property Name Type Required Update allowed Description Constraints
SecurityGroupId String Yes Yes The ID of the security group. None
VSwitchIds List Yes Yes One or more vSwitch IDs. For example: [VSwitchId, ...]. You must specify at least one vSwitch ID.
VpcId String Yes Yes The ID of the VPC. None

LogConfig syntax

"LogConfig": {
  "Project": String,
  "Logstore": String
}

LogConfig properties

Property Type Required Update allowed Description Constraints
Project String No Yes The name of the project in LogHub. None
Logstore String No Yes The name of the Logstore in LogHub. None

NasConfig syntax

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

NasConfig properties

Property Name Type Required Update allowed Description Constraints
MountPoints List Yes Yes The mount points. For more information, see MountPoints properties.
UserId Integer Yes Yes The user ID. Valid values: -1 to 65534.
GroupId Integer Yes Yes The group ID. Valid values: -1 to 65534.

MountPoints syntax

"MountPoints": [
  {
    "ServerAddr": String,
    "MountDir": String
  }
]

MountPoints properties

Property Type Required Update allowed Description Constraints
ServerAddr String Yes Yes The address of the NAS server. None
MountDir String Yes Yes The local mount directory. None

Return values

Fn::GetAtt

  • ServiceId: The unique ID of the service.
  • ServiceName: The name of the service.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Transform": "Aliyun::Serverless-2018-04-03",
  "Resources": {
    "MyService": {
      "Type": "Aliyun::Serverless::Service",
      "Properties": {
        "Policies": [
          "AliyunFCReadOnlyAccess",
          {
            "Version": "1",
            "Statement": [
              {
                "Effect": "Allow",
                "Action": [
                  "oss:GetObject",
                  "oss:GetObjectACL"
                ],
                "Resource": "*"
              }
            ]
          }
        ]
      }
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  MyService: # service name
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Policies:
        - AliyunFCReadOnlyAccess # Managed Policy
        - Version: '1' # Policy Document
          Statement:
            - Effect: Allow
              Action:
                - oss:GetObject
                - oss:GetObjectACL
              Resource: '*'