Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Gracefully handle invalid input
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergei Smolianinov committed Aug 7, 2023
1 parent 0421914 commit 5195530
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vector-aws-secrets-helper

A helper tool for [Vector](https://vector.dev/) to securely retrieve secrets from AWS SSM Parameter Store and AWS
Secrets Manager using the [exec](https://vector.dev/docs/reference/configuration/global-options/#secret.exec) backend.
Secrets Manager using the [exec](https://vector.dev/highlights/2022-07-07-secrets-management/) backend.

## Installation

Expand Down
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ async fn main() {
// Parse the CLI arguments.
let cli = Cli::parse();

// Parse the JSON from stdin into a SecretsToFetch struct. It assumes that Vector will always
// provide valid JSON, so we can simply unwrap the result. Probably should implement proper
// pattern matching for the result here at some point instead.
let secrets_to_fetch: vector::SecretsToFetch =
serde_json::from_reader(std::io::stdin()).unwrap();
// Parse the JSON from stdin into a SecretsToFetch struct.
let secrets_to_fetch: vector::SecretsToFetch = match serde_json::from_reader(std::io::stdin()) {
Ok(secrets_to_fetch) => secrets_to_fetch,
Err(_) => {
eprintln!("failed to parse JSON from stdin");
std::process::exit(1);
}
};

// Load the AWS SDK config using the default credential provider chain.
let aws_sdk_config = aws_config::load_from_env().await;
Expand Down

0 comments on commit 5195530

Please sign in to comment.