Parsed global parameters doesn't get passed to external aliases #3102
Labels
automation-exempt
Issue will not be subject to stale-bot
configuration
feature-request
A feature should be added or improved.
p3
This is a minor priority issue
When creating an alias (ie
~/.aws/cli/alias
) to an external command, theparsed_globals
variable (ie https://github.com/aws/aws-cli/blob/develop/awscli/alias.py#L274 ) is never passed to the child-process. As a result, information is lost. Hence, the child command is actively prevented from using certain command line parameters.Steps to reproduce:
Actual output (note that all trace of the "foo" profile is lost):
There are several possible solutions (mostly around https://github.com/aws/aws-cli/blob/develop/awscli/alias.py#L278-L283 ):
a. Pass a serialised, sh-escaped (which makes non-sh/bash aliases difficult to write)
parsed_globals
via a new environment variable (egAWS_CLI_ALIAS_PARSED_GLOBALS
) which can then be eval'ed by the child-process. This data could also be in Base64-encoded JSON (though this is now getting complicated). We could also have multiple new variables (egAWS_CLI_PROFILE
) -- which starts to make it similar to solution 3c. Expected output then becomes:b. Add it to the command-line. Unfortunately, we really need the unparsed-args. Else, we need to revert
endpoint_url
to--endpoint-url
and I don't fancy dealing with duplicated logic. We could also modifyExternalAliasCommand.__call__
(andServiceAliasCommand
etc) to transmit the unparsed args (also see: https://github.com/aws/aws-cli/blob/develop/awscli/clidriver.py#L208 ). Expected output then becomes:c. For some parameters (eg
--profile
), modify the existing standardised environment variable (ieAWS_PROFILE
) instead. However, there are no standardised variable names for most of the existing parameters. Expected output then becomes:Note that existing environment parameters exists for the following options only:
--profile
toAWS_PROFILE
--region
toAWS_DEFAULT_REGION
--output
toAWS_DEFAULT_OUTPUT
--ca-bundle
toAWS_CA_BUNDLE
And none for (if this is the desired solution, I'd also like to hear opinions on appropriate environment variable names for the following, my recommendations in brackets):
--color
(AWS_COLOR
)--no-paginate
(AWS_NO_PAGINATE
)--cli-connect-timeout
(AWS_CONNECT_TIMEOUT
)--no-sign-request
(AWS_NO_SIGN_REQUEST
)--no-verify-ssl
(AWS_NO_VERIFY_SSL
)--cli-read-timeout
(AWS_READ_TIMEOUT
)--debug
(AWS_DEBUG
)--endpoint-url
(AWS_ENDPOINT_URL
)A reason for the negatives is that by common (though not universal) Unix/Linux convention, a missing variable is treated identically to an empty string which is then interpreted as a boolean false. And given the existing default values for those variables, a
AWS_NO_
name seems more appropriate.As an aside,
git
solves a similar problem by selecting solution c. There are also issues which would benefit from a consistent and complete set of environment variables (eg in Feature Request: set--debug
via .aws/config #2007 the user could switch on--debug
for all their aws-cli invocations simply by togglingAWS_DEBUG
).Before I start coding up a solution, I'd like to hear from aws-cli maintainers what's likely to be merged. I want to avoid spending a lot of time coding/debugging, only for the patch to be rejected due to a difference of opinion at the very first step.
The text was updated successfully, but these errors were encountered: