Skip to content
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

Bugfix/issue 325 #458

Closed
wants to merge 11 commits into from
Closed

Bugfix/issue 325 #458

wants to merge 11 commits into from

Conversation

glasswalk3r
Copy link
Contributor

  • Changed the way Awspec::Helper::Finder instantiates clients so first it checks for exception related to configurations done wrong.
  • Awspec::Helper::Finder::Alb now checks for Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound exception instead of generic ones.
  • Added check_instance to be executed at each method from Awspec::Helper::Finder::Alb so a proper exception is generated if there is no such load balancer.

Alceu Rodrigues de Freitas Junior added 2 commits March 5, 2019 20:37
Changed the way Awspec::Helper::Finder instantiates clients so first it checks for exception related to misconfigurations.
Awspec::Helper::Finder::Alb now checks for Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound exception instead of generic ones.
Added check_instance to be executed at each method from Awspec::Helper::Finder::Alb so a proper exception is generated if there is no such load balancer.
@@ -148,6 +148,16 @@ module Finder
http_proxy: ENV['http_proxy'] || ENV['https_proxy'] || nil
}

# define_method below will "hide" any exception that comes from bad
# setup of AWS client, so let's try first to create a instance
if File.exist?(ENV['HOME'] + '/.aws') && File.directory?(ENV['HOME'] + '/.aws')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awspec should not check .aws. I think this is beyond the awspec's responsibilities

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removed the .aws verification... now awspec will try to create a instance of Aws::EC2::Client in any setup situation (.aws or environment variables).

@glasswalk3r
Copy link
Contributor Author

Ops... @k1LoW , looks like we need to design some way to the tests running on Travis define a AWS region, or we use something that disables this tests to execute over there... otherwise, they will always fail.

@k1LoW
Copy link
Owner

k1LoW commented Jul 15, 2019

awspec should not check ENV, too. I think this is beyond the awspec's responsibilities.

awspec only uses Aws. awssecrets sets credentials.

@glasswalk3r
Copy link
Contributor Author

glasswalk3r commented Jul 15, 2019

awspec should not check ENV, too. I think this is beyond the awspec's responsibilities.

awspec only uses Aws. awssecrets sets credentials.

Got that, but since I removed any dependency (awssecrets), now the Travis CI tests will always be broken because this PR forces the configuration of the AWS Client at the very beginning, which will always fail because the Specs on awspec are using stubs, not real configuration.

A possibility is to add an environment variable (for awspec internal usage) that disables this specific test execution if that variable is defined.

@k1LoW
Copy link
Owner

k1LoW commented Jul 21, 2019

this PR forces the configuration of the AWS Client at the very beginning

https://github.com/k1LoW/awspec/pull/458/files#diff-f46513d75a662c430cff22e30e77570cR157

I do not feel the need for very beginning configuration of the AWS Client. Because, I think this is beyond the awspec's responsibilities too.

@glasswalk3r
Copy link
Contributor Author

this PR forces the configuration of the AWS Client at the very beginning

https://github.com/k1LoW/awspec/pull/458/files#diff-f46513d75a662c430cff22e30e77570cR157

I do not feel the need for very beginning configuration of the AWS Client. Because, I think this is beyond the awspec's responsibilities too.

I understand that, but there is a trade-off here: AWS configuration is not responsibility of awspec, but misconfiguration of it will cause a delayed exception, later in the specs execution, with a confusing message that will leave the user wondering if there is an error in the defined specs, awspec, AWS SDK or AWS itself.

Since we are not checking for anything regarding how the configuration was done (possibly repeating validations already provided by the SDK), forcing the client usage before running anything not only will provide a better error message, but also avoid wasting execution time for specs that will surely fail anyway. Future updates on the SDK (and how the configuration is made) will not break up awspec since we don't care how the configuration is done, just if it is working as expected.

What we would need is to define a mechanism to disable this self-test when running on Travis CI, since the stubs will not provide a client configuration by default.

@majormoses
Copy link

majormoses commented Jul 23, 2019

awspec should not check ENV, too. I think this is beyond the awspec's responsibilities.

awspec only uses Aws. awssecrets sets credentials.

I disagree, it seems weird to have to call some kind of script to init credentials and then call awspec. While I agree it makes it safer long term in case aws changes their auth api but this has not happened in a very long time and I imagine it will break too many tools that they just wont bother.

@k1LoW
Copy link
Owner

k1LoW commented Jul 24, 2019

There are a number of AWS credential configuration patterns.
There are also many patterns for using credentials.
I think it's difficult to support it all with awspec.
I want to simplify the awspec's responsibilities to keep the maintenance going.

@glasswalk3r
Copy link
Contributor Author

@k1LoW , I updated my PR to make it pass on Travis CI by adding a environment variable that disable the AWS client test. I don't think so it will get more simple than that, no assumptions are made regarding how the authentication was done, just executing the client with anything the AWS SDK will pull off from the environment.

@glasswalk3r
Copy link
Contributor Author

@k1LoW , any chance to have this patch applied?

@glasswalk3r
Copy link
Contributor Author

Thanks @majormoses !

@k1LoW
Copy link
Owner

k1LoW commented Nov 17, 2019

@glasswalk3r

First, thank you for committing to awspec !

This pull request is trying to solve multiple issues. I agree No.3.

  1. .gitignore
    • Contains unnecessary file information.
  2. Credential check
  3. alb check_existence
    • Thank you !

If possible, solve one problem with one PR 🙏 because

  • I can not merge when only one of them has agreed.
  • awspec use Pull Request title as changelog.

Best regards.

@glasswalk3r
Copy link
Contributor Author

Alright @k1LoW , I broke down this PR in two.
For the ALB, please check #503 .
For awsecrets, I started working on it, but there are pull requests 26 and 28 that you want to check first before I'm able to actually create the PR #325 (almost done basically).

@glasswalk3r
Copy link
Contributor Author

@k1LoW , the respective PR's for awsecrets are already merged and in place. I just fixed a merge conflict and also fixed, could you please check if this is ready for merge too?
Thanks!

@k1LoW
Copy link
Owner

k1LoW commented Jun 28, 2021

@glasswalk3r

Could you fix Number one on the list?

@glasswalk3r
Copy link
Contributor Author

@k1LoW , any chance to have this patch applied?

Gladly! But I had to fork again from awspec because of conflicts when trying to fetch from upstream, and my original branch is lost (I even tried to recreate with if the same name, but Github wasn't fooled).

So, I just copied the changes I made from there to my new fork/branch and will create the PR.

For now, I close this one so it can be done.

@glasswalk3r glasswalk3r closed this Jul 3, 2021
@glasswalk3r glasswalk3r mentioned this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants