0

Let's say I need to run a command on the terminal:

elasticdump \
  --s3AccessKeyId "${$access_key_id}" \
  --s3SecretAccessKey "${access_key_secret}" \
  --input=localhost:123/my_index/ \
  --output "s3://${bucket_name}/${file_name}.json"

In which, access_key_id and access_key_secret are the AWS credentials that need to be put in a double quote.

To get the credentials, I run a program, let's name it get-cred:

get-cred --type=b info
get-cred --type=a info

When run individually in the command line, each line would print out the secret key and ID, without the double quotes.

How do I put them inside double quotes and use them in the elasticdump command?


Update with more details:

The outputs of get-cred are printed in a single line.

For example:

get-cred --type=a info

would print out

AKIAIOSFODNN7EXAMPLE

and

get-cred --type=b info

would print out:

wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Example keys taken from here: https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html

Katie
  • 811
  • 1
  • 10
  • 15
  • 1
    Important conceptual distinction: Insofar as they're meaningful to the parsing process, quotes are _syntax_. Literal quotes in your data don't substitute for semantic quotes in your syntax being missing; they're two entirely different things and orthogonal to each other. – Charles Duffy Nov 20 '20 at 20:50
  • That said -- can you show me a sanitized example of what `get-cred`'s output looks like? Substitute other content for your real secrets, but the values should be close enough to show the format (so if there are any interesting special characters in the output, they should be there in the sample; if you don't know if something qualifies as interesting, include it). – Charles Duffy Nov 20 '20 at 20:50
  • ...are the values printed to a single line, separated by spaces? To two separate lines, thus separated by a newline? Something else? – Charles Duffy Nov 20 '20 at 20:52
  • "\"$access_key_id\"" – Raman Sailopal Nov 20 '20 at 20:52
  • @RamanSailopal, absolutely not. That's adding **literal** quotes, the OP needs **syntactic** quotes. – Charles Duffy Nov 20 '20 at 20:53
  • @RamanSailopal the outputs of `get-cred` are printed in a single line. For example: ``` get-cred --type=a info ``` would print out ``` AKIAIOSFODNN7EXAMPLE ``` and ``` get-cred --type=b info ``` would print out: ``` wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY ``` Example keys taken from here: https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html – Katie Nov 20 '20 at 20:54
  • 2
    @Katie, great, then. `elasticdump --s3AccessKeyId "$(get-cred --type=a info)" --s3SecretAccessKey "$(get-cred --type=b info)"` -- the quotes that surround the `$(...)` are the only kind of quotes you need. – Charles Duffy Nov 20 '20 at 20:54
  • 1
    Something like `"$(get-cred --type=a info)"`? – Paul Hodges Nov 20 '20 at 20:55
  • Oh that works! Thanks! @CharlesDuffy – Katie Nov 20 '20 at 20:59

0 Answers0