mrm-commerce / cloud_builder

Ruby DSL for managing AWS CloudFormation templates and stacks
MIT License
17 stars 4 forks source link

DSL generation issues when properties contain "type" #1

Open TinHead opened 11 years ago

TinHead commented 11 years ago

I was trying to add a Route53 entry to a stack as below:

resource "dns_record_set" do 
    properties do 
          hosted_zone_name "somezone.net."
          name "host.somezone.net"
          type "A"
          set_identifier "frontend_instance_b"
          weight 1
          TTL 300
          resource_records [ ref("my_elastic_ip_defined_else") ]              
     end
    type "AWS::Route53::RecordSet"
end

The resulting json was:

"DnsRecordSet": {
      "Metadata": {
      },
      "Properties": {
       "HostedZoneName": "somezone.net.",
        "Name": "host.somezone.net.",
        "ResourceRecords": [
          {
            "Ref": "MyElasticIpDefinedElse"
          }
        ],
        "SetIdentifier": "frontend_instance_b",
        "Ttl": 300,
        "Weight": 1
      },
      "Type": "A"
},

The problem is that in the resulting Json the Type attribute type "AWS::Route53::RecordSet" is overwritten by the Type attribute in the properties which is set to "A"

dvestal commented 10 years ago

I'm not sure if you've resolved your issue yet, but if I declare the inner property "type" as "Type" instead then it generates the correct json.

resource "dns_record_set" do
  properties do
    hosted_zone_name "somezone.net"
    name "host.somezone.net"
    Type "A"
    set_identifier "frontend_instance_b"
    weight 1
    TTL 300
    resource_records [ ref("my_elastic_ip_defined_else") ]
  end
  type "AWS::Route53::RecordSet"
end

Generated json:

"DnsRecordSet": {
    "Metadata": {
    },
    "Properties": {
        "HostedZoneName": "somezone.net",
        "Name": "host.somezone.net",
        "ResourceRecords": [
          {
            "Ref": "MyElasticIpDefinedElse"
          }
        ],
        "SetIdentifier": "frontend_instance_b",
        "TTL": 300,
        "Type": "A",
        "Weight": 1
      },
    "Type": "AWS::Route53::RecordSet"
}