GithubHelp home page GithubHelp logo

Comments (3)

codezninja avatar codezninja commented on July 28, 2024

I think this is a possible solution

awssume "aws --output text lambda list-functions --query \"Functions[?starts_with(FunctionName, \\\`FUNCTION_NAME\\\`) == \\\`true\\\`].FunctionName\""

from awssume.

jantman avatar jantman commented on July 28, 2024

I'm pretty sure the issue is with Awssume::CommandDecorator; format_cmd joins the args array into a string, and then that is passed to ruby's Kernel.system... but system() is explicitly designed to perform shell expansion if its argument is a string as opposed to an Array.

A pretty telling example of this comes from Ruby's API documentation:

system("echo *")
system("echo", "*")

produces:

config.h main.rb
*

As to a solution... I'm not 100% sure here, but it looks to me like the only reason that we're converting args from a (non-shell-evaluated) Array to a (shell-evaluated) string is to interpolate the AWS_* environment variable settings at the beginning of the command line. But we shouldn't have to do that; system() accepts an optional first env Hash parameter like spawn, where we can specify environment variables to set as a hash and then pass the command array through unmodified.

i.e. I think this problem would go away if the actual call became something like

system({'AWS_foo' => 'key', ... }, ARGV[0..-1])

or, in terms of an actual implementation, in lib/awssume.rb, change:

    aws_env = {
      'AWS_REGION'         => config.region,
      'AWS_DEFAULT_REGION' => config.region
    }
    creds_hash = adapter.assume
    fmt_cmd    = Awssume::CommandDecorator.format_cmd(ARGV[0..-1], creds_hash)

    handle_exit { system(aws_env, fmt_cmd) }

to:

    aws_env = {
      'AWS_REGION'         => config.region,
      'AWS_DEFAULT_REGION' => config.region
    }
    adapter.assume.each { |k,v| aws_env["AWS_#{k.upcase}"] = v }

    handle_exit { system(aws_env, ARGV[0..-1]) }

... unless I'm missing there being a reason why we're exporting some things directly to the environment, but relying on the shell to export others...?

from awssume.

qntnrbns avatar qntnrbns commented on July 28, 2024

I also think the is the correct solution.

Do we feel good about a patch?

from awssume.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.