realestate-com-au / stackup

a simple CLI and Ruby API for AWS CloudFormation
MIT License
97 stars 34 forks source link

Tags as AWS style array of hashes doesn't seem to work for me #83

Closed ps-jay closed 4 years ago

ps-jay commented 4 years ago

With a .json file of tags in AWS format ... I get errors from stackup some-stack up ...:

Tags file:

[
  {
    "Key": "Name",
    "Value": "some-stack"
  },
  {
    "Key": "Environment",
    "Value": "test"
  },
  {
    "Key": "Owner",
    "Value": "Delivery Engineering"
  },
  {
    "Key": "Criticality",
    "Value": "Low"
  },
  {
    "Key": "CostCentre",
    "Value": "1000"
  },
  {
    "Key": "PublicResource",
    "Value": "Yes"
  }
]

Errors:

/usr/local/bundle/gems/aws-sdk-core-3.68.1/lib/aws-sdk-core/param_validator.rb:33:in `validate!': parameter validator found 24 errors: (ArgumentError)
  - missing required parameter params[:tags][0][:key]
  - missing required parameter params[:tags][0][:value]
  - unexpected value at params[:tags][0]["Key"]
  - unexpected value at params[:tags][0]["Value"]
  - missing required parameter params[:tags][1][:key]
  - missing required parameter params[:tags][1][:value]
  - unexpected value at params[:tags][1]["Key"]
  - unexpected value at params[:tags][1]["Value"]
  - missing required parameter params[:tags][2][:key]
  - missing required parameter params[:tags][2][:value]
  - unexpected value at params[:tags][2]["Key"]
  - unexpected value at params[:tags][2]["Value"]
  - missing required parameter params[:tags][3][:key]
  - missing required parameter params[:tags][3][:value]
  - unexpected value at params[:tags][3]["Key"]
  - unexpected value at params[:tags][3]["Value"]
  - missing required parameter params[:tags][4][:key]
  - missing required parameter params[:tags][4][:value]
  - unexpected value at params[:tags][4]["Key"]
  - unexpected value at params[:tags][4]["Value"]
  - missing required parameter params[:tags][5][:key]
  - missing required parameter params[:tags][5][:value]
  - unexpected value at params[:tags][5]["Key"]
  - unexpected value at params[:tags][5]["Value"]

I realise these come from the aws-sdk .. so it may not be Stackup's issue ?

In hash style, it works fine. e.g.

{
  "Name": "some-stack",
  "Environment": "test",
  "Owner": "Delivery Engineering",
  "Criticality": "Low",
  "CostCentre": "1000",
  "PublicResource": "Yes"
}

FYI, I'm using the Stackup docker container: realestate/stackup 1.4.5 247f28127230 2 months ago 51MB

ps-jay commented 4 years ago

And while I was writing this ... I noticed "Key" is unexpected, but :key is missing.

With terrible ruby skills, I got this to work

    def normalize_tags(tags)
      if tags.is_a?(Hash)
        tags.map do |key, value|
          { :key => key, :value => value.to_s }
        end
      else
        puts "XXX"
        temp = []
        for t in tags do
          temp += [{ :key => t['Key'], :value => t['Value'].to_s }]
        end
      end
      return temp
    end

I should be able to clean that up and submit a PR.

ps-jay commented 4 years ago

84 opened to fix this

ps-jay commented 4 years ago

Closed via #84