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

Aws secrets manager simple strings and error checking #1292

Merged
merged 6 commits into from
Dec 13, 2024

Conversation

nickhammond
Copy link
Contributor

String-based secrets

SecretString can technically be a regular string value and not a JSON object, this PR adds support to fallback to the simple string value when JSON parsing fails.

https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_SecretValueEntry.html

You still fetch the value out the same way as a JSON-based secret but from there you can process however you need.

SECRETS=$(kamal secrets fetch --adapter aws_secrets_manager --from PG_PASSWORD)

PG_PASSWORD=$(kamal secrets extract PG_PASSWORD $SECRETS)

Errors

I also noticed that errors are not returned with a return code from the CLI but within the Errors array. Before this PR it just returns an empty secret value for an unknown secret, this PR checks the Errors array and prints out a message(from AWS) for each error.

Current output:

$ kamal secrets fetch --adapter aws_secrets_manager unknown-secret
\{\}

Updated output:

$ kamal secrets fetch --adapter aws_secrets_manager unknown-secret
ERROR (RuntimeError): unknown-secret: Secrets Manager can't find the specified secret.

https://docs.aws.amazon.com/cli/latest/reference/secretsmanager/batch-get-secret-value.html (Output -> Errors)

@djmb djmb merged commit d9c2553 into basecamp:main Dec 13, 2024
8 checks passed
@nickhammond nickhammond deleted the aws-secrets-manager-simple branch December 13, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants