Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 7e12d61

Browse files
committed
Allow innit to take in env variables
This changes allows innit to take in env variables. This can be configured by environment variable or command line argument with the new "mode" type. It contains two variants: "env" and "ssm". If the mode is not provided, it defaults to "ssm", which ensures innit runs as it does on main today. If "env" is provided, then innit will take in environment variables to configure all services rather than using ssm. The environment variable use case may not be that interesting on its own, but innit being able to be used across several verticals and cloud providers in the future helps standardize the SI initialization procedure. Theorhetically, a secrets manager provided by a helm chart on a k8s cluster can do the same thing. For now, innit's env var use case is valuable. We'll see how long that will remain to be the case. Signed-off-by: Nick Gerace <nick@systeminit.com>
1 parent b9cd8d4 commit 7e12d61

14 files changed

Lines changed: 246 additions & 24 deletions

File tree

‎Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bin/innit/src/args.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use innit_server::{
88
Config,
99
ConfigError,
1010
ConfigFile,
11+
Mode,
1112
StandardConfigFile,
1213
};
1314
use si_service::prelude::*;
@@ -78,6 +79,15 @@ pub(crate) struct Args {
7879
/// The address and port to bind the HTTP server to [example: 0.0.0.0:80]
7980
#[arg(long, env)]
8081
pub(crate) socket_addr: Option<String>,
82+
83+
/// Mode for parameter storage backend [options: env, ssm]
84+
#[arg(
85+
long = "mode",
86+
env = "SI_INNIT_MODE",
87+
default_value = "ssm",
88+
hide_env_values = true
89+
)]
90+
pub(crate) mode: Mode,
8191
}
8292

8393
impl TryFrom<Args> for Config {
@@ -91,6 +101,7 @@ impl TryFrom<Args> for Config {
91101
if let Some(socket_addr) = args.socket_addr {
92102
config_map.set("socket_addr", socket_addr);
93103
}
104+
config_map.set("mode", args.mode.to_string());
94105
})?
95106
.try_into()
96107
}

‎lib/innit-core/BUCK‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ rust_library(
44
name = "innit-core",
55
deps = [
66
"//lib/config-file:config-file",
7-
87
"//third-party/rust:aws-sdk-ssm",
9-
"//third-party/rust:chrono",
10-
"//third-party/rust:serde",
11-
"//third-party/rust:serde_json",
12-
"//third-party/rust:ulid"
8+
"//third-party/rust:serde"
139
],
1410
srcs = glob([
1511
"src/**/*.rs",

‎lib/innit-server/BUCK‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ rust_library(
1010
"//lib/si-settings:si-settings",
1111
"//lib/si-std:si-std",
1212
"//lib/si-tls:si-tls",
13-
1413
"//lib/telemetry-rs:telemetry",
1514
"//third-party/rust:axum",
1615
"//third-party/rust:dashmap",
@@ -21,6 +20,7 @@ rust_library(
2120
"//third-party/rust:remain",
2221
"//third-party/rust:serde",
2322
"//third-party/rust:serde_json",
23+
"//third-party/rust:strum",
2424
"//third-party/rust:thiserror",
2525
"//third-party/rust:tokio",
2626
"//third-party/rust:tokio-rustls",

‎lib/innit-server/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ si-data-ssm = { path = "../../lib/si-data-ssm" }
2424
si-settings = { path = "../../lib/si-settings" }
2525
si-std = { path = "../../lib/si-std" }
2626
si-tls = { path = "../../lib/si-tls" }
27+
strum = { workspace = true }
2728
telemetry = { path = "../../lib/telemetry-rs" }
2829
thiserror = { workspace = true }
2930
tokio = { workspace = true }

‎lib/innit-server/src/app_state.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use axum::extract::FromRef;
2-
use si_data_ssm::ParameterStoreClient;
2+
use si_data_ssm::ParameterStorageBackend;
33
use tokio_util::sync::CancellationToken;
44

55
use crate::parameter_cache::ParameterCache;
@@ -11,20 +11,20 @@ pub enum ShutdownSource {}
1111
#[derive(Clone, Debug, FromRef)]
1212
pub struct AppState {
1313
pub parameter_cache: ParameterCache,
14-
pub parameter_store_client: ParameterStoreClient,
14+
pub parameter_storage: ParameterStorageBackend,
1515
shutdown_token: CancellationToken,
1616
}
1717

1818
impl AppState {
1919
#[allow(clippy::too_many_arguments)]
2020
pub fn new(
2121
parameter_cache: ParameterCache,
22-
parameter_store_client: ParameterStoreClient,
22+
parameter_storage: ParameterStorageBackend,
2323
shutdown_token: CancellationToken,
2424
) -> Self {
2525
Self {
2626
parameter_cache,
27-
parameter_store_client,
27+
parameter_storage,
2828
shutdown_token,
2929
}
3030
}

‎lib/innit-server/src/config.rs‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ use si_std::{
1919
CanonicalFileError,
2020
};
2121
use si_tls::CertificateSource;
22+
use strum::{
23+
Display,
24+
EnumString,
25+
};
2226
use telemetry::prelude::*;
2327
use thiserror::Error;
2428
use ulid::Ulid;
@@ -49,7 +53,19 @@ impl ConfigError {
4953

5054
type Result<T> = std::result::Result<T, ConfigError>;
5155

52-
/// The config for the forklift server.
56+
#[remain::sorted]
57+
#[derive(
58+
Debug, Default, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, EnumString, Display,
59+
)]
60+
#[serde(rename_all = "lowercase")]
61+
#[strum(serialize_all = "lowercase")]
62+
pub enum Mode {
63+
Env,
64+
#[default]
65+
Ssm,
66+
}
67+
68+
/// The config for the server.
5369
#[derive(Debug, Builder)]
5470
pub struct Config {
5571
#[builder(default = "default_cache_ttl()")]
@@ -78,6 +94,9 @@ pub struct Config {
7894

7995
#[builder(default)]
8096
dev_mode: bool,
97+
98+
#[builder(default = "Mode::default()")]
99+
mode: Mode,
81100
}
82101

83102
impl StandardConfig for Config {
@@ -124,6 +143,10 @@ impl Config {
124143
pub fn client_ca_arns(&self) -> Option<&Vec<String>> {
125144
self.client_ca_arns.as_ref()
126145
}
146+
147+
pub fn mode(&self) -> Mode {
148+
self.mode
149+
}
127150
}
128151

129152
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -147,6 +170,9 @@ pub struct ConfigFile {
147170

148171
#[serde(default)]
149172
pub dev_mode: bool,
173+
174+
#[serde(default)]
175+
mode: Mode,
150176
}
151177

152178
impl Default for ConfigFile {
@@ -161,6 +187,7 @@ impl Default for ConfigFile {
161187
socket_addr: get_default_socket_addr(),
162188
test_endpoint: default_test_endpoint(),
163189
dev_mode: false,
190+
mode: Mode::default(),
164191
}
165192
}
166193
}
@@ -182,6 +209,7 @@ impl TryFrom<ConfigFile> for Config {
182209
config.instance_id(value.instance_id);
183210
config.quiescent_period(Duration::from_secs(value.quiescent_period_secs));
184211
config.dev_mode(value.dev_mode);
212+
config.mode(value.mode);
185213
config.build().map_err(Into::into)
186214
}
187215
}

‎lib/innit-server/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub use self::{
1111
Config,
1212
ConfigError,
1313
ConfigFile,
14+
Mode,
1415
StandardConfigFile,
1516
detect_and_configure_development,
1617
},

‎lib/innit-server/src/routes/create_parameter.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use innit_core::{
1010
CreateParameterResponse,
1111
Parameter,
1212
};
13+
use si_data_ssm::ParameterStorage;
1314
use telemetry::tracing::info;
1415

1516
use super::AppError;
@@ -19,7 +20,7 @@ pub async fn create_parameter_route(
1920
Path(name): Path<String>,
2021
State(AppState {
2122
parameter_cache,
22-
parameter_store_client,
23+
parameter_storage,
2324
..
2425
}): State<AppState>,
2526
Json(CreateParameterRequest { value }): Json<CreateParameterRequest>,
@@ -30,7 +31,7 @@ pub async fn create_parameter_route(
3031
name.clone()
3132
};
3233

33-
parameter_store_client
34+
parameter_storage
3435
.create_string_parameter(name.clone(), value.clone())
3536
.await?;
3637

‎lib/innit-server/src/routes/get_parameter.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use innit_core::{
66
GetParameterResponse,
77
Parameter,
88
};
9+
use si_data_ssm::ParameterStorage;
910
use telemetry::tracing::info;
1011

1112
use super::AppError;
@@ -18,7 +19,7 @@ pub async fn get_parameter_route(
1819
Path(name): Path<String>,
1920
State(AppState {
2021
parameter_cache,
21-
parameter_store_client,
22+
parameter_storage,
2223
..
2324
}): State<AppState>,
2425
) -> Result<Json<GetParameterResponse>, AppError> {
@@ -36,7 +37,7 @@ pub async fn get_parameter_route(
3637
}));
3738
}
3839

39-
let parameter: Parameter = parameter_store_client
40+
let parameter: Parameter = parameter_storage
4041
.get_parameter(name.clone())
4142
.await?
4243
.into();

0 commit comments

Comments
 (0)