DataDog / datadog-cloudformation-macro

CloudFormation Macros by Datadog
Apache License 2.0
14 stars 22 forks source link

Datadog macro removes DD_LAMBDA_HANDLER from container image lambdas #108

Closed vieirai closed 9 months ago

vieirai commented 1 year ago

Expected Behavior

Datadog macro does not modify container image lambdas

Actual Behavior

Datadog macro modifies the environment variables of container image lambdas

Steps to Reproduce the Problem

  1. Have a SAM project with container image lambda and normal lambdas
  2. Add the datadog macro for transforming the normal lambdas
  3. Follow the steps in the docs to add the datadog extension to container image lambda
  4. Observe the DD_LAMBDA_HANDLER environment variable disappearing for the container image lambda

Specifications

For the Datadog Serverless Macro:

Stacktrace

This is the error message we get from the container image lambda, as the DD_LAMBDA_HANDLER environment variable was removed.

  [ERROR] HandlerError: DD_LAMBDA_HANDLER is not defined. Can't use prebuilt datadog handler
Traceback (most recent call last):
  File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/lang/lib/python3.8/site-packages/datadog_lambda/handler.py", line 20, in <module>
    raise HandlerError(
duncanpharvey commented 9 months ago

Hi @vieirai, thanks for reporting this! We released a fix that resolves this error in v0.11.0. https://github.com/DataDog/datadog-cloudformation-macro/releases/tag/serverless-macro-0.11.0

Please reopen this issue or open a new issue if you continue to encounter errors.