Unable to define Math Expression for Cloudwatch Alarm in a Cloudformation Template : <p><a href="https://aws.amazon.com/about-aws/whats-new/2018/11/amazon-cloudwatch-launches-ability-to-add-alarms-on-metric-math-expressions/" rel="noreferrer">Recently</a> AWS announced that Cloudwatch alarms can use Math Expressions on metrics. I decided to create an alarm that compares the SUM of 2 single metrics with a given threshold. This means that according to <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html#metric-math-syntax" rel="noreferrer">AWS documentation</a> my expression should be SUM([m1,m2]), where m1 and m2 are 2 single metrics.
I also decided to implement this idea using a cloudformation template (in yaml). Here's the Cloudwatch alarm definition:</p>

<pre><code>BillingAlarmExpression:
  Type: AWS::CloudWatch::Alarm
  Properties:
    AlarmActions:
      - !Ref BillingAlertTopic
    AlarmDescription: String
    ComparisonOperator: GreaterThanOrEqualToThreshold
    EvaluationPeriods: 1
    Metrics:
      - Id: m1
        MetricStat:
          Metric:
            Dimensions:
              - Name: ServiceName
                Value: AmazonEC2
              - Name: Currency
                Value: USD
            MetricName: Estimated­Charges
            Namespace: AWS/Billing
          Period: 86400
          Stat: Maximum
        ReturnData: False
      - Id: m2
        MetricStat:
          Metric:
            Dimensions:
              - Name: ServiceName
                Value: AmazonCloudwatch
              - Name: Currency
                Value: USD
            MetricName: Estimated­Charges
            Namespace: AWS/Billing
          Period: 86400
          Stat: Maximum
        ReturnData: False
      - Id: Expr1
        Expression: SUM([m1,m2])
        Label: Yeap
    Threshold: 100
    TreatMissingData: ignore
</code></pre>

<p>The single metrics , m1 and m2 , have to do with the billing cost of EC2 and Cloudwatch service. What I want to check is if the charging cost for these 2 services has crossed the threshold of 100$. (Note that since the billing costs are exclusively stored in the N.Virginia region, I tried to deploy the above template in N.Virginia).
During the deployment of this template Cloudformation responds with the following error:</p>

<pre><code>"Invalid metrics list (Service: AmazonCloudWatch; Status Code: 400; Error Code: ValidationError; Request ID: c0748047-0378-11e9-ac36-5b1829988d18)"
</code></pre>

<p>When Cloudformation says "metrics list" it refers to the definition of m1,m2, Expr1. What is even more strange is that when I use the above metrics-list definition from aws cli the charging data return successfully:</p>

<pre><code>aws cloudwatch get-metric-data --metric-data-queries file://./metric-data.json --start-time 2018-12-03T03:00:00Z --end-time 2018-12-10T04:30:00Z
</code></pre>

<p>,where metric-data.json is the above metrics-list.</p>

<p>For creating my template I used the following guides:
<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html" rel="noreferrer">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html</a>
and
<a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html" rel="noreferrer">https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html</a></p>

<p>Do you have any idea why Cloudformation returns this error? Thanks!</p>
