IN THIS ARTICLE
Lambda Language Support in the Cloud Gem Framework
Lambda Language Support in the Cloud Gem Framework
Lumberyard has support for Lambda deployment packages that include Lambda functions written in Node.js, Python 3.7 or later, Java, Go, or the .NET framework.
To add a non-Python Lambda function to a cloud gem
Add a new Lambda function and Lambda configuration to the
Resources
block of yourresource_template.json
file.The following example shows the entries for the .NET Lambda function in the
resource_template.json
file of the AWS Lambda Language Demo cloud gem.[ … ] "Resources": { "AccessControl": { "DependsOn": [ "PythonLambda", "JavaJarLambda", "DotnetLambda", "GoLambda", "NodeLambda" ], "Properties": { "ConfigurationBucket": { "Ref": "ConfigurationBucket" }, "ConfigurationKey": { "Ref": "ConfigurationKey" }, "ServiceToken": { "Ref": "ProjectResourceHandler" } }, "Type": "Custom::AccessControl" }, [ … ] "DotnetLambda": { "Properties": { "Code": { "S3Bucket": { "Fn::GetAtt": [ "DotnetLambdaConfiguration", "ConfigurationBucket" ] }, "S3Key": { "Fn::GetAtt": [ "DotnetLambdaConfiguration", "ConfigurationKey" ] } }, "Handler": "DotnetLambda::DotnetLambda.Function::FunctionHandler", "Role": { "Fn::GetAtt": [ "DotnetLambdaConfiguration", "Role" ] }, "Environment": { "Variables": { "Fn::GetAtt": [ "DotnetLambdaConfiguration", "CCSettings" ] } }, "Runtime": { "Fn::GetAtt": [ "DotnetLambdaConfiguration", "Runtime" ] } }, "Type": "AWS::Lambda::Function" }, "DotnetLambdaConfiguration": { "Properties": { "ConfigurationBucket": { "Ref": "ConfigurationBucket" }, "ConfigurationKey": { "Ref": "ConfigurationKey" }, "FunctionName": "DotnetLambda", "Runtime": "dotnetcore1.0", "ServiceToken": { "Ref": "ProjectResourceHandler" } }, "Type": "Custom::LambdaConfiguration" }, [ … ]
Follow the instructions in Creating a Deployment Package to create a Lambda function deployment package for the runtime that you are using.
Use the
FunctionName
property of the function’sLambdaConfiguration
section to name the packaged.zip
or.jar
file.Put the package file (for example,
DotnetLambda.zip
) in thelumberyard_version\dev\Gems\gem_directory\vN\AWS\lambda-code\
directory.
Notes
When you create non-Python Lambda functions for use with Cloud Canvas, note the following:
- The Visual Studio tools for .NET Lambda functions do not generate a Lambda function deployment package automatically. For steps, see .NET Core CLI in the AWS Lambda Developer Guide.
- When you use the
Eclipse IDE and
Apache Maven to build a Java
.jar
package, Maven generates a.jar
file namedproject-SNAPSHOT.jar
. The Cloud Canvas uploader supports this naming convention and theproject.jar
file. - Each runtime has its own format for the
Handler
property. See the following table.
[See the AWS documentation website for more details]
Examples and Sample Level
The AWS Lambda Language Demo cloud gem included with Lumberyard contains skeleton “Hello World” Lambda function examples in Python, Java, .NET, Go, and node.js. You can find the relevant files in the lumberyard_version\dev\Gems\AWSLambdaLanguageDemo\v1\AWS\lambda-code
directory.
Running the Sample Level
The CloudGemSamples project cloud gem includes a sample level named LambdaLanguage that shows Cloud Canvas support for Lambda languages.
Prerequisites
Running the sample requires the following prerequisites:
- You are using Lumberyard version 1.16 or later.
- Your Lumberyard project has the CloudGemSamples project enabled (in the Project Configurator, choose CloudGemSamples).
- You used the
Cloud Canvas Resource Manager or the
lmbr_aws command line tool to create the following:
- A project stack for your project.
- A deployment for your project that includes the AWSLambdaLanguageDemo resource group.
To run the LambdaLanguage sample level
In Lumberyard Editor, choose File, Open or press Ctrl+O.
In the Open a Level dialog box, expand Levels.
Choose LambdaLanguage, and then click Open.
Click Play Game or press Ctrl+G to switch to gameplay mode. After a short pause, a message reports success, as seen in the following image.
Additional Resources
For information on how the sample applications were built, see the following topics in the AWS Lambda Developer Guide .
Sample Application | Resource Page |
---|---|
DotNetLambda | AWS Toolkit for Visual Studio and .NET Core CLI |
GoLambda | Creating a Deployment Package (Go) |
JavajarLambda | Creating a .jar Deployment Package Using Maven and Eclipse IDE (Java) |
NodeLambda | Creating a Deployment Package (Node.js) |