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

Need "no quotes" string option for JMESPAth output #1961

Closed
SteveALee opened this issue May 6, 2016 · 8 comments
Closed

Need "no quotes" string option for JMESPAth output #1961

SteveALee opened this issue May 6, 2016 · 8 comments
Assignees
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@SteveALee
Copy link

Is there a way to lose the quotes in returned string values?

In order to use output such as the IdentityPoolId from cognito-identity create-identity-pool on the command line the quotes need to me removed.

JMSEPath jp includes an -u/--unquoted option or we can set export JP_UNQUOTED=true

neither work with AWS. Can you please implement?

@SteveALee SteveALee changed the title Need no quotes option for JMESPAth output Need "no quotes" string option for JMESPAth output May 6, 2016
@SteveALee
Copy link
Author

For now I'm using

IDENTITY_POOL_ID="${IDENTITY_POOL_ID%\"}";IDENTITY_POOL_ID="${IDENTITY_POOL_ID#\"}"

@kyleknap
Copy link
Member

kyleknap commented May 6, 2016

You can do this now with the --output text option. For example, try something like this:

$ aws cognito-identity create-identity-pool --identity-pool-name foo --allow-unauthenticated-identities --query IdentityPoolId --output text
us-east-1:96339a84-0d20-4e67-9b87-fe1f1f854f00

It should output the id that you want without the quotes. Let us know if that helps.

@kyleknap kyleknap added question closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 6, 2016
@kyleknap kyleknap self-assigned this May 6, 2016
@SteveALee
Copy link
Author

AH, OK thanks will give it a go. I had assume the text output would be ALL the same info as in the json. Ie more than just the ID.

@JordonPhillips
Copy link
Member

@SteveALee Correct, it shows all the same information.

@SteveALee
Copy link
Author

Gotit --query IdentityPoolId filters even if not JSON output. Effectively -output text reformats the json output.

@SteveALee
Copy link
Author

@JordonPhillips @kyleknap

Yes --output text is perfect. I obviously made invalid assumptions about output formats and relation to the --query option. My bad. It turns out I even forgot to specify the output format at all. I don't see the default specified. I guessed JSON.

@diehlaws diehlaws added guidance Question that needs advice or information. and removed question labels Jan 4, 2019
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
…ws#1961)

* fix: allow parameters to be passed through to `SamTranslatorWrapper`

Why is this change necessary?

* Some plugins require that intrinsics are resolved and parameter
information be present.

How does it address the issue?

* Passing parameters that have parameters and pseudo parameters resolved
fixes the issue.
* Also tested with local invoke and deploy

What side effects does this change have?

* None at this point.

* fix: integration tests

Why is this change necessary?

* Integration testing for intrinsics.

How does it address the issue?

* Test use cases where the function invoke and deploys work and shouldnt
work.

* fix: test assertions - line numbers

Why is this change necessary?

* Container Implementation may have changed, which changes the line
numbers in the assertion.

How does it address the issue?

* Updated to correct line number in the assertion.

What side effects does this change have?

* None

* fix: address comments
@nitrocode
Copy link

I know this is an old thread but it popped up on google so I thought I'd add to the conversation.

The --output text works for most use-cases but if any of the output contains multi line string data with \n chars, if you use --output text, you lose the new lines.

I use the following for multi line information.

  • sed to remove the quotations
  • echo to turn the \n chars into new lines
echo $(aws secretsmanager get-secret-value --secret-id my-client-pem --query SecretString | sed 's,",,g') > client.pem

with jq and its flag -r for raw, we can drop the echo and the sed command

aws secretsmanager get-secret-value --secret-id my-client-pem | jq -r '.SecretString' > client.pem

It would be nice if the awscli supported a native -r raw output like jq does.

@lvkins
Copy link

lvkins commented May 29, 2023

Be careful using --output text as it changes how --query operates, see: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-filter.html#cli-usage-filter-client-side

Important
The output type you specify changes how the --query option operates:

If you specify --output text, the output is paginated before the --query filter is applied, and the AWS CLI runs the query once on each page of the output. Due to this, the query includes the first matching element on each page which can result in unexpected extra output. To additionally filter the output, you can use other command line tools such as head or tail.

If you specify --output json, --output yaml, or --output yaml-stream the output is completely processed as a single, native structure before the --query filter is applied. The AWS CLI runs the query only once against the entire structure, producing a filtered result that is then output.

You can can combine AWS cli command with jq in order to strip the double quotes:

aws [...] --query 'yourItem' | jq -r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

6 participants