AWS Lambda

Create function

Creates a Lambda function. To create a function, you need a deployment package and an execution role.

Inputs

Expand All

Field

Type

Description

region [required]

enum

default: us-east-1

functionName [required]

string

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

role [required]

string

The Amazon Resource Name (ARN) of the function's execution role.

code [required]

 <oneOf>

Choose how to provide the code for the function.

Option 1

object

option [required]

string

runtime [required]

enum

The identifier of the function's runtime. For more information, see Runtime deprecation policy. Allowed enum values: nodejs20.x,nodejs18.x,nodejs16.x,python3.12,python3.11,python3.10,python3.9,python3.8,ruby3.3,ruby3.2

code [required]

string

The code of your Lambda Function.

handler

string

The name of the method within your code that Lambda calls to run your function. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see Lambda programming model.

filename [required]

string

The name of the file as how it should be saved in the zip file. This will be reflected in the handler name.

Option 2

object

option [required]

string

s3Bucket [required]

string

An Amazon S3 bucket in the same Amazon Web Services Region as your function. The bucket can be in a different Amazon Web Services account.

s3Key [required]

string

The Amazon S3 key of the deployment package.

s3ObjectVersion

string

For versioned objects, the version of the deployment package object to use.

handler

string

The name of the method within your code that Lambda calls to run your function. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see Lambda programming model.

runtime [required]

enum

The identifier of the function's runtime. For more information, see Runtime deprecation policy. Allowed enum values: nodejs20.x,nodejs18.x,nodejs16.x,python3.12,python3.11,python3.10,python3.9,python3.8,ruby3.3,ruby3.2,java21,java17,java11,java8.al2,dotnet8,dotnet7,dotnet6,provided.al2023,provided.al2

Option 3

object

option [required]

string

imageUri [required]

string

URI of a container image in the Amazon ECR registry.

imageConfig

object

Container image configuration values that override the values in the container image Dockerfile.

EntryPoint

[string]

Specifies the entry point to their application, which is typically the location of the runtime executable.

Command

[string]

Specifies parameters that you want to pass in with ENTRYPOINT.

WorkingDirectory

string

Specifies the working directory.

description

string

A description of the function.

timeout

number

The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds. The maximum allowed value is 900 seconds. For more information, see Lambda execution environment.

default: 3

memorySize

number

The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB.

default: 128

publish

boolean

Set to true to publish the first version of the function during creation.

vpcConfig

object

For network connectivity to Amazon Web Services resources in a VPC, specify a list of security groups and subnets in the VPC. When you connect a function to a VPC, it can access resources and the internet only through that VPC. For more information, see Configuring a Lambda function to access resources in a VPC.

SubnetIds

[string]

A list of VPC subnet IDs.

SecurityGroupIds

[string]

A list of VPC security group IDs.

Ipv6AllowedForDualStack

boolean

Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.

deadLetterConfig

object

A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing. For more information, see Dead-letter queues.

TargetArn

string

The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.

environment

object

Environment variables that are accessible from function code during execution.

Variables

object

Environment variable key-value pairs. For more information, see Using Lambda environment variables.

kmsKeyArn

string

The ARN of the Key Management Service (KMS) customer managed key that's used to encrypt your function's environment variables. When Lambda SnapStart is activated, Lambda also uses this key is to encrypt your function's snapshot. If you deploy your function using a container image, Lambda also uses this key to encrypt your function when it's deployed. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). If you don't provide a customer managed key, Lambda uses a default service key.

tracingConfig

object

Set Mode to Active to sample and trace a subset of incoming requests with X-Ray.

Mode

string

The tracing mode.

tags

A list of tags to apply to the function.

layers

[string]

A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.

fileSystemConfigs

[object]

Connection settings for an Amazon EFS file system.

Arn [required]

string

The Amazon Resource Name (ARN) of the Amazon EFS access point that provides access to the file system.

LocalMountPath [required]

string

The path where the function can access the file system, starting with /mnt/.

codeSigningConfigArn

string

To enable code signing for this function, specify the ARN of a code-signing configuration. A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.

architecture

enum

The instruction set architecture that the function supports. The default value is x86_64. Allowed enum values: x86_64,arm64

default: x86_64

ephemeralStorage

object

The size of the function's /tmp directory in MB. The default value is 512, but can be any whole number between 512 and 10,240 MB. For more information, see Configuring ephemeral storage (console).

Size [required]

number

The size of the function's /tmp directory.

snapStart

object

The function's SnapStart setting.

ApplyOn

string

Set to PublishedVersions to create a snapshot of the initialized execution environment when you publish a function version.

loggingConfig

object

The function's Amazon CloudWatch Logs configuration settings.

LogFormat

string

The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.

ApplicationLogLevel

string

Set this property to filter the application logs for your function that Lambda sends to CloudWatch. Lambda only sends application logs at the selected level of detail and lower, where TRACE is the highest level and FATAL is the lowest.

SystemLogLevel

string

Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the selected level of detail and lower, where DEBUG is the highest level and WARN is the lowest.

LogGroup

string

The name of the Amazon CloudWatch log group the function sends logs to. By default, Lambda functions send logs to a default log group named /aws/lambda/<function name>. To use a different log group, enter an existing log group or enter a new log group name.

Outputs

Expand All

Field

Type

Description

amzRequestId [required]

string

FunctionName

string

The name of the function.

FunctionArn

string

The function's Amazon Resource Name (ARN).

Runtime

string

The identifier of the function's runtime. Runtime is required if the deployment package is a .zip file archive. The following list includes deprecated runtimes. For more information, see Runtime deprecation policy.

Role

string

The function's execution role.

Handler

string

The function that Lambda calls to begin running your function.

CodeSize

number

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

Description

string

The function's description.

Timeout

number

The amount of time in seconds that Lambda allows a function to run before stopping it.

MemorySize

number

The amount of memory available to the function at runtime.

LastModified

string

The date and time that the function was last updated, in ISO-8601 format (YYYY-MM-DDThh:mm:ss.sTZD).

CodeSha256

string

The SHA256 hash of the function's deployment package.

Version

string

The version of the Lambda function.

VpcConfig

object

The function's networking configuration.

SubnetIds

[string]

A list of VPC subnet IDs.

SecurityGroupIds

[string]

A list of VPC security group IDs.

VpcId

string

The ID of the VPC.

Ipv6AllowedForDualStack

boolean

Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.

DeadLetterConfig

object

The function's dead letter queue.

TargetArn

string

The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.

Environment

object

The function's environment variables. Omitted from CloudTrail logs.

Variables

object

Environment variable key-value pairs. Omitted from CloudTrail logs.

Error

object

Error messages for environment variables that couldn't be applied.

ErrorCode

string

The error code.

Message

string

The error message.

KMSKeyArn

string

The KMS key that's used to encrypt the function's environment variables. When Lambda SnapStart is activated, this key is also used to encrypt the function's snapshot. This key is returned only if you've configured a customer managed key.

TracingConfig

object

The function's X-Ray tracing configuration.

Mode

string

The tracing mode.

MasterArn

string

For Lambda@Edge functions, the ARN of the main function.

RevisionId

string

The latest updated revision of the function or alias.

Layers

[object]

The function's layers.

Arn

string

The Amazon Resource Name (ARN) of the function layer.

CodeSize

number

The size of the layer archive in bytes.

SigningProfileVersionArn

string

The Amazon Resource Name (ARN) for a signing profile version.

SigningJobArn

string

The Amazon Resource Name (ARN) of a signing job.

State

string

The current state of the function. When the state is Inactive, you can reactivate the function by invoking it.

StateReason

string

The reason for the function's current state.

StateReasonCode

string

The reason code for the function's current state. When the code is Creating, you can't invoke or modify the function.

LastUpdateStatus

string

The status of the last update that was performed on the function. This is first set to Successful after function creation completes.

LastUpdateStatusReason

string

The reason for the last update that was performed on the function.

LastUpdateStatusReasonCode

string

The reason code for the last update that was performed on the function.

FileSystemConfigs

[object]

Connection settings for an Amazon EFS file system.

Arn [required]

string

The Amazon Resource Name (ARN) of the Amazon EFS access point that provides access to the file system.

LocalMountPath [required]

string

The path where the function can access the file system, starting with /mnt/.

PackageType

string

The type of deployment package. Set to Image for container image and set Zip for .zip file archive.

ImageConfigResponse

object

The function's image configuration values.

ImageConfig

object

Configuration values that override the container image Dockerfile.

EntryPoint

[string]

Specifies the entry point to their application, which is typically the location of the runtime executable.

Command

[string]

Specifies parameters that you want to pass in with ENTRYPOINT.

WorkingDirectory

string

Specifies the working directory.

Error

object

Error response to GetFunctionConfiguration.

ErrorCode

string

Error code.

Message

string

Error message.

SigningProfileVersionArn

string

The ARN of the signing profile version.

SigningJobArn

string

The ARN of the signing job.

Architectures

[string]

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.

EphemeralStorage

object

The size of the function's /tmp directory in MB. The default value is 512, but can be any whole number between 512 and 10,240 MB. For more information, see Configuring ephemeral storage (console).

Size [required]

number

The size of the function's /tmp directory.

SnapStart

object

Set ApplyOn to PublishedVersions to create a snapshot of the initialized execution environment when you publish a function version. For more information, see Improving startup performance with Lambda SnapStart.

ApplyOn

string

When set to PublishedVersions, Lambda creates a snapshot of the execution environment when you publish a function version.

OptimizationStatus

string

When you provide a qualified Amazon Resource Name (ARN), this response element indicates whether SnapStart is activated for the specified function version.

RuntimeVersionConfig

object

The ARN of the runtime and any errors that occured.

RuntimeVersionArn

string

The ARN of the runtime version you want the function to use.

Error

object

Error response when Lambda is unable to retrieve the runtime version for a function.

ErrorCode

string

The error code.

Message

string

The error message.

LoggingConfig

object

The function's Amazon CloudWatch Logs configuration settings.

LogFormat

string

The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.

ApplicationLogLevel

string

Set this property to filter the application logs for your function that Lambda sends to CloudWatch. Lambda only sends application logs at the selected level of detail and lower, where TRACE is the highest level and FATAL is the lowest.

SystemLogLevel

string

Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the selected level of detail and lower, where DEBUG is the highest level and WARN is the lowest.

LogGroup

string

The name of the Amazon CloudWatch log group the function sends logs to. By default, Lambda functions send logs to a default log group named /aws/lambda/<function name>. To use a different log group, enter an existing log group or enter a new log group name.