View a markdown version of this page

PublishVersion - AWS Lambda

PublishVersion

Creates a version from the current code and configuration of a function. Use versions to create a snapshot of your function code and configuration that doesn't change.

AWS Lambda doesn't publish a version if the function's configuration and code haven't changed since the last version. Use UpdateFunctionCode or UpdateFunctionConfiguration to update the function before publishing a version.

Clients can invoke versions directly or with an alias. To create an alias, use CreateAlias.

Request Syntax

POST /2015-03-31/functions/FunctionName/versions HTTP/1.1 Content-type: application/json { "CodeSha256": "string", "Description": "string", "PublishTo": "string", "RevisionId": "string" }

URI Request Parameters

The request uses the following URI parameters.

FunctionName

The name or ARN of the Lambda function.

Name formats
  • Function name - MyFunction.

  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction.

  • Partial ARN - 123456789012:function:MyFunction.

The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

Length Constraints: Minimum length of 1. Maximum length of 140.

Pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?

Required: Yes

Request Body

The request accepts the following data in JSON format.

CodeSha256

Only publish a version if the hash value matches the value that's specified. Use this option to avoid publishing a version if the function code has changed since you last updated it. You can get the hash for the version that you uploaded from the output of UpdateFunctionCode.

Type: String

Required: No

Description

A description for the version to override the description in the function configuration.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.

Required: No

PublishTo

Specifies where to publish the function version or configuration.

Type: String

Valid Values: LATEST_PUBLISHED

Required: No

RevisionId

Only update the function if the revision ID matches the ID that's specified. Use this option to avoid publishing a version if the function configuration has changed since you last updated it.

Type: String

Required: No

Response Syntax

HTTP/1.1 201 Content-type: application/json { "Architectures": [ "string" ], "CapacityProviderConfig": { "LambdaManagedInstancesCapacityProviderConfig": { "CapacityProviderArn": "string", "ExecutionEnvironmentMemoryGiBPerVCpu": number, "PerExecutionEnvironmentMaxConcurrency": number } }, "CodeSha256": "string", "CodeSize": number, "ConfigSha256": "string", "DeadLetterConfig": { "TargetArn": "string" }, "Description": "string", "DurableConfig": { "ExecutionTimeout": number, "KMSKeyArn": "string", "RetentionPeriodInDays": number }, "Environment": { "Error": { "ErrorCode": "string", "Message": "string" }, "Variables": { "string" : "string" } }, "EphemeralStorage": { "Size": number }, "FileSystemConfigs": [ { "Arn": "string", "LocalMountPath": "string", "S3FilesConfig": { "DirectS3Read": "string" } } ], "FunctionArn": "string", "FunctionName": "string", "Handler": "string", "ImageConfigResponse": { "Error": { "ErrorCode": "string", "Message": "string" }, "ImageConfig": { "Command": [ "string" ], "EntryPoint": [ "string" ], "WorkingDirectory": "string" } }, "KMSKeyArn": "string", "LastModified": "string", "LastUpdateStatus": "string", "LastUpdateStatusReason": "string", "LastUpdateStatusReasonCode": "string", "Layers": [ { "Arn": "string", "CodeSize": number, "SigningJobArn": "string", "SigningProfileVersionArn": "string" } ], "LoggingConfig": { "ApplicationLogLevel": "string", "LogFormat": "string", "LogGroup": "string", "SystemLogLevel": "string" }, "MasterArn": "string", "MemorySize": number, "PackageType": "string", "RevisionId": "string", "Role": "string", "Runtime": "string", "RuntimeVersionConfig": { "Error": { "ErrorCode": "string", "Message": "string" }, "RuntimeVersionArn": "string" }, "SigningJobArn": "string", "SigningProfileVersionArn": "string", "SnapStart": { "ApplyOn": "string", "OptimizationStatus": "string" }, "State": "string", "StateReason": "string", "StateReasonCode": "string", "TenancyConfig": { "TenantIsolationMode": "string" }, "Timeout": number, "TracingConfig": { "Mode": "string" }, "Version": "string", "VpcConfig": { "Ipv6AllowedForDualStack": boolean, "SecurityGroupIds": [ "string" ], "SubnetIds": [ "string" ], "VpcId": "string" } }

Response Elements

If the action is successful, the service sends back an HTTP 201 response.

The following data is returned in JSON format by the service.

Architectures

The instruction set architecture that the function supports. Architecture is a string array with one of the valid values. The default architecture value is x86_64.

Type: Array of strings

Array Members: Fixed number of 1 item.

Valid Values: x86_64 | arm64

CapacityProviderConfig

Configuration for the capacity provider that manages compute resources for Lambda functions.

Type: CapacityProviderConfig object

CodeSha256

The SHA256 hash of the function's deployment package.

Type: String

CodeSize

The size of the function's deployment package, in bytes.

Type: Long

ConfigSha256

The SHA256 hash of the function configuration.

Type: String

DeadLetterConfig

The function's dead letter queue.

Type: DeadLetterConfig object

Description

The function's description.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.