Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: data.join is not a function #16

Closed
PatMyron opened this issue Dec 7, 2020 · 4 comments
Closed

TypeError: data.join is not a function #16

PatMyron opened this issue Dec 7, 2020 · 4 comments

Comments

@PatMyron
Copy link

PatMyron commented Dec 7, 2020

cfn-dia html -t ~/Documents/GitHub/cfn-python-lint/test/fixtures/templates/bad/resources_circular_dependency_2.yaml

TypeError: data.join is not a function
    at Object.dump (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/yaml-cfn/index.js:39:24)
    at applyOverrides (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/yaml-cfn/index.js:44:49)
    at Type.represent (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/yaml-cfn/index.js:61:23)
    at detectType (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:695:26)
    at writeNode (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:720:5)
    at writeBlockMapping (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:657:10)
    at writeNode (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:750:9)
    at writeBlockMapping (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:657:10)
    at writeNode (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:750:9)
    at dump (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/js-yaml/lib/js-yaml/dumper.js:840:7)
Resources:
  Resource:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Sub ${Resource2}
  Resource2:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !GetAtt Resource3.TopicName
  Resource3:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Ref Resource4
  Resource4:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::Sub: ${Resource5}
  Resource5:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::GetAtt: Resource6.TopicName
  Resource6:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Ref: Resource7
  Resource7:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Sub ${Resource8.TopicName}
  Resource8:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::Sub: ${Resource9.TopicName}
  Resource9:
    DependsOn: Resource
    Type: AWS::SNS::Topic

(template from aws-cloudformation/cfn-lint#1391, aws-cloudformation/cfn-lint#1411)

@ljacobsson
Copy link
Owner

Thanks for reporting.

This error originates from the yaml-cfn parser.

You can only reference the atttribute using dot-notation when using the !GetAtt shorthand syntax. Changing this to Fn::GetAtt: [ Resource6, TopicName] or !GetAtt Resource6.TopicName will give you valid CloudFormation.

Please refer to the docs for Fn::GetAtt

I see you're using connections to visualise DependsOn-relationships. That's a good idea and I'll add an issue for that!

@ljacobsson
Copy link
Owner

I'll close this. Please reopen if you disagree :-)

@PatMyron
Copy link
Author

PatMyron commented Dec 8, 2020

will give you valid CloudFormation

This template successfully deploys, but maybe better filed downstream: https://github.com/gristlabs/yaml-cfn/issues

Resources:
  Resource:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Sub ${Resource2}
  Resource2:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !GetAtt Resource3.TopicName
  Resource3:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Ref Resource4
  Resource4:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::Sub: ${Resource5}
  Resource5:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::GetAtt: Resource6.TopicName
  Resource6:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Ref: Resource7
  Resource7:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        !Sub ${Resource8.TopicName}
  Resource8:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName:
        Fn::Sub: ${Resource9.TopicName}
  Resource9:
    # DependsOn: Resource
    Type: AWS::SNS::Topic

@chauncey-garrett
Copy link

@PatMyron I ran into a similar issue and ended up needing to convert from the shorthand notation !GetAtt Resource6.TopicName to the standard notation Fn::GetAtt: [ Resource6, TopicName].

Our template has also deployed successfully. I believe this issue is the result of a bug in the GetAtt override: https://github.com/gristlabs/yaml-cfn/blob/9a139dc48428f6bf01d7fb3334133cf56fe9e31c/index.js#L37-L40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants