aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.46k stars 596 forks source link

E1029: StateMachine DefinitionSubstitutions key is the same as the parameter name or resource id #3786

Closed sudoudaisuke closed 4 weeks ago

sudoudaisuke commented 4 weeks ago

CloudFormation Lint Version

1.18.1

What operating system are you using?

Ubuntu

Describe the bug

If the key of AWS::StepFunctions::StateMachine DefinitionSubstitutions is the same as the parameter name or resource ID, an E1029 error occurs. I do not want to use the Sub function. So, I set the DefinitionSubstitutions map to ResouceId: !Ref ResouceId. Then, E1029 is generated when the key is referenced.

$ cfn-lint ./a.yaml
E1029 Found an embedded parameter "${myParam}" outside of an "Fn::Sub" at Resources/TestStateMachine/Properties/Definition/States/Test/Parameters/Key1
a.yaml:28:15

E1029 Found an embedded parameter "${mySnsTopic}" outside of an "Fn::Sub" at Resources/TestStateMachine/Properties/Definition/States/Test/Parameters/Key2
a.yaml:29:15

Expected behavior

pass lint.

Reproduction template

---
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  myParam:
    Type: String

Resources:
  mySnsTopic:
    Type: AWS::SNS::Topic

  TestStateMachine:
    Type: AWS::StepFunctions::StateMachine
    Properties:
      RoleArn: arn:aws:iam::123456789012:role/abc
      DefinitionSubstitutions:
        # define key as parameter name or resource id
        myParam: !Ref myParam
        # define key as parameter name or resource id
        mySnsTopic: !GetAtt mySnsTopic.TopicName
        # define key as none resource name
        myOkKey: 1234
      Definition:
        StartAt: Test
        States:
          Test:
            End: true
            Parameters:
              Key1: ${myParam} # E1029
              Key2: ${mySnsTopic} # E1029
              Key3: ${myOkKey} # ok
            Type: Pass