DataDog / cloudformation-template

Easily set up the Datadog AWS integration using CloudFormation
Apache License 2.0
34 stars 42 forks source link

[AWSMC-954] Fix streams template to pass new AWS template validation #92

Closed ktmq closed 3 months ago

ktmq commented 3 months ago

Note: Please remember to review the contribution guidelines if you have not yet done so.

What does this PR do?

AWS is introducing new validation requirements for their MetricStreams resource that enforces OneOf ExcludeFilters or IncludeFilters. Currently, our template renders each of these Parameters as an empty list [] if no namespaces are set, but this is invalid according to the new logic and results in an error and failed stack creation. This PR updates the conditions to set only one of IncludeFilters and ExcludeFilters depending on the value of FilterMethod, so they will no longer both be set to [] when no namespaces are specified.

Motivation

https://datadoghq.atlassian.net/browse/AWSMC-954

The streams stack currently fails to create with the following error:

ResourceType:AWS::CloudWatch::MetricStream, ResourceStatusReason:Properties validation failed for resource DatadogMetricStreamAllNamespaces with message: [#: #: 2 subschemas matched instead of one]

Testing Guidelines

Tested by creating a stack in our sandbox AWS account in one of the regions (e.g., ap-northeast-1) where this error was observed. The stack was successfully created with each include/exclude parameter combination with these changes.

Additional Notes

Sorry my IDE insisted on changing all the quotes and formatting 💀 I commented on the lines with the only significant changes