0

I have a JSON body that looks something like this.

This was retrieved through AWS cli secrets manager command.

{
    "user1": {
      "username": "user",
      "password": "123",
    },
    "user2": {
      "username": "user2",
      "password": "1234"
    }
}

I need a command that would put this JSON into a file called something like user.json.

Is this possible through a command?

## buildspec.yml
version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: latest
    commands:
      - npm install
  pre_build:
    commands:
      - CREDS="$(aws secretsmanager get-secret-value --secret-id arn:aws:secretsmanager:{secret} | jq '.SecretString | fromjson')"
  build:
    commands:
      - echo $CREDS (prints the correct credentials in json format)
      - Need to send $CREDS > user.json or something similar. Is this possible?
      - npm start test:run
Steve
  • 197
  • 7
  • 17
  • Unclear what this has to do with `jq`. To redirect output of a command to a file `>` is to be used (regardless of the format). – knittl Aug 14 '22 at 07:33
  • Does this answer your question? [How to redirect output to a file and stdout](https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout) – knittl Sep 06 '22 at 19:02

0 Answers0