Skip to content

Commit

Permalink
Convert param input to String
Browse files Browse the repository at this point in the history
The ruby AWS SDK always expects string input. Even if your
cloudformation parameter type is `Number`, it still wants it to be a
ruby String. The validation of parameter value will happen in
cloudformation land.

Currently stackup is just passing through the raw YAML value to the SDK
as is - which means it is up to the caller to understand the nuances on
the ruby AWS SDK (where everything must be a string). Given stackup is
supposed to "help" reduce cognitive load, I think it's ok for it to help
convert our YAML values in this instance.
  • Loading branch information
tigris committed Apr 23, 2024
1 parent 5cd37e3 commit 192583f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/stackup/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def to_a
if value == :use_previous_value
record[:use_previous_value] = true
else
record[:parameter_value] = value
record[:parameter_value] = value.to_s
end
end
end
Expand Down Expand Up @@ -75,7 +75,7 @@ def value
if use_previous_value
:use_previous_value
else
parameter_value
parameter_value.to_s
end
end

Expand Down
24 changes: 24 additions & 0 deletions spec/stackup/parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,30 @@

end

context "with Integer values" do

let(:input_records) do
[{ :parameter_key => "SomeInteger", :parameter_value => 123_456_789 }]
end

subject(:parameters) { Stackup::Parameters.new(input_records) }

describe "#to_hash" do
it "converts the Integer to a String" do
expected = { "SomeInteger" => "123456789" }
expect(parameters.to_hash).to eql(expected)
end
end

describe "#to_a" do
it "converts the Integer to a String" do
expected = [{ :parameter_key => "SomeInteger", :parameter_value => "123456789" }]
expect(parameters.to_a).to eql(expected)
end
end

end

context "with empty parameter file" do

let(:input_records) { false }
Expand Down

0 comments on commit 192583f

Please sign in to comment.