App Files

As part of lono cfn deploy, the in the app/files folder can get zipped and uploaded to the lono managed s3 bucket. The files only get uploaded if they are referenced in your template with the file_s3_url.

Lambda Function Example

The app/files are particularly useful for Lambda function resources. Example:

resource("Function", "AWS::Lambda::Function",
  Code: {
    S3Bucket: s3_bucket,
    S3Key: file_s3_key("index.rb"),
  Handler: "index.lambda_handler",
  Role: get_att("LambdaExecutionRole.Arn"),
  Runtime: "ruby2.5",
  Timeout: "300"

You can then define the source code for the lambda function in app/files. Example:


def lambda_handler(event:, context:)
  puts "hello"

Lono will zip up the file in a package that works with Lambda.

Zipping Folders

If pass file_s3_key a folder instead of a file, lono will zip up the entire contents within the folder.

ERB Support

ERB is supported in app files. To activate ERB support, add a .tt extension to the file name. Lono will process the .tt files as ERB files and the .tt extension will be removed from the resulting final file. Example:


require 'json'

def lambda_handler(event:, context:)
  # <%= "comment is from erb" %>
  { statusCode: 200, body: JSON.generate('Hello from Lambda!') }

Results in:


require 'json'

def lambda_handler(event:, context:)
  # comment is from erb
  { statusCode: 200, body: JSON.generate('Hello from Lambda!') }

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!