Allow use to easily deploy AWS Lambda functions with Terraform.
- Deploy AWS API Gateway
- Associate Authorizer to API Gateway
- Deploy AWS Lambda function
- Bind AWS Lambda function to API Gateway
- Bind AWS Lambda function to SQS queue
- Bind AWS Lambda function to IoT rule
- Bind AWS Lambda function to Cron event
module "easy-lamb" {
source = "URL"
version = "LAST_RELEASE_VERSION"
project_name = "easy-lamb-api"
aws_region = "eu-west-1"
environment = "prod"
functions = [
{
name = "get-user-data"
memory = 128
timeout = 30
source = "dist/get-user-data"
handler = "get-user-data.handler"
runtime = "nodejs18.x"
http = true
http_method = "GET"
http_path = "/users/{userId}"
description = "Retrieve user data by user ID"
}
]
}
- Clone the repository
- Edit the file providers.tf
- Create a file variables.tf based on the example below
Vous trouverez un exemple d'utilisation du module dans le répertoire examples.
This documentation is generated using terraform-docs. Please do not edit it manually.
Name | Version |
---|---|
archive | ~> 2.0 |
aws | ~> 5.0 |
local | ~> 2.1 |
Name | Source | Version |
---|---|---|
api_gateway | ./modules/api_gateway | n/a |
cron | ./modules/cron-lambda | n/a |
http | ./modules/http-lambda | n/a |
iot | ./modules/iot-lambda | n/a |
lambda | ./modules/lambda | n/a |
sqs | ./modules/sqs-lambda | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
api_gateway | api_gateway = { cors = { allow_origins = "The origins to allow" allow_methods = "The methods to allow" allow_headers = "The headers to allow" } authorizer = { name = "The name of the authorizer" audience = "The audience for the authorizer" issuer = "The issuer for the authorizer" identity_sources = "The identity sources for the authorizer" } log_retention = "The number of days to retain logs for" } |
object({ |
n/a | yes |
aws_region | The AWS region to deploy to | string |
n/a | yes |
environment | The environment to deploy to | string |
n/a | yes |
functions | functions = { name = "the name of the function" description = "The description of the function" memory = "The amount of memory to allocate to the function (https://docs.aws.amazon.com/lambda/latest/dg/limits.html)" timeout = "The amount of time the function has to run (https://docs.aws.amazon.com/lambda/latest/dg/limits.html) source = "The path to the source code for the function (ex: dist/hello)" handler = "The name of the handler function in the source code (ex: fileName.functionName)" runtime = "The runtime to use for the function (https://docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html#SSS-CreateFunction-request-Runtime)" http = "Whether the function is an HTTP function, if true bind to an HTTP API Gateway with values from httpMethod, httpPath and authorizer" http_method = "The HTTP method to bind to the function (ex: GET)" http_path = "The HTTP path to bind to the function (ex: /hello)" authorizer = "The name of the authorizer to use for the function" mqtt = "Whether the function is an MQTT function, if true bind to an MQTT topic with values from mqttSql" mqtt_sql = "The MQTT SQL to bind to the function (ex: SELECT * FROM 'topic')" sqs = "Whether the function is an SQS function, if true bind to an SQS queue sqs_listeners = "The names of the SQS queues to bind to the function (ex: ['mysuper-function-name'])" cron = "The cron expression to trigger the function (ex: 0 23 * * ? *)" log_retention = "The number of days to retain logs for" environment = "The environment variables to set for the function" assume_roles = "The roles to assume for the function" policies = "The policies to attach to the function" override_env = "Read .env file and add values to environment" } |
list(object({ |
n/a | yes |
output_zip_dir | The directory to output the zip files to | string |
"dist" |
no |
project_name | The name of the project | string |
n/a | yes |