DataDog / datadog-cloudformation-macro

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

Version 0.3.0 of the macro generates tags in a format that CloudFormation doesn't like #64

Closed srussellextensis closed 2 years ago

srussellextensis commented 2 years ago

Expected Behavior

A CloudFormation template with the "DatadogServerless" Transform and a "AWS::Lambda::Function" resource should deploy without error in AWS.

Actual Behavior

After installing v0.3.0 of the serverless macro, a CloudFormation template with the "DatadogServerless" Transform and a "AWS::Lambda::Function" fails to deploy with this error:

Properties validation failed for resource MyLambdaFunction with message: #/Tags: expected type: JSONArray, found: JSONObject

This happened with a variety of our Lambda-deploying CloudFormation templates which had not been changed.

The processed template with 0.3.0 includes these tags in object format on my Lambda function:

"Tags": {
          "dd_sls_macro": "v0.3.0"
        }

The previous version of the macro we had installed, 0.2.5, has them as an array like this:

        "Tags": [
          {
            "Value": "v0.2.5",
            "Key": "dd_sls_macro"
          }
        ]

AWS CloudFormation does not appear to like the newer output from the macro.

Steps to Reproduce the Problem

  1. Install the v0.3.0 serverless macro into your AWS account. I was using the "latest" template from: https://datadog-cloudformation-template.s3.amazonaws.com/aws/serverless-macro/latest.yml
  2. Create a CloudFormation template that uses the DatadogServerless transform and includes a AWS::Lambda::Function resource. If it matters, my template is in JSON format
  3. Deploy the template into AWS. Mine is deployed via the Javascript SDK, but it should also happen through the console.
  4. The template fails to deploy with the error listed above.
  5. Fix the problem by rolling back to the previous macro from the following location and re-deploying: https://datadog-cloudformation-template.s3.amazonaws.com/aws/serverless-macro/0.2.5.yml

Specifications

For the Datadog Serverless Macro:

Stacktrace

  Paste here
lizapressman commented 2 years ago

This should be fixed now in v0.4.1. Please reopen if you still have an issue.