DataDog / datadog-cloudformation-macro

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

Should this be used with cloudformation templates? #25

Closed exiadbq closed 3 years ago

exiadbq commented 3 years ago

https://github.com/DataDog/datadog-cloudformation-macro#datadog-cloudformation-macro read me says yes,

sub folder no mentioning https://github.com/DataDog/datadog-cloudformation-macro/tree/master/serverless#datadog-serverless-macro

Support guy suggest it should work with CF templates, but seems not clear, or not sure if working.

tianchu commented 3 years ago

This macro primarily focuses on AWS SAM and CDK use cases, but it should work for CloudFormation projects too. Let us know if you encounter any issue. For quick questions like this, you could also find us in our slack community.

exiadbq commented 3 years ago

Thanks for replying!

Transform:
  - AWS::Serverless-2016-10-31
  - Name: DatadogServerless
    Parameters:
      nodeLayerVersion: 43
      forwarderArn:
        Fn::ImportValue: datadog-forwarder-ForwarderArn

I got an error while generating changeset for my cfn template on template level, I didn't add service param as my template has multiple functions and each can be its own service.

The value of parameter forwarderArn under transform DatadogServerless must resolve to a string, number, boolean or a list of any of these. Which may or may not relate to https://github.com/aws/serverless-application-model/issues/22?

tianchu commented 3 years ago

@exiadbq you are right, your issue and https://github.com/aws/serverless-application-model/issues/22 are due to the same root cause -- CFN passes the raw template to the macro for transformation, i.e., our macro sees Fn::ImportValue: datadog-forwarder-ForwarderArn instead of the actual value of the forwarder ARN, so it's not gonna work.

The workaround is to NOT define the forwarderArn parameter (which creates the subscription filters behind scene) and instead you define subscription filters on your functions' log groups in your SAM/CFN template. Similar to what is described here.

I'm going to close this issue, since I think this kind of questions are better suited for our slack community.