bazaarvoice / cloudformation-ruby-dsl

Ruby DSL for creating Cloudformation templates
Apache License 2.0
210 stars 76 forks source link

Attributes with dots in the name generate an incorrect get_att() call #124

Open icy-arctic-fox opened 6 years ago

icy-arctic-fox commented 6 years ago

When using cfntemplate-to-ruby to generate the Ruby code, if you use Fn::GetAtt with more than 2 arguments - like when the attribute has a dot in the name, extra arguments are generated for get_att() instead of keeping the dot.

For instance, I use Fn::GetAtt on an RDS instance to get the database endpoint - Endpoint.Address.

In the documentation for Fn::GetAtt, one of the examples shows the attribute name as separate elements of the array.

"SourceSecurityGroupName": {
  "Fn::GetAtt": [
    "myELB",
    "SourceSecurityGroup",
    "GroupName"
  ]
}

Steps to reproduce:

  1. Generate a CloudFormation template that uses Fn::GetAtt with an attribute that has a dot (.) in the name. Split the attribute name on the dot to give Fn::GetAtt more than two arguments.
  2. Generate the Ruby code with cfntemplate-to-ruby
  3. Notice the output contains a get_att() call with more than two arguments.
  4. Try to run expand on on the generated Ruby code.
  5. Error is received:
    .../cloudformation-ruby-dsl-1.4.6/lib/cloudformation-ruby-dsl/dsl.rb:264:in `get_att': wrong number of arguments (given 3, expected 2) (ArgumentError)