{"id":21202493,"url":"https://github.com/infrablocks/terraform-aws-lambda","last_synced_at":"2025-06-12T08:33:08.520Z","repository":{"id":38325481,"uuid":"196584757","full_name":"infrablocks/terraform-aws-lambda","owner":"infrablocks","description":"Terraform module to create a lambda in a pre-existing VPC","archived":false,"fork":false,"pushed_at":"2025-04-04T02:15:46.000Z","size":611,"stargazers_count":3,"open_issues_count":3,"forks_count":5,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-05T11:34:33.109Z","etag":null,"topics":["aws","aws-lambda","infrastructure","lambda","terraform","terraform-modules"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infrablocks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security_group.tf","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-12T13:33:19.000Z","updated_at":"2025-02-12T09:49:03.000Z","dependencies_parsed_at":"2023-02-14T13:15:28.348Z","dependency_job_id":"46b6e41f-5ad3-48da-a375-891b7fc172cd","html_url":"https://github.com/infrablocks/terraform-aws-lambda","commit_stats":null,"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"purl":"pkg:github/infrablocks/terraform-aws-lambda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infrablocks","download_url":"https://codeload.github.com/infrablocks/terraform-aws-lambda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-lambda/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259430106,"owners_count":22856187,"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","aws-lambda","infrastructure","lambda","terraform","terraform-modules"],"created_at":"2024-11-20T20:16:12.076Z","updated_at":"2025-06-12T08:33:08.495Z","avatar_url":"https://github.com/infrablocks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Terraform AWS Lambda\n===================================\n\n[![CircleCI](https://circleci.com/gh/infrablocks/terraform-aws-lambda.svg?style=svg)](https://circleci.com/gh/infrablocks/terraform-aws-lambda)\n\nA Terraform module for creating a new lambda\n\nThe lambda module requires:\n\n* A lambda function packaged as zip\n\nThe lambda resource consists of:\n\n- lambda function\n- security group for lambda\n- iam role for executing lambda\n- iam policy for lambda\n\nUsage\n-----\n\nTo use the module, include something like the following in your Terraform\nconfiguration:\n\n```hcl-terraform\nmodule \"lambda\" {\n  source                       = \"infrablocks/lambda/aws\"\n  region                       = \"eu-west-2\"\n  component                    = \"my-lambda\"\n  deployment_identifier        = \"development-europe\"\n  include_vpc_access           = true\n  vpc_id                       = \"VPC-1234\"\n  lambda_subnet_ids            = [\"subnet-id-1\"]\n  lambda_zip_path              = \"lambda.zip\"\n  lambda_ingress_cidr_blocks   = [\"10.10.0.0/16\"]\n  lambda_egress_cidr_blocks    = [\"0.0.0.0/8\"]\n  lambda_environment_variables = {\n    \"TEST_ENV_VARIABLE\" = \"test-value\"\n  }\n  lambda_function_name         = \"lambda-function\"\n  lambda_handler               = \"handler.hello\"\n  lambda_description           = \"An optional description\"\n  tags                         = {\n    \"AdditionalTags\" = \"my-tag\"\n  }\n  lambda_execution_role_policy = jsonencode(\n    {\n      \"Version\" : \"2012-10-17\",\n      \"Statement\" : [\n        {\n          \"Effect\" : \"Allow\",\n          \"Action\" : [\n            \"logs:DescribeLogGroups\",\n            \"logs:DescribeLogStreams\",\n            \"logs:CreateLogStream\",\n            \"logs:DeleteLogStream\",\n            \"logs:FilterLogEvents\",\n            \"logs:GetLogEvents\",\n            \"logs:PutLogEvents\",\n          ],\n          \"Resource\" : [\n            \"arn:aws:logs:${var.region}:${data.aws_caller_identity.current.account_id}:*\"\n          ]\n        },\n        {\n          \"Effect\" : \"Allow\",\n          \"Action\" : [\n            \"sns:Publish\"\n          ],\n          \"Resource\" : [\n            \"arn:aws:sns:${var.region}:${data.aws_caller_identity.current.account_id}:*\"\n          ]\n        }\n      ]\n    })\n}\n```\n\nSee the\n[Terraform registry entry](https://registry.terraform.io/modules/infrablocks/lambda/aws/latest)\nfor more details.\n\n### Inputs\n\n| Name                                  | Description                                                       | Default | Required |\n|---------------------------------------|-------------------------------------------------------------------|:-------:|:--------:|\n| region                                | AWS Region                                                        |    -    |   yes    |\n| component                             | The component for which the load balancer is being created        |    -    |   yes    |\n| deployment_identifier                 | An identifier for this instantiation                              |    -    |   yes    |\n| deployment_label                      | A unique label per deployment                                     |    -    |   yes    |\n| deployment_type                       | The type of deployment, e.g. development, production              |    -    |   yes    |\n| account_id                            | AWS account ID                                                    |    -    |   yes    |\n| vpc_id                                | VPC to deploy lambda to                                           |    -    |   yes    |\n| include_vpc_access                    | A flag to enable VPC access                                       |  false  |    no    |\n| tags                                  | The AWS tags to use for any deployed resources                    |    -    |    no    |\n| lambda_subnet_ids                     | subnet ids for the lambda                                         |    -    |   yes    |\n| lambda_zip_path                       | location of your lambda zip archive                               |    -    |   yes    |\n| lambda_ingress_cidr_blocks            | ingress CIDR for lambda                                           |    -    |   yes    |\n| lambda_egress_cidr_blocks             | egress CIDR for lambda                                            |    -    |   yes    |\n| lambda_function_name                  | lambda function name                                              |    -    |   yes    |\n| lambda_handler                        | handler path for lambda                                           |    -    |   yes    |\n| lambda_environment_variables          | environment variables for lambda                                  |    -    |   yes    |\n| lambda_execution_role_policy          | An inline policy to use for the lambda                            |    -    |    no    |\n| lambda_description                    | A description to use for the lambda                               |    -    |    no    | \n| lambda_reserved_concurrent_executions | Amount of reserved concurrent executions for this lambda function |   -1    |    no    | \n\n### Outputs\n\n| Name                    | Description                                                                                                        |\n|-------------------------|--------------------------------------------------------------------------------------------------------------------|\n| lambda_invoke_arn       | The ARN to be used for invoking Lambda Function from API Gateway - to be used in aws_api_gateway_integration's uri |\n| lambda_arn              | The Amazon Resource Name (ARN) identifying your Lambda Function.                                                   |\n| lambda_function_name    | function name of the lambda                                                                                        |\n| lambda_function_name    | function name of the lambda                                                                                        |\n| lambda_handler          | The handler of the lambda                                                                                          |\n| lambda_last_modified    | The date this resource was last modified                                                                           |\n| lambda_id               | The id of the lambda                                                                                               |\n| lambda_memory_size      | The allocated memory size of the lambda                                                                            |\n| lambda_runtime          | The runtime environment of the lambda                                                                              |\n| lambda_source_code_hash | Base64-encoded representation of raw SHA-256 sum of the zip file, provided either via filename or s3_* parameters. |\n| lambda_source_code_size | The size in bytes of the function .zip file.                                                                       |\n| lambda_version          | Latest published version of your Lambda Function                                                                   |\n\n### Compatibility\n\nThis module is compatible with Terraform versions greater than or equal to\nTerraform 1.1.\n\n### VPC Access\n\nBy default, the module deploys the lambda without any access to resources in a\nVPC. If `include_vpc_access` is set to `true` then the AWS lambda will be\ndeployed with access to the VPC identified by `vpc_id`, via the provided\n`lambda_subnet_ids`.\n\n### Execution IAM Policy\n\nIf you want to customise the execution policy for the lambda then you can\noptionally supply an inline policy via the `lambda_execution_policy` variable.\n\nBe sure to include the permissions listed in the default policy so that the\nlambda can be created successfully, see `lambda_execution_policy` for the\ndefault policy.\n\n### Tags\n\nThe module deploys `Component`, `DeploymentType`, `DeploymentLabel` and\n`DeploymentIdentifier` tags for any created infrastructure by default.\nAdditional tags can be optionally passed in via the `tags` input variable,\nwhich will then be merged together with the default tags.\n\nDevelopment\n-----------\n\n### Machine Requirements\n\nIn order for the build to run correctly, a few tools will need to be installed\non your development machine:\n\n* Ruby (3.1.1)\n* Bundler\n* git\n* git-crypt\n* gnupg\n* direnv\n* aws-vault\n\n#### Mac OS X Setup\n\nInstalling the required tools is best managed by [homebrew](http://brew.sh).\n\nTo install homebrew:\n\n```\nruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\nThen, to install the required tools:\n\n```\n# ruby\nbrew install rbenv\nbrew install ruby-build\necho 'eval \"$(rbenv init - bash)\"' \u003e\u003e ~/.bash_profile\necho 'eval \"$(rbenv init - zsh)\"' \u003e\u003e ~/.zshrc\neval \"$(rbenv init -)\"\nrbenv install 3.1.1\nrbenv rehash\nrbenv local 3.1.1\ngem install bundler\n\n# git, git-crypt, gnupg\nbrew install git\nbrew install git-crypt\nbrew install gnupg\n\n# aws-vault\nbrew cask install\n\n# direnv\nbrew install direnv\necho \"$(direnv hook bash)\" \u003e\u003e ~/.bash_profile\necho \"$(direnv hook zsh)\" \u003e\u003e ~/.zshrc\neval \"$(direnv hook $SHELL)\"\n\ndirenv allow \u003crepository-directory\u003e\n```\n\n### Running the build\n\nRunning the build requires an AWS account and AWS credentials. You are free to\nconfigure credentials however you like as long as an access key ID and secret\naccess key are available. These instructions utilise\n[aws-vault](https://github.com/99designs/aws-vault) which makes credential\nmanagement easy and secure.\n\nTo provision module infrastructure, run tests and then destroy that\ninfrastructure, execute:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go\n```\n\nTo provision the module prerequisites:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo provision the module contents:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module contents:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:destroy[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module prerequisites:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:destroy[\u003cdeployment_identifier\u003e]\n```\n\nConfiguration parameters can be overridden via environment variables:\n\n```bash\nDEPLOYMENT_IDENTIFIER=testing aws-vault exec \u003cprofile\u003e -- ./go\n```\n\nWhen a deployment identifier is provided via an environment variable,\ninfrastructure will not be destroyed at the end of test execution. This can\nbe useful during development to avoid lengthy provision and destroy cycles.\n\nBy default, providers will be downloaded for each terraform execution. To\ncache providers between calls:\n\n```bash\nTF_PLUGIN_CACHE_DIR=\"$HOME/.terraform.d/plugin-cache\" aws-vault exec \u003cprofile\u003e -- ./go\n```\n\n### Common Tasks\n\n#### Generating an SSH key pair\n\nTo generate an SSH key pair:\n\n```\nssh-keygen -m PEM -t rsa -b 4096 -C integration-test@example.com -N '' -f config/secrets/keys/bastion/ssh\n```\n\n#### Generating a self-signed certificate\n\nTo generate a self signed certificate:\n\n```\nopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365\n```\n\nTo decrypt the resulting key:\n\n```\nopenssl rsa -in key.pem -out ssl.key\n```\n\n#### Managing CircleCI keys\n\nTo encrypt a GPG key for use by CircleCI:\n\n```bash\nopenssl aes-256-cbc \\\n  -e \\\n  -md sha1 \\\n  -in ./config/secrets/ci/gpg.private \\\n  -out ./.circleci/gpg.private.enc \\\n  -k \"\u003cpassphrase\u003e\"\n```\n\nTo check decryption is working correctly:\n\n```bash\nopenssl aes-256-cbc \\\n  -d \\\n  -md sha1 \\\n  -in ./.circleci/gpg.private.enc \\\n  -k \"\u003cpassphrase\u003e\"\n```\n\nContributing\n------------\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/infrablocks/terraform-aws-lambda. This project is intended to\nbe a safe, welcoming space for collaboration, and contributors are expected to\nadhere to the [Contributor Covenant](http://contributor-covenant.org) code of\nconduct.\n\nLicense\n-------\n\nThe library is available as open source under the terms of the\n[MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrablocks%2Fterraform-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfrablocks%2Fterraform-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrablocks%2Fterraform-aws-lambda/lists"}