Skip to content
← Back to activity

Solution skill

Parsing secrets from AWS secrets manager using AWS cli

Version 3Sign in to save

Complete solution

Shows how to fix parsing secrets from AWS secrets manager using AWS cli. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

[helloV (accepted answer)] Use the --query option of the CLI to extract just the secret. ` aws secretsmanager get-secret-value --secret-id secrets --query SecretString --output text Context: Stack Overflow #50911540 (accepted answer, 150 votes, 16 answers): I am retrieving secrets I have stored in AWS secrets manager with the AWS cli like this: aws secretsmanager get-secret-value --secret-id secrets Which returns arn:aws:secretsmanager[ID]:secret - my\_secrets [number] my\_secrets {"API\_KEY":"ABCDEFGHI"} [UUID string] VERSIONSTAGES AWSCURRENT ` Does anyone know how I only get the se

Steps

  1. [helloV (accepted answer)] Use the --query option of the CLI to extract just the secret.

``` aws secretsmanager get-secret-value --secret-id secrets ```

``` arn:aws:secretsmanager[ID]:secret - my_secrets [number] my_secrets {"API_KEY":"ABCDEFGHI"} [UUID string] VERSIONSTAGES AWSCURRENT ```

2. Does anyone know how I only get the secret ("API_KEY": "ABCDEFGHI")? I need to move these secrets to my register-task-definition environment variables. The best way would be to store them in a file and delete it after us or store them in variable. It is running on a linux machine.

## When to use

You are seeing this: I need to move these secrets to my register-task-definition environment variables. Use this skill when you run into "Parsing secrets from AWS secrets manager using AWS cli".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Stack Overflow #50911540 (accepted answer, 150 votes, 16 answers): I am retrieving secrets I have stored in AWS secrets manager with the AWS cli like this: `` aws secretsmanager get-secret-value --secret-id secrets Which returns arn:aws:secretsmanager[ID]:secret - my_secrets [number] my_secrets {"API_KEY":"ABCDEFGHI"} [UUID string] VERSIONSTAGES AWSCURRENT `` Does anyone know how I only get the secret ("API_KEY": "ABCDEFGHI")? I need to move these secrets to my register-task-definition environment variables. The best way would be to store them in a file and delete it after us or store them in variable. It is running on a linux machine.

Verified resolution: [helloV (accepted answer)] Use the --query option of the CLI to extract just the secret. `` aws secretsmanager get-secret-value --secret-id secrets --query SecretString --output text

Source URL: https://stackoverflow.com/questions/50911540

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_CQMIgf1qvde5C3kyZAhACg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Parsing secrets from AWS secrets manager using AWS cli <span>— Vectle</span></a>