Coder Social home page Coder Social logo

anthonysanoja23 / terraform-aws-lambda-scheduler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uridium/terraform-aws-lambda-scheduler

0.0 0.0 0.0 128 KB

Terraform AWS module which creates Lambda resource with attached CloudWatch scheduler

License: MIT License

HCL 100.00%

terraform-aws-lambda-scheduler's Introduction

Terraform AWS Lambda module: scheduler/cron

GitHub Actions Latest tag

Terraform AWS module which creates Lambda resource with attached CloudWatch scheduler.

It integrates Lambda function with CloudWatch cron expression using EventBridge.

Simply put, thanks to this module, you can schedule your code to run at a specific time.

Usage

module "cron" {
  source = "[email protected]:uridium/terraform-aws-lambda-scheduler.git"

  function_name = "plower"
  handler       = "lambda.handler"
  runtime       = "python3.9"

  layer_enabled = true

  code_directory = "/opt/lambda"

  input = "{\"firstName\": \"John\", \"lastName\": \"Doe\"}"

  vars = {
    foo = "bar"
  }

  tags = {
    Env = "Stage"
  }

  cron = "cron(01 06 ? * MON-FRI *)"
}

Development

This module uses pre-commit hook to identify simple issues before pushing code to the remote repository, and relies on .pre-commit-config.yaml file.

To use it simply run:

pip install pre-commit
pre-commit install

Now pre-commit will run automatically on every git commit.

Notes

  • code_directory specifies a directory where you keep your entire Lambda code
  • If you want to create a layer, simply put it into layer/<runtime> directory and set layer_enabled to true

Examples

Requirements

Name Version
terraform >= 1.2
archive >= 2.2.0
aws >= 4.0

Resources

Name Type
aws_cloudwatch_event_rule.this resource
aws_cloudwatch_event_target.this resource
aws_cloudwatch_log_group.this resource
aws_iam_role.this resource
aws_iam_role_policy_attachment.lambda resource
aws_iam_role_policy_attachment.xray resource
aws_lambda_function.this resource
aws_lambda_layer_version.this resource
aws_lambda_permission.this resource
archive_file.function_zip data source
archive_file.layer_zip data source
aws_iam_policy_document.this data source

Inputs

Name Description Type Default Required
code_directory A relative or full path to the directory with your Lambda Function (and Layer if you use it) code. For example: /opt/lambda string n/a yes
cron The scheduling expression. For example: cron(0 20 * * ? *) or rate(5 minutes) string n/a yes
description Description of what your Lambda Function does string "Generated by Terraform" no
function_name A unique name for your Lambda Function string n/a yes
handler The function entrypoint in your code string n/a yes
input Valid JSON text passed to the target string null no
layer_enabled Create a Lambda Layer Version resource bool false no
memory_size The amount of memory in MB your Lambda Function can use at runtime number 128 no
runtime The identifier of the function's runtime string n/a yes
security_group_ids A list of security group IDs associated with the Lambda function list(string) [] no
subnet_ids A list of subnet IDs associated with the Lambda function list(string) [] no
tags A map of tags to assign to the object map(string) null no
timeout The amount of time your Lambda Function has to run in seconds number 3 no
tracing_mode Define X-Ray tracing mode to record timing and error information for a subset of invocations string "PassThrough" no
vars The Lambda environment's configuration settings map(string) null no

Outputs

Name Description
lambda_function_arn The ARN of the Lambda Function
lambda_function_filename The filename of the function zip archive
lambda_function_handler The filename.handler-method value in your function
lambda_function_last_modified The time when the Lambda Function was modified
lambda_function_name The name of the Lambda Function
lambda_function_role IAM role attached to the Lambda Function
lambda_function_runtime The identifier of the Lambda Function's runtime
lambda_function_source_code_hash A base64-encoded SHA256 hash of the package file
lambda_function_source_code_size The size in bytes of the function .zip file
lambda_function_version Latest published version of your Lambda Function
lambda_function_vpc_config A list of subnets and security groups associated tiwht the Lambda Function
lambda_layer_filename The filename of the layer zip archive

terraform-aws-lambda-scheduler's People

Contributors

uridium avatar actions-user avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.