DataDog / datadog-cloudformation-macro

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

Use AWS SDK to create log groups and subscription filters #7

Closed hannah-sun closed 4 years ago

hannah-sun commented 4 years ago

What does this PR do?

For customers who provide forwarderArn, create log groups and subscription filters through AWS SDK createLogGroup and putSubscriptionFilter instead of adding declarations to the CloudFormation template.

Motivation

Currently, customers who are deploying their Lambdas for the first time will run into potential issues in later deployments. When the macro creates a log group and subscription filter by adding declarations to the template, this works fine the first time, but for later deployments, applying the macro again will result in those resources being deleted. This is because we currently have no way to determine which log groups were created by the macro. (If a log group was created by a macro in a previous iteration, we should add the declaration again to make sure it doesn't get removed.) This solution removes template declarations and uses AWS SDK to create these resources.

Limitation: using the AWS SDK to create the log group requires customers to provide the optional FunctionName parameter. For more details, see the Jira ticket.

Testing Guidelines

Modified unit tests and tested with deployments for both SAM and CDK in sandbox account.

Types of changes