AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Invokes the CreateFunction operation against Amazon Lambda.

Syntax

CodeFromLocalZipFile (Default)

Publish-LMFunction
-FunctionName <String>
-ZipFilename <String>
-Handler <String>
-Runtime <Runtime>
-Role <String>
-Description <String>
-MemorySize <Nullable<Int32>>
-Timeout <Nullable<Int32>>
-DeadLetterConfig_TargetArn <String>
-Environment_Variable <Hashtable>
-KMSKeyArn <String>
-Publish <SwitchParameter>
-VpcConfig_SecurityGroupId <String[]>
-VpcConfig_SubnetId <String[]>
-Force <SwitchParameter>

CodeFromS3Location

Publish-LMFunction
-FunctionName <String>
-Handler <String>
-Runtime <Runtime>
-Role <String>
-Description <String>
-BucketName <String>
-Key <String>
-VersionId <String>
-MemorySize <Nullable<Int32>>
-Timeout <Nullable<Int32>>
-DeadLetterConfig_TargetArn <String>
-Environment_Variable <Hashtable>
-KMSKeyArn <String>
-Publish <SwitchParameter>
-VpcConfig_SecurityGroupId <String[]>
-VpcConfig_SubnetId <String[]>
-Force <SwitchParameter>

Description

Creates a new Lambda function. If the function name already exists, the operation will fail. Note that the function name is case-sensitive. This operation requires permission for the lambda:CreateFunction action.

Parameters

-BucketName <String>
Amazon S3 bucket name where the .zip file containing your deployment package is stored. This bucket must reside in the same AWS region where you are creating the Lambda function.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-DeadLetterConfig_TargetArn <String>
The ARN (Amazon Resource Value) of an Amazon SQS queue or Amazon SNS topic you specify as your Dead Letter Queue (DLQ).
Required?False
Position?Named
Accept pipeline input?False
-Description <String>
A short user-defined function description. Lambda does not use this value. Assign a meaningful description as you see fit.
Required?False
Position?Named
Accept pipeline input?False
-Environment_Variable <Hashtable>
Environment variable key-value pairs that represent your environment's configuration settings. The value(s) you specify cannot contain a ",".
Required?False
Position?Named
Accept pipeline input?False
-Force <SwitchParameter>
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?False
-FunctionName <String>
The name you want to assign to the function you are uploading. The function names appear in the console and are returned in the ListFunctions API. Function names are used to specify functions to other AWS Lambda APIs, such as Invoke.Length constraints: Minimum length of 1. Maximum length of 140.Pattern: (arn:aws:lambda:)?([a-z]{2}-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?
Required?True
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-Handler <String>
The function within your code that Lambda calls to begin execution. For Node.js, it is the module-name.export value in your function. For Java, it can be package.class-name::handler or package.class-name. For more information, see Lambda Function Handler (Java). Length constraints: Minimum length of 0. Maximum length of 128.Pattern: [^\s]+
Required?True
Position?3
Accept pipeline input?False
-Key <String>
The key name of the Amazon S3 object (the deployment package) you want to upload to Lambda.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-KMSKeyArn <String>
The Amazon Resource Name (ARN) of the KMS key used to encrypt your function's environment variables. If not provided, AWS Lambda will use a default service key.
Required?False
Position?Named
Accept pipeline input?False
-MemorySize <Nullable<Int32>>
The amount of memory, in MB, your Lambda function is given. Lambda uses this memory size to infer the amount of CPU and memory allocated to your function. Your function use-case determines your CPU and memory requirements. For example, a database operation might need less memory compared to an image processing function. The default value is 128 MB. The value must be a multiple of 64 MB.Valid range: Minimum value of 128. Maximum value of 1536.
Required?False
Position?Named
Accept pipeline input?False
-Publish <SwitchParameter>
If set requests that AWS Lambda create the Lambda function and publish a version as an atomic operation.
Required?False
Position?Named
Accept pipeline input?False
-Role <String>
The Amazon Resource Name (ARN) of the IAM role that Lambda assumes when it executes your function to access any other Amazon Web Services (AWS) resources. For more information, see AWS Lambda: How it WorksPattern: arn:aws:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+
Required?True
Position?5
Accept pipeline input?False
-Runtime <Runtime>
The runtime environment for the Lambda function you are uploading. To use the Node.js runtime v4.3, set the value to "nodejs4.3". To use earlier runtime (v0.10.42), set the value to "nodejs".Valid Values: dotnetcore1.0 | nodejs | nodejs4.3 | nodejs4.3-edge | java8 | python2.7
Required?False
Position?4
Accept pipeline input?False
-Timeout <Nullable<Int32>>
The function execution time at which Lambda should terminate the function. Because the execution time has cost implications, we recommend you set this value based on your expected execution time. The default is 3 seconds. Valid range: Minimum value of 1. Maximum value of 300.
Required?False
Position?Named
Accept pipeline input?False
-VersionId <String>
Optional version ID of the Amazon S3 object (the deployment package) you want to upload to Lambda.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-VpcConfig_SecurityGroupId <String[]>
If your Lambda function accesses resources in a VPC, you provide this parameter identifying the list of security group IDs. The security groups and subnets specified via the VpcConfig_SubnetId parameter must belong to the same VPC. If you specify one or more security groups you must also provide at least one subnet ID.A list of one or more security groups IDs in your VPC.
Required?False
Position?Named
Accept pipeline input?False
-VpcConfig_SubnetId <String[]>
If your Lambda function accesses resources in a VPC, you provide this parameter identifying the list of subnet IDs. The security groups and subnets specified via the VpcConfig_SecurityGroupId parameter must belong to the same VPC. If you specify one or more subnets you must also provide at least one security group ID.A list of one or more subnet IDs in your VPC.
Required?False
Position?Named
Accept pipeline input?False
-ZipFilename <String>
A file path to the zip file containing your packaged source code.
Required?True
Position?2
Accept pipeline input?False

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required? False
Position? Named
Accept pipeline input? False
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required? False
Position? Named
Accept pipeline input? False
-ProfileLocation <String>

Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)

If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials. Note that the encrypted credential file is not supported on all platforms. It will be skipped when searching for profiles on Windows Nano Server, Mac, and Linux platforms.

If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.

As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.

Required? False
Position? Named
Accept pipeline input? False
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required? False
Position? Named
Accept pipeline input? False
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required? False
Position? Named
Accept pipeline input? False
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required? False
Position? Named
Accept pipeline input? False
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required? False
Position? Named
Accept pipeline input? False
-Region <String>
The system name of the AWS region in which the operation should be invoked. For example, us-east-1, eu-west-1 etc.
Required? False
Position? Named
Accept pipeline input? False
-EndpointUrl <String>

The endpoint to make the call against.

Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.

Required? False
Position? Named
Accept pipeline input? False

Inputs

You can pipe a String object to this cmdlet for the FunctionName parameter.

Outputs

This cmdlet returns an Amazon.Lambda.Model.CreateFunctionResult object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Examples

Example 1

PS C:\> Publish-LMFunction -Description "My C# Lambda Function" `
-FunctionName MyFunction `
-ZipFilename .\MyFunctionBinaries.zip `
-Handler "AssemblyName::Namespace.ClassName::MethodName" `
-Role "arn:aws:iam::123456789012:role/LambdaFullExecRole" `
-Runtime dotnetcore1.0 `
-Environment_Variable @{ "envvar1"="value";"envvar2"="value" }

CodeSha256 : /NgBMd...gq71I=
CodeSize : 214784
DeadLetterConfig :
Description : My C# Lambda Function
Environment : Amazon.Lambda.Model.EnvironmentResponse
FunctionArn : arn:aws:lambda:us-west-2:123456789012:function:ToUpper
FunctionName : MyFunction
Handler : AssemblyName::Namespace.ClassName::MethodName
KMSKeyArn :
LastModified : 2016-12-29T23:50:14.207+0000
MemorySize : 128
Role : arn:aws:iam::123456789012:role/LambdaFullExecRole
Runtime : dotnetcore1.0
Timeout : 3
Version : $LATEST
VpcConfig :
This example creates a new C# (dotnetcore1.0 runtime) function named MyFunction in AWS Lambda, providing the compiled binaries for the function from a zip file on the local file system (relative or absolute paths may be used). C# Lambda functions specify the handler for the function using the designation AssemblyName::Namespace.ClassName::MethodName. You should replace the assembly name (without .dll suffix), namespace, class name and method name parts of the handler spec appropriately. The new function will have environment variables 'envvar1' and 'envvar2' set up from the provided values.

Example 2

PS C:\> Write-S3Object -BucketName mybucket -Key MyFunctionBinaries.zip -File .\MyFunctionBinaries.zip
PS C:\> Publish-LMFunction -Description "My C# Lambda Function" `
-FunctionName MyFunction `
-BucketName mybucket `
-Key MyFunctionBinaries.zip `
-Handler "AssemblyName::Namespace.ClassName::MethodName" `
-Role "arn:aws:iam::123456789012:role/LambdaFullExecRole" `
-Runtime dotnetcore1.0 `
-Environment_Variable @{ "envvar1"="value";"envvar2"="value" }
This example is similar to the previous one except the function binaries are first uploaded to an Amazon S3 bucket (which must be in the same region as the intended Lambda function) and the resulting S3 object is then referenced when creating the function.

Supported Version

AWS Tools for PowerShell: 2.x.y.z