-
Notifications
You must be signed in to change notification settings - Fork 202
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
allow AWS-managed ssh key pairs to be disabled #392
Conversation
spec/kitchen/driver/ec2_spec.rb
Outdated
context "with key pair configured to false" do | ||
before do | ||
config[:aws_ssh_key_id] = false | ||
expect(driver).to receive(:submit_server).and_return(server) |
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.
Maybe include a negative expectation for setting aws_ssh_key_id
to false
?
expect(driver).to_not receive(:create_key)
Looking at the spec, I found myself wondering what was different.
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.
The key won't get created if you provide a path either so not sure checking this is any more meaningful but I do see what you are saying. Initially I'd added this to the instance_generator but that felt like more code that wasn't really doing much.
Just throwing this out there .... should |
No, env vars have no concept of boolean - they are always strings and we're going to respect whatever a person sets there and fail if it's bad data. |
@pantocrator27 so we've figured out the fix (mostly) but bike shedding on the option, would you prefer:
OR
We definitely want to keep auto-generation as the default when Nil and given this is a relatively niche use case you kinda get to pick what sounds best! |
@pantocrator27 Updated this PR with what |
@cheeseplus @robbkidd Thanks for all of your work on this guys! It honestly feels to me that "disable" may sound better than "false". It semantically feels better to me if this makes sense because we are essentially disabling this feature .... Thoughts? |
That was pretty much our thinking too but just wanted to shop it out since, as of now, you are the primary use case. |
spec/kitchen/driver/ec2_spec.rb
Outdated
expect(fake_file).to receive(:write).with("RSA PRIVATE KEY") | ||
context "with no AWS-managed ssh key pair configured, creates a key pair to use" do | ||
before do | ||
config.delete(:aws_ssh_key_id) |
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.
🤔 This should probably be config[:aws_ssh_key_id] = nil
to accurately reflect the default config where the key is present and its value is nil
. config.delete(:aws_ssh_key_id)
as setup is technically testing when the key is not present.
Hmm, I am :-/ on using disable since we shouldn't do stuff that requires symbols (as opposed to strings) and magic string values are usually a thing that will bite people later. |
@coderanger Do you have a suggestion for a better way to disable the current
The current code handles either with a relevant specs
|
I'm not super opposed to |
At this point ... I am not going to look a gift horse in the mouth :) or ask you guys to do something contrary to the set of current coding standards |
As the customer, I will be equally pleased with either approach so long as it is documented. Please and thanks! |
Alternate proposal: |
@robbkidd can that be done :) |
also I hate to ask this, could this make its way into the next release of ChefDK ... I don't know how that process would work? |
The deps in ChefDK just need to get bumped - the catch being that the ChefDK release is on it's own monthly schedule so if you wanted it sooner you'd have to consume a build from the |
thanks for the info @cheeseplus! |
I think I've convinced myself that a magic string is fine but what if we do |
Updated for |
Just needs some text in the readme to document it :) I can do that post merge if you're low on cycles since you already put in a 💯 effort <3 |
Regarding ...
As things currently stand in this PR, if the environment variable is set to |
@coderanger I'm working on the README update right now! Thanks for the offer, though. |
Both ec2_spec and ec2/image_selection_spec use this class, so let's promote it to a proper shared test class under spec/support. Signed-off-by: Robb Kidd <robb@thekidds.org>
If :aws_ssh_key_id is nil, continue to perform the key auto-generation. If :aws_ssh_key_id is explicitly set to "_disabled", do not generate a key. This means that the kitchen configuration must be more explicit about how connections will be authenticated. For example, when an environment has disallowed AWS-managed keys, a key could be named in the driver's `user_data` and the private key specified in the transport. * moved the gnarly setup/expectations for #create_key to a separate describe block so that the expectations around key auto-generation or enable/disable are more clear Co-authored-by: Robb Kidd <robb@thekidds.org> Co-authored-by: Seth Thomas <sthomas@chef.io> Signed-off-by: Robb Kidd <robb@thekidds.org> Signed-off-by: Seth Thomas <sthomas@chef.io>
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.
Intended to call out the three states `aws_ssh_key_id` can be in and put the words appropriate for each state next to it. Signed-off-by: Robb Kidd <robb@thekidds.org>
Did a quick rearrangement within the doc section. Does that make things better or worse? |
I personally feel it makes sense |
We've got two thumbs and since I started the PR I can't approve - |
Fixes #391. When adding the new auto-generation feature of keys/security groups, the option to not pass any SSH key id at all was lost. This means that
aws_ssh_key_id
now has three states:nil
we auto-create a key-pair"/path/to/key.pem"
orENV["AWS_SSH_KEY_ID"]
is set, we use specified key"_disable"
, don't provide any key-pair at all - this requires the remote image/instance to have this configured out of band (baking, user_data)TODO