Skip to content

Commit

Permalink
Parse AWS creds from control plane (#4750)
Browse files Browse the repository at this point in the history
  • Loading branch information
awestover authored Jul 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 87eead5 commit 1b624e7
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 2 additions & 5 deletions compute_tools/src/bin/compute_ctl.rs
Original file line number Diff line number Diff line change
@@ -30,7 +30,8 @@
//! -C 'postgresql://cloud_admin@localhost/postgres' \
//! -S /var/db/postgres/specs/current.json \
//! -b /usr/local/bin/postgres \
//! -r {"bucket": "my-bucket", "region": "eu-central-1", "endpoint": "http:://localhost:9000"} \
//! -r {"bucket": "my-bucket", "region": "eu-central-1", "endpoint": "http:://localhost:9000",
//! (optionally) "key": "AWS_SECRET_ACCESS_KEY", "id": "AWS_ACCESS_KEY_ID"}
//! ```
//!
use std::collections::HashMap;
@@ -72,10 +73,6 @@ fn main() -> Result<()> {
let pgbin = matches.get_one::<String>("pgbin").unwrap_or(&pgbin_default);

let remote_ext_config = matches.get_one::<String>("remote-ext-config");
// NOTE TODO: until control-plane changes, we can use the following line to forcibly enable remote extensions
// let remote_ext_config = Some(
// r#"{"bucket": "neon-dev-extensions", "region": "eu-central-1", "endpoint": null, "prefix": "5555"}"#.to_string(),
// );
let ext_remote_storage = remote_ext_config.map(|x| {
init_remote_storage(x, build_tag)
.expect("cannot initialize remote extension storage from config")
14 changes: 12 additions & 2 deletions compute_tools/src/extension_server.rs
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@ pub async fn download_extension(
Ok(())
}

// This function initializes the necessary structs to use remmote storage (should be fairly cheap)
// This function initializes the necessary structs to use remote storage (should be fairly cheap)
pub fn init_remote_storage(
remote_ext_config: &str,
default_prefix: &str,
@@ -202,7 +202,17 @@ pub fn init_remote_storage(
.unwrap_or(default_prefix)
.to_string();

// TODO: potentially allow modification of other parameters
// control plane passes the aws creds via CLI ARGS to compute_ctl
let aws_key = remote_ext_config["key"].as_str();
let aws_id = remote_ext_config["id"].as_str();
if let Some(aws_key) = aws_key {
if let Some(aws_id) = aws_id {
std::env::set_var("AWS_SECRET_ACCESS_KEY", aws_key);
std::env::set_var("AWS_ACCESS_KEY_ID", aws_id);
}
}

// If needed, it is easy to allow modification of other parameters
// however, default values should be fine for now
let config = S3Config {
bucket_name: remote_ext_bucket.to_string(),

0 comments on commit 1b624e7

Please sign in to comment.