PublishLayerVersion - Amazon Lambda
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

PublishLayerVersion

从 ZIP 归档中创建某个 Amazon Lambda 层。每次使用相同的层名称调用 PublishLayerVersion 时,将会创建新的版本。

使用 CreateFunctionUpdateFunctionConfiguration 将层添加到您的函数。

请求语法

POST /2018-10-31/layers/LayerName/versions HTTP/1.1 Content-type: application/json { "CompatibleArchitectures": [ "string" ], "CompatibleRuntimes": [ "string" ], "Content": { "S3Bucket": "string", "S3Key": "string", "S3ObjectVersion": "string", "ZipFile": blob }, "Description": "string", "LicenseInfo": "string" }

URI 请求参数

请求使用以下 URI 参数。

LayerName

层的名称或 Amazon Resource Name (ARN)。

长度限制:最小长度为 1。长度上限为 140。

模式:(arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+)|[a-zA-Z0-9-_]+

必需:是

请求体

请求接受采用 JSON 格式的以下数据。

CompatibleArchitectures

兼容指令集架构列表。

类型:字符串数组

数组成员:最多 15 项。

有效值:x86_64 | arm64

必需:否

CompatibleRuntimes

兼容的函数运行时列表。用于使用 ListLayersListLayerVersions 进行筛选。

以下列表包括已弃用的运行时。有关更多信息,请参阅运行时弃用策略

类型:字符串数组

数组成员:最多 15 项。

有效值:nodejs | nodejs4.3 | nodejs6.10 | nodejs8.10 | nodejs10.x | nodejs12.x | nodejs14.x | nodejs16.x | java8 | java8.al2 | java11 | python2.7 | python3.6 | python3.7 | python3.8 | python3.9 | dotnetcore1.0 | dotnetcore2.0 | dotnetcore2.1 | dotnetcore3.1 | dotnet6 | nodejs4.3-edge | go1.x | ruby2.5 | ruby2.7 | provided | provided.al2 | nodejs18.x | python3.10 | java17 | ruby3.2 | python3.11 | nodejs20.x | provided.al2023 | python3.12 | java21

必需:否

Content

函数层存档。

类型:LayerVersionContentInput 对象

必需:是

Description

关于版本的描述。

类型:字符串

长度约束:最小长度为 0。长度上限为 256。

必需:否

LicenseInfo

层的软件许可证。它可以是以下任一种:

  • SPDX 许可证标识符。例如,MIT

  • 在 Internet 上托管的许可证的 URL。例如,https://opensource.org/licenses/MIT

  • 许可证全文。

类型:字符串

长度约束:最大长度为 512。

必需:否

响应语法

HTTP/1.1 201 Content-type: application/json { "CompatibleArchitectures": [ "string" ], "CompatibleRuntimes": [ "string" ], "Content": { "CodeSha256": "string", "CodeSize": number, "Location": "string", "SigningJobArn": "string", "SigningProfileVersionArn": "string" }, "CreatedDate": "string", "Description": "string", "LayerArn": "string", "LayerVersionArn": "string", "LicenseInfo": "string", "Version": number }

响应元素

如果此操作成功,则该服务将会发送回 HTTP 201 响应。

服务以 JSON 格式返回的以下数据。

CompatibleArchitectures

兼容指令集架构列表。

类型:字符串数组

数组成员:最多 15 项。

有效值:x86_64 | arm64

CompatibleRuntimes

层的兼容运行时。

以下列表包括已弃用的运行时。有关更多信息,请参阅运行时弃用策略

类型:字符串数组

数组成员:最多 15 项。

有效值:nodejs | nodejs4.3 | nodejs6.10 | nodejs8.10 | nodejs10.x | nodejs12.x | nodejs14.x | nodejs16.x | java8 | java8.al2 | java11 | python2.7 | python3.6 | python3.7 | python3.8 | python3.9 | dotnetcore1.0 | dotnetcore2.0 | dotnetcore2.1 | dotnetcore3.1 | dotnet6 | nodejs4.3-edge | go1.x | ruby2.5 | ruby2.7 | provided | provided.al2 | nodejs18.x | python3.10 | java17 | ruby3.2 | python3.11 | nodejs20.x | provided.al2023 | python3.12 | java21

Content

有关层版本的详细信息。

类型:LayerVersionContentOutput 对象

CreatedDate

层版本的创建日期,为 ISO-8601 格式 (YYYYY-MM-DDThh:mm:ss.sTZD)。

类型:字符串

Description

关于版本的描述。

类型:字符串

长度约束:最小长度为 0。长度上限为 256。

LayerArn

层的 ARN。

类型:字符串

长度限制:最小长度为 1。长度上限为 140。

模式:arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+

LayerVersionArn

层版本的 ARN。

类型:字符串

长度限制:最小长度为 1。长度上限为 140。

模式:arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\d{12}:layer:[a-zA-Z0-9-_]+:[0-9]+

LicenseInfo

层的软件许可证。

类型:字符串

长度约束:最大长度为 512。

Version

版本号。

类型:长整型

错误

有关所有操作返回的常见错误的信息,请参阅 常见错误

CodeStorageExceededException

您的 Amazon Web Services 账户 已超出最大总代码大小。有关更多信息,请参阅 Lambda 限额

HTTP 状态代码:400

InvalidParameterValueException

请求中的参数之一无效。

HTTP 状态代码:400

ResourceNotFoundException

请求中指定的资源不存在。

HTTP 状态代码:404

ServiceException

Amazon Lambda 服务遇到了内部错误。

HTTP 状态代码:500

TooManyRequestsException

超出了请求吞吐量限制。有关更多信息,请参阅 Lambda 限额

HTTP 状态代码:429

另请参阅

有关在特定语言的 Amazon SDK 中使用此 API 的更多信息,请参阅以下内容: