-
Notifications
You must be signed in to change notification settings - Fork 34
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
Convert param input to String #105
Conversation
c25d190
to
192583f
Compare
Hi Dan! 🙂 I hope you're doing well ❤️ I feel like this change makes sense, but I'm curious about a couple of things:
|
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.
The methods affected The expected arguments seem to be a list of hashes, where each item in the hashes are strict key / value pairs, and I don't believe it supports the values being anything other than a simple string. Dan's latest commit sanitizes the values when initializing the object, rather than when outputting, which I think is the better approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense; Parameter values are supposed to be strings.
Also, hi!
Looking at the docs, it seems it's not possible to pass an array or hash/dict/object as a param. The stackup library is not currently validating this at all and blindly slurps in the yaml object and passes it as the parsed object. Which of course fails, for the same reason the Integer fails (cloudformation wants a string). Anyone attempting to do this would be receiving failures.
This would be a I guess this would be a breaking change in a way -- previous instances of folks using
This is correct. A YAML |
Perhaps to alleviate the chance of breaking changes, I can update this change to only impact Integer and Boolean values. |
What do people think about the following ideas?
|
80bba95
to
f6ad592
Compare
Sure. I've done this now.
I feel less ok about this, i'm totally not sure who's stuff out there would break. Not mine, and likely not anyone, but it's also likely no one is setting |
Cloudformation doesn't take Arrays or any other kind of things that YAML may consider objects. So let's convert what we can to String safely. We're not converting `null` to string because that may be a breaking change.
@tigris I just wanted to make sure you knew that we haven't forgtten about this. I've been on leave but will be back on deck later this week 👍 |
Oops. I forgot about this after getting back from my leave :( I'm taking another look now. |
class ParameterValue | ||
|
||
def initialize(value) | ||
@value = value | ||
end | ||
|
||
def to_param | ||
case @value | ||
when TrueClass, FalseClass, Integer then | ||
@value.to_s | ||
when Array | ||
@value.map { |v| ParameterValue.new(v).to_param }.join(",") | ||
else | ||
@value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is a class. Couldn't it just be a plain function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is a class. Couldn't it just be a plain function?
Was following the convention used elsewhere in the same file, e.g. ParameterStruct
Thanks for the contribution Dan, and sorry it took me so long to get to it :( I'll see what's required to issue a new release later today 👍 |
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.