<- All Blueprints
Customizable templates for deploying cloud infrastructure

AWS Lambda Function

This blueprint creates an AWS Lambda function following best practices, such as setting a default runtime environment (Python 3.8) and handler, enabling secure configuration by requiring an IAM role, and encouraging the use of tags for resource identification and management. It allows customization of memory size and timeout for performance tuning and supports the inclusion of environment variables to provide flexibility for various use cases.

Define and customize Blueprints to set what infrastructure configuration options are available to developers.

---
constants:
  __name: "{{ name }}_{{ __guid }}"
variables:
  name:
    desc: "Name of the Lambda function."
    required: true
    group: Lambda Function Details
  runtime:
    desc: "Runtime environment for the Lambda function (e.g., 'python3.8')."
    required: true
    group: Lambda Function Details
    default: "python3.8"
  handler:
    desc: "Function handler in the code (e.g., 'index.handler')."
    required: true
    group: Lambda Function Details
    default: "lambda_function.lambda_handler"
  filename:
    desc: "Path to the deployment package within the local filesystem."
    required: true
    group: Code
  source_code_hash:
    desc: "Base64-encoded SHA256 hash of the package file specified by filename."
    required: false
    group: Code
    advanced: true
  role:
    desc: "IAM role ARN that the Lambda function assumes."
    required: true
    group: Permissions
    links_to: resource.aws_iam_role.arn
  memory_size:
    desc: "Amount of memory in MB your Lambda Function can use at runtime."
    required: false
    group: Lambda Function Details
    default: 128
  timeout:
    desc: "The amount of time your Lambda Function has to run in seconds."
    required: false
    group: Lambda Function Details
    default: 3
  environment_variables:
    group: Environment Variables
    required: false
  tags:
    group: Tags
    required: false
groups:
  Lambda Function Details:
    order: 1
    desc: "Basic settings for the Lambda function."
  Code:
    order: 2
    desc: "Code deployment settings."
  Permissions:
    order: 3
    desc: "Permissions for the Lambda function."
  Environment Variables:
    order: 4
    desc: "Environment variables for the Lambda function."
  Tags:
    order: 5
    desc: "Tags to assign to the Lambda function."
---

resource "aws_lambda_function" "__name" {
  function_name = {{ name }}
  runtime       = {{ runtime }}
  handler       = {{ handler }}
  filename      = {{ filename }}
  source_code_hash = {{ source_code_hash | required: false | advanced: true }}
  role          = {{ role }}

  memory_size = {{ memory_size }}
  timeout     = {{ timeout }}

  {{# environment_variables }}
  environment {
    variables = {
      {{ environment_variables.key | required: false }} = {{ environment_variables.value | required: false }}
    }
  }
  {{/ environment_variables }}

  tags = {
    Name = {{ name }}
    {{# tags }}
      {{ tags.key | required: false }} = {{ tags.value | required: false }}
    {{/ tags }}
  }
}

// The Lambda function is configured with a default runtime of Python 3.8 and default handler.
// Memory size and timeout are set to default values but can be customized.
// Tags are encouraged for resource identification and management.
// Environment variables can be specified as needed.
// The IAM role is required and should have the necessary permissions.
//
A form is created automatically that accepts inputs that you defined in the Blueprint.
After filling out the Blueprint form, Terraform is generated and a PR is automatically submitted.
What am I looking at?

Talk to a Human

See Resourcely in action and learn how it can help you secure and manage your cloud infrastructure today!