Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . lambda ]

create-function

Description

Creates a new Lambda function. The function configuration is created from the request parameters, and the code for the function is provided by a .zip file. The function name is case-sensitive.

This operation requires permission for the lambda:CreateFunction action.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  create-function
--function-name <value>
--runtime <value>
--role <value>
--handler <value>
[--code <value>]
[--description <value>]
[--timeout <value>]
[--memory-size <value>]
[--publish | --no-publish]
[--vpc-config <value>]
[--dead-letter-config <value>]
[--environment <value>]
[--kms-key-arn <value>]
[--tracing-config <value>]
[--tags <value>]
[--zip-file <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--function-name (string)

The name 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.

--runtime (string)

The runtime version for the function.

Possible values:

  • nodejs
  • nodejs4.3
  • nodejs6.10
  • nodejs8.10
  • java8
  • python2.7
  • python3.6
  • dotnetcore1.0
  • dotnetcore2.0
  • dotnetcore2.1
  • nodejs4.3-edge
  • go1.x

--role (string)

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

--handler (string)

The name of the method within your code that Lambda calls to execute your function. For more information, see Programming Model .

--code (structure)

The code for the function.

Shorthand Syntax:

S3Bucket=string,S3Key=string,S3ObjectVersion=string

JSON Syntax:

{
  "S3Bucket": "string",
  "S3Key": "string",
  "S3ObjectVersion": "string"
}

--description (string)

A description of the function.

--timeout (integer)

The amount of time that Lambda allows a function to run before terminating it. The default is 3 seconds. The maximum allowed value is 900 seconds.

--memory-size (integer)

The amount of memory that your function has access to. Increasing the function's memory also increases it's CPU allocation. The default value is 128 MB. The value must be a multiple of 64 MB.

--publish | --no-publish (boolean)

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

--vpc-config (structure)

If your Lambda function accesses resources in a VPC, you provide this parameter identifying the list of security group IDs and subnet IDs. These must belong to the same VPC. You must provide at least one security group and one subnet ID.

Shorthand Syntax:

SubnetIds=string,string,SecurityGroupIds=string,string

JSON Syntax:

{
  "SubnetIds": ["string", ...],
  "SecurityGroupIds": ["string", ...]
}

--dead-letter-config (structure)

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 .

Shorthand Syntax:

TargetArn=string

JSON Syntax:

{
  "TargetArn": "string"
}

--environment (structure)

Environment variables that are accessible from function code during execution.

Shorthand Syntax:

Variables={KeyName1=string,KeyName2=string}

JSON Syntax:

{
  "Variables": {"string": "string"
    ...}
}

--kms-key-arn (string)

The ARN of the KMS key used to encrypt your function's environment variables. If not provided, AWS Lambda will use a default service key.

--tracing-config (structure)

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

Shorthand Syntax:

Mode=string

JSON Syntax:

{
  "Mode": "Active"|"PassThrough"
}

--tags (map)

The list of tags (key-value pairs) assigned to the new function. For more information, see Tagging Lambda Functions in the AWS Lambda Developer Guide .

Shorthand Syntax:

KeyName1=string,KeyName2=string

JSON Syntax:

{"string": "string"
  ...}

--zip-file (blob)

The path to the zip file of the code you are uploading. Example: fileb://code.zip

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Output

FunctionName -> (string)

The name of the function.

FunctionArn -> (string)

The function's Amazon Resource Name.

Runtime -> (string)

The runtime environment for the Lambda function.

Role -> (string)

The function's execution role.

Handler -> (string)

The function Lambda calls to begin executing your function.

CodeSize -> (long)

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

Description -> (string)

The function's description.

Timeout -> (integer)

The amount of time that Lambda allows a function to run before terminating it.

MemorySize -> (integer)

The memory allocated to the function

LastModified -> (string)

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

CodeSha256 -> (string)

The SHA256 hash of the function's deployment package.

Version -> (string)

The version of the Lambda function.

VpcConfig -> (structure)

The function's networking configuration.

SubnetIds -> (list)

A list of VPC subnet IDs.

(string)

SecurityGroupIds -> (list)

A list of VPC security groups IDs.

(string)

VpcId -> (string)

The ID of the VPC.

DeadLetterConfig -> (structure)

The function's dead letter queue.

TargetArn -> (string)

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

Environment -> (structure)

The function's environment variables.

Variables -> (map)

Environment variable key-value pairs.

key -> (string)

value -> (string)

Error -> (structure)

Error messages for environment variables that could not be applied.

ErrorCode -> (string)

The error code.

Message -> (string)

The error message.

KMSKeyArn -> (string)

The KMS key used to encrypt the function's environment variables. Only returned if you've configured a customer managed CMK.

TracingConfig -> (structure)

The function's AWS X-Ray tracing configuration.

Mode -> (string)

The tracing mode.

MasterArn -> (string)

The ARN of the master function.

RevisionId -> (string)

Represents the latest updated revision of the function or alias.