DataDog / datadog-cloudformation-macro

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

Read config from ENV vars #90

Closed pas256 closed 1 year ago

pas256 commented 1 year ago

What does this PR do?

As discussed in #88, this adds the ability to specify configuration via environment variables on the Macro Lambda function.

Resolves #88

Motivation

I wanted to simplify all of my SAM templates and not have each one specify the ARN of the Datadog secret, when it is the same in every region the Macro function is deployed.

Testing Guidelines

The automated tests ensure the order of precedence for configuration is:

  1. Default values
  2. Environment variables specified on the Macro Lambda function
  3. Mappings section or Parameters ... which allows the maximum flexibility.

Additional Notes

One difference from the proposal in #88 is that I didn't have to modify any validation logic. I did this only by modifying the order in which configuration default values are read.

To be sure I didn't break anything in the tags code, I also added a test for that too.

Types of changes

Check all that apply

pas256 commented 1 year ago

Here is my PR @sfirrin. Please let me know if you would like any modifications.

Question: How might I test this in my AWS account before an official release is made?

pas256 commented 1 year ago

Amazing, thank you @sfirrin.

With this being merged now, how long before this is in the official release?

sfirrin commented 1 year ago

👍 It's been released in https://github.com/DataDog/datadog-cloudformation-macro/releases/tag/serverless-macro-0.6.4