DataDog / datadog-cloudformation-macro

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

Allow the extension layer to be applied separately from the runtime layers #131

Closed TophrC-dd closed 2 months ago

TophrC-dd commented 2 months ago

What does this PR do?

Currently there is no way to deploy with the cloudformation macro and only apply the extension. This PR adds this ability when the user sets addLayers to false the extension will still be applied. To override this feature a new configuration option has been made called 'addExtension. This defaults totrue` ensuring the extension layer is applied.

Motivation

Currently if a customer is providing their own lambda libraries (dd-trace, datadog-lambda-js) there is no way to exclude these layers from the deployment and still retain the extension layer. This adds that functionality for this edge case.

Testing Guidelines

In addition to the unit tests i used the release tool to upload my changes to a staging bucket that hosted the macro. Which i deployed to a sandbox aws environment and then created a new function using the macro. I had set addLayers to false along with leaving addExtension to default. This produced a lambda with just the extension layer.

I then modified my template.yaml file to set addExtension to false this resulted in no lambda's being added.

Additional Notes

I did not increment the version number in the template yaml file.

One thing to consider is that users that have addLayers to false today and redeploy the macro will see a change in the expected behavior.

Types of changes

Check all that apply

sawilde commented 2 months ago

extensionLayerVersion has always been optional as you don't need it if you are pushing your logs to cloudwatch and then using the cloudwatch forwarder.