cfn-language-discussion icon indicating copy to clipboard operation
cfn-language-discussion copied to clipboard

Adding LanguageExtensions breaks Account Id comparisons

Open brianhenk opened this issue 1 year ago • 0 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about the bug

In my template, I have a condition based on equality comparison of AWS::AccountId to a static, integer value. When I add the AWS::LanguageExtensions transform, this logic no longer evaluates to true when I would expect. It only works if I define the static value as a string.

Expected behavior

When evaluating within AWS account 12345, I'd expect the following condition to be true:

"Fn::Equals": [ { "Ref": "AWS::AccountId" }, 12345]

Observed behavior

The above expression evaluates to true with no transform, but false with the AWS::LanguageExtensions transform.

Test cases

This template produces "Int Not Equal" and "Str Equals" as output:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Transform": "AWS::LanguageExtensions",
  "Conditions": {
    "IntEqualsCondition": {
      "Fn::Equals": [ { "Ref": "AWS::AccountId" }, 12345 ]
    },
    "StrEqualsCondition": { 
      "Fn::Equals": [ { "Ref": "AWS::AccountId" }, "12345" ]
    }
  },
  "Resources": {
    "JustATestQueue": {
      "Type": "AWS::SQS::Queue",
      "Properties": {
        "QueueName": "JustATestQueue",
        "MessageRetentionPeriod": 1209600
      },
      "UpdateReplacePolicy": "Delete",
      "DeletionPolicy": "Delete"
    }
  },
  "Outputs": {
    "Int": {
      "Value": {
        "Fn::If": [ "IntEqualsCondition", "Int Equals", "Int Not Equal" ]
      }
    },
    "Str": {
      "Value": {
        "Fn::If": [ "StrEqualsCondition", "Str Equals", "Str Not Equal" ]
      }
    }
  }
}

If the transform is removed, the output is "Int Equals" and "Str Equals".

brianhenk avatar Jan 05 '24 22:01 brianhenk