• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Consul
  • Install
  • Tutorials
  • Documentation
  • API
  • CLI
  • Try Cloud(opens in new tab)
  • Sign up
Consul Home

Documentation

Skip to main contentOverview
  • What is Consul?



    • Overview
      • Requirements
      • Automate Registration
      • Manual Registration
    • Invoke Lambda Functions from Services
    • Invoke Services from Lambda Functions
      BETABETA

  • HCP Consul


  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Consul
  3. Documentation
  4. AWS Lambda
  5. Register Lambda Functions
  6. Manual Registration
  • Consul
  • v1.13.x
  • v1.12.x
  • v1.11.x
  • v1.10.x
  • v1.9.x
  • v1.8.x

ยปManual Lambda Function Registration

This topic describes how to manually register Lambda functions into Consul. Refer to Automate Lambda Function Registration for information about using the Lambda registrator to automate registration.

Requirements

Verify that your environment meets the requirements specified in Lambda Function Registration Requirements.

To manually register Lambda functions so that mesh services can invoke them, you must create and apply a service registration configuration for the Lambda function and write a service defaults configuration entry for the function.

Register a Lambda function

You can manually register Lambda functions if you are unable to automate the process using the Lambda registrator.

  1. Create a configuration for registering the service. You can copy the following example and replace <SERVICE_NAME> with your Consul service name for the Lambda function:

    lambda.json
    {
      "Node": "lambdas",
      "SkipNodeUpdate": true,
      "NodeMeta": {
        "external-node": "true",
        "external-probe": "true"
      },
      "Service": {
        "Service": "<SERVICE_NAME>"
      }
    }
    
  2. Save the configuration to lambda.json.

  3. Send the configuration to the catalog/register API endpoint to register the service, for example:

    $ curl --request PUT --data @lambda.json localhost:8500/v1/catalog/register
    
  4. Create the service-defaults configuration entry and include the AWS tags used to invoke the Lambda function in the Meta field (refer to Supported Meta fields. The following example creates a service-defaults configuration entry named lambda:

    lambda-service-defaults.hcl
    Kind = "service-defaults"
    Name = "lambda"
    Protocol  = "http"
    Meta = {
      "serverless.consul.hashicorp.com/v1alpha1/lambda/enabled" = "true"
      "serverless.consul.hashicorp.com/v1alpha1/lambda/arn" = "<INSERT ARN HERE>"
      "serverless.consul.hashicorp.com/v1alpha1/lambda/payload-passthrough" = "true"
      "serverless.consul.hashicorp.com/v1alpha1/lambda/region" = "us-east-2"
    }
    
  5. Issue the consul config write command to store the configuration entry. For example:

    $ consul config write lambda-service-defaults.hcl
    

Supported Meta fields

The following tags are supported. The path prefix for all tags is serverless.consul.hashicorp.com/v1alpha1/lambda. For example, specify the following tag to enable Consul to configure the service as an AWS Lambda function:

serverless.consul.hashicorp.com/v1alpha1/lambda/enabled.

TagDescription
<prefix-path>/enabledDetermines if Consul configures the service as an AWS Lambda.
<prefix-path>/payload-passthroughDetermines if the body Envoy receives is converted to JSON or directly passed to Lambda.
<prefix-path>/arnSpecifies the AWS ARN for the service's Lambda.
<prefix-path>/invocation-modeDetermines if Consul configures the Lambda to be invoked using the synchronous or asynchronous invocation mode.
<prefix-path>/regionSpecifies the AWS region the Lambda is running in.
Edit this page on GitHub

On this page

  1. Manual Lambda Function Registration
  2. Requirements
  3. Register a Lambda function
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)