{"id":21725426,"url":"https://github.com/jameswoolfenden/terraform-aws-lambda","last_synced_at":"2026-05-06T22:34:24.509Z","repository":{"id":41079205,"uuid":"251428303","full_name":"JamesWoolfenden/terraform-aws-lambda","owner":"JamesWoolfenden","description":"Basic lambda module","archived":false,"fork":false,"pushed_at":"2022-09-20T12:54:30.000Z","size":102,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T19:27:52.424Z","etag":null,"topics":["aws","module","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamesWoolfenden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2020-03-30T21:06:13.000Z","updated_at":"2023-02-01T09:11:05.000Z","dependencies_parsed_at":"2023-01-18T10:37:07.690Z","dependency_job_id":null,"html_url":"https://github.com/JamesWoolfenden/terraform-aws-lambda","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesWoolfenden%2Fterraform-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesWoolfenden","download_url":"https://codeload.github.com/JamesWoolfenden/terraform-aws-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244706500,"owners_count":20496570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","module","terraform"],"created_at":"2024-11-26T03:17:34.896Z","updated_at":"2026-05-06T22:34:24.483Z","avatar_url":"https://github.com/JamesWoolfenden.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terraform-aws-lambda\n\n[![Build Status](https://github.com/JamesWoolfenden/terraform-aws-lambda/workflows/Verify%20and%20Bump/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-aws-lambda)\n[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-aws-lambda.svg)](https://github.com/JamesWoolfenden/terraform-aws-lambda/releases/latest)\n[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-aws-lambda.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-aws-lambda/releases/latest)\n![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-aws-lambda/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-lambda\u0026benchmark=CIS+AWS+V1.2)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)\n[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-aws-lambda/general)](https://www.bridgecrew.cloud/link/badge?vcs=github\u0026fullRepo=JamesWoolfenden%2Fterraform-aws-lambda\u0026benchmark=INFRASTRUCTURE+SECURITY)\n\n---\n\nMinimal Terraform module.\n\n---\n\nIt's 100% Open Source and licensed under the [APACHE2](LICENSE).\n\n## Usage\n\nThis is a minimal example **examplea**, but with Cloudwatch alarms enabled.\n\n```hcl\nmodule \"lambda\" {\n  source = \"github.com/jameswoolfenden/terraform-aws-lambda\"\n  version= \"0.3.40\"\n  account_id     = data.aws_caller_identity.current.account_id\n  alarms_enabled = true\n  common_tags    = var.common_tags\n  description    = \"Best Pizza!!\"\n  filename       = \"${path.module}/lambda.zip\"\n  name           = var.name\n  region_name    = data.aws_region.current.name\n  role_arn       = data.aws_iam_role.lambda.arn\n}\n\n```\n\n\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Requirements\n\nNo requirements.\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | n/a |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_iam_policy.basic](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n| [aws_iam_policy.kms](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n| [aws_iam_policy.s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n| [aws_iam_policy.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n| [aws_iam_role.updatepolicy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |\n| [aws_iam_role_policy_attachment.basic-attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n| [aws_iam_role_policy_attachment.kms-attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n| [aws_iam_role_policy_attachment.s3-attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n| [aws_iam_role_policy_attachment.vpc-attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n| [aws_lambda_function.withintent](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |\n| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_action\"\u003e\u003c/a\u003e [action](#input\\_action) | Action for the Lambda permission | `string` | `\"lambda:InvokeFunction\"` | no |\n| \u003ca name=\"input_alarms_enabled\"\u003e\u003c/a\u003e [alarms\\_enabled](#input\\_alarms\\_enabled) | Cloudwatch alarms enabled | `bool` | `false` | no |\n| \u003ca name=\"input_description\"\u003e\u003c/a\u003e [description](#input\\_description) | Of the the Lambda | `string` | n/a | yes |\n| \u003ca name=\"input_envvar\"\u003e\u003c/a\u003e [envvar](#input\\_envvar) | Optional set of environmental variables for the lambda | `map(any)` | `{}` | no |\n| \u003ca name=\"input_ephemeral_storage\"\u003e\u003c/a\u003e [ephemeral\\_storage](#input\\_ephemeral\\_storage) | Storage for lambda Min 512 MB and the Max 10240 MB | `number` | `512` | no |\n| \u003ca name=\"input_filename\"\u003e\u003c/a\u003e [filename](#input\\_filename) | name of zip file if any | `string` | `null` | no |\n| \u003ca name=\"input_handler\"\u003e\u003c/a\u003e [handler](#input\\_handler) | The file the lambda should import | `string` | `\"index.handler\"` | no |\n| \u003ca name=\"input_kms_key_id\"\u003e\u003c/a\u003e [kms\\_key\\_id](#input\\_kms\\_key\\_id) | Your KMS Key ARN | `string` | n/a | yes |\n| \u003ca name=\"input_layers\"\u003e\u003c/a\u003e [layers](#input\\_layers) | Optionally, add in up 5 lambda layers | `list(any)` | `[]` | no |\n| \u003ca name=\"input_memory_size\"\u003e\u003c/a\u003e [memory\\_size](#input\\_memory\\_size) | Of the the lambda | `string` | `\"128\"` | no |\n| \u003ca name=\"input_metric_comparison_operator\"\u003e\u003c/a\u003e [metric\\_comparison\\_operator](#input\\_metric\\_comparison\\_operator) | For Cloudwatch Alarms | `string` | `\"GreaterThanThreshold\"` | no |\n| \u003ca name=\"input_metric_datapoints_to_alarm\"\u003e\u003c/a\u003e [metric\\_datapoints\\_to\\_alarm](#input\\_metric\\_datapoints\\_to\\_alarm) | For Cloudwatch Alarms | `number` | `1` | no |\n| \u003ca name=\"input_metric_evaluation_periods\"\u003e\u003c/a\u003e [metric\\_evaluation\\_periods](#input\\_metric\\_evaluation\\_periods) | For Cloudwatch Alarms | `number` | `1` | no |\n| \u003ca name=\"input_metric_metric_name\"\u003e\u003c/a\u003e [metric\\_metric\\_name](#input\\_metric\\_metric\\_name) | n/a | `string` | `\"Invocations\"` | no |\n| \u003ca name=\"input_metric_period\"\u003e\u003c/a\u003e [metric\\_period](#input\\_metric\\_period) | n/a | `number` | `300` | no |\n| \u003ca name=\"input_metric_statistic\"\u003e\u003c/a\u003e [metric\\_statistic](#input\\_metric\\_statistic) | n/a | `string` | `\"Average\"` | no |\n| \u003ca name=\"input_metric_threshold\"\u003e\u003c/a\u003e [metric\\_threshold](#input\\_metric\\_threshold) | n/a | `number` | `100` | no |\n| \u003ca name=\"input_name\"\u003e\u003c/a\u003e [name](#input\\_name) | Name of Lambda object | `string` | n/a | yes |\n| \u003ca name=\"input_prefixdash\"\u003e\u003c/a\u003e [prefixdash](#input\\_prefixdash) | Support for renaming on multi-environments | `string` | `\"\"` | no |\n| \u003ca name=\"input_region\"\u003e\u003c/a\u003e [region](#input\\_region) | Aws region name, eu-west-1... | `string` | n/a | yes |\n| \u003ca name=\"input_runtime\"\u003e\u003c/a\u003e [runtime](#input\\_runtime) | Language the code runs in | `string` | `\"python3.8\"` | no |\n| \u003ca name=\"input_s3_bucket\"\u003e\u003c/a\u003e [s3\\_bucket](#input\\_s3\\_bucket) | path to the lambda bucket | `string` | `null` | no |\n| \u003ca name=\"input_s3_key\"\u003e\u003c/a\u003e [s3\\_key](#input\\_s3\\_key) | path to the lambda zip | `string` | `null` | no |\n| \u003ca name=\"input_security_group_ids\"\u003e\u003c/a\u003e [security\\_group\\_ids](#input\\_security\\_group\\_ids) | The IDs of some security groups | `list(string)` | `[]` | no |\n| \u003ca name=\"input_subnet_ids\"\u003e\u003c/a\u003e [subnet\\_ids](#input\\_subnet\\_ids) | Subnet IDs... | `list(string)` | `[]` | no |\n| \u003ca name=\"input_timeout\"\u003e\u003c/a\u003e [timeout](#input\\_timeout) | Of the the lambda | `string` | `\"100\"` | no |\n| \u003ca name=\"input_tracing_mode\"\u003e\u003c/a\u003e [tracing\\_mode](#input\\_tracing\\_mode) | Enable X-ray and in what mode Active or PassThrough | `string` | `\"Active\"` | no |\n| \u003ca name=\"input_vpc_config\"\u003e\u003c/a\u003e [vpc\\_config](#input\\_vpc\\_config) | Optional Vpc attachment config | `map(any)` | `{}` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_lambda\"\u003e\u003c/a\u003e [lambda](#output\\_lambda) | n/a |\n| \u003ca name=\"output_role\"\u003e\u003c/a\u003e [role](#output\\_role) | n/a |\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n\n## Policy\n\nThis is the policy required to build this project:\n\n\u003c!-- BEGINNING OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\nThe Terraform resource required is:\n\n```golang\nresource \"aws_iam_policy\" \"terraform_pike\" {\n  name_prefix = \"terraform_pike\"\n  path        = \"/\"\n  description = \"Pike Autogenerated policy from IAC\"\n\n  policy = jsonencode({\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"VisualEditor0\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ec2:DescribeAccountAttributes\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor1\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"iam:AttachRolePolicy\",\n                \"iam:CreatePolicy\",\n                \"iam:CreateRole\",\n                \"iam:DeletePolicy\",\n                \"iam:DeleteRole\",\n                \"iam:DetachRolePolicy\",\n                \"iam:GetPolicy\",\n                \"iam:GetPolicyVersion\",\n                \"iam:GetRole\",\n                \"iam:ListAttachedRolePolicies\",\n                \"iam:ListInstanceProfilesForRole\",\n                \"iam:ListPolicyVersions\",\n                \"iam:ListRolePolicies\",\n                \"iam:PassRole\"\n            ],\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"VisualEditor2\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"lambda:CreateFunction\",\n                \"lambda:DeleteFunction\",\n                \"lambda:GetFunction\",\n                \"lambda:GetFunctionCodeSigningConfig\",\n                \"lambda:ListVersionsByFunction\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n})\n}\n\n\n```\n\u003c!-- END OF PRE-COMMIT-PIKE DOCS HOOK --\u003e\n\n## Further work\n\nIf you provision this lambda inside a VPC and want to call aws services from with it, youmay need to deploy a Private endpoint to support that.\n\nConnection to cloudwatch metric and attach subscription to Slack.\n\nDetermine when ConcurrentExecutions or Invocations exceeds your threshold\n\n- \u003chttps://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-metrics.html\u003e\n  and\n- \u003chttps://aws.amazon.com/blogs/architecture/best-practices-for-developing-on-aws-lambda/?sc_channel=sm\u0026sc_campaign=AWS_Blog\u0026sc_publisher=LINKEDIN\u0026sc_country=Global\u0026sc_geo=GLOBAL\u0026sc_outcome=awareness\u0026trk=AWS_Blog_LINKEDIN\u0026sc_category=AWS_Lambda,AWS+Lambda\u0026linkId=70615743\u003e\n\nand connect up the aws chatbot to slack/bot\n\n- \u003chttps://us-east-2.console.aws.amazon.com/chatbot/home#/\u003e\n- \u003chttps://docs.aws.amazon.com/chatbot/latest/adminguide/setting-up.html\u003e\n\nGeneral:\n\n- \u003chttps://www.concurrencylabs.com/blog/how-to-operate-aws-lambda/\u003e\n- Add support for sns subscriptions.\n- Add in support for keeping lambda warm.\n\nWhat alarms are important:\n\n- \u003chttps://www.concurrencylabs.com/blog/how-to-operate-aws-lambda/\u003e\n- \u003chttps://dev.to/frosnerd/monitoring-aws-lambda-functions-with-cloudwatch-1nap\u003e\n- \u003chttps://aws.amazon.com/blogs/compute/investigating-spikes-in-aws-lambda-function-concurrency/\u003e\n\nRight sizing Lambdas:\n\n- timeouts to close to invocation length\n- no of failed or throttled\n- memory usage - am i over provisioned?\n- memory usage - more tin required?\n- size of payload is related to the start time\n\n## Related Projects\n\nCheck out these related projects.\n\n- [terraform-aws-codecommit](https://github.com/jameswoolfenden/terraform-aws-codecommit) - Storing ones code\n\n## Help\n\n**Got a question?**\n\nFile a GitHub [issue](https://github.com/JamesWoolfenden/terraform-aws-lambda/issues).\n\n## Contributing\n\n### Bug Reports \u0026 Feature Requests\n\nPlease use the [issue tracker](https://github.com/JamesWoolfenden/terraform-aws-lambda/issues) to report any bugs or file feature requests.\n\n## Copyrights\n\nCopyright 2019-2022 James Woolfenden\n\n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nSee [LICENSE](LICENSE) for full details.\n\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n\u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied. See the License for the\nspecific language governing permissions and limitations\nunder the License.\n\n### Contributors\n\n[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]\u003cbr/\u003e[James Woolfenden][jameswoolfenden_homepage]\n\n[jameswoolfenden_homepage]: https://github.com/jameswoolfenden\n[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameswoolfenden%2Fterraform-aws-lambda/lists"}