terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
892 stars 662 forks source link

feat: Support additional arguments for docker and entrypoint override #366

Closed AllanBenson001 closed 1 year ago

AllanBenson001 commented 1 year ago

Description

  1. Have added support for additional options to be passed to the docker run command
  2. Have added ability to override the entrypoint in the docker run command

This PR replaces #360. The approach here requires fewer changes to package.py, making it far easier to maintain going forwards.

Motivation and Context

I want to build my lambdas in docker containers (because my build environment might not have the required pre-requisites installed) but I need access to packages in CodeArtifact. Differences in build environments make this slightly more difficult. On build machines builds are run within containers, so I have Docker in Docker issues. On developers machines, Terraform might be running within a container or it might not. Workarounds to cope with these different environments make for some very ugly code.

Therefore, the best option is to make these changes that allow me to pass AWS tokens in as environment variables and run a CodeArtifact login within the container (via the entrypoint) before doing a pip install. I see the need to be able to do things like pass tokens as environment variables or map local config files as volumes as being quite a common scenario for people wanting to get packages from private repositories (e.g. Artifactory), that's why I'm updating this module.

Breaking Changes

None

How Has This Been Tested?

antonbabenko commented 1 year ago

Looks good. Could you please resolve merge conflicts?

AllanBenson001 commented 1 year ago

Conflicts resolved 👍

antonbabenko commented 1 year ago

This PR is included in version 4.5.0 :tada:

AllanBenson001 commented 1 year ago

Thanks for this @antonbabenko Thanks also for adding the fix to my example.

github-actions[bot] commented 1 year ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.