DataDog / serverless-plugin-datadog

Serverless plugin to automagically instrument your Lambda functions with Datadog
Apache License 2.0
94 stars 50 forks source link

Show Missing Environment Variables Warning when Running Deploy with --package Option #494

Open ceagan opened 3 months ago

ceagan commented 3 months ago

Expected Behavior

When performing a deploy from a folder generated by running package separately, and specifying monitors in the configuration, the plugin should ensure that the DATADOG_API_KEY and DATADOG_APP_KEY are in the environment.

Actual Behavior

Because the checks for existence of DATADOG_API_KEY and DATADOG_APP_KEY are in the handler attached to lifecycle events that are not triggered for a deploy executed like this, the validation doesn't occur. This causes the monitors code to fail silently.

https://github.com/DataDog/serverless-plugin-datadog/blob/08dfe3b4c69e667f0c0b595c1ea2111d3048f430/src/index.ts#L114

Steps to Reproduce the Problem

  1. Use sls package specifying DATADOG_API_KEY and DATADOG_APP_KEY in the environment.
  2. Run sls deploy --package .serverless without specifying DATADOG_API_KEY and DATADOG_APP_KEY in the environment.

Specifications

TalUsvyatsky commented 3 months ago

@ceagan, thanks for the report. I was able to reproduce the issue, and I've tracked it on our side.