Skip to content

Commit 5d32cf1

Browse files
committed
s3 blob storage config - credentials, path style
1 parent 587d454 commit 5d32cf1

File tree

7 files changed

+69
-16
lines changed

7 files changed

+69
-16
lines changed

golem-component-compilation-service/config/component-compilation-service.sample.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ GOLEM__TRACING__STDOUT__WITHOUT_TIME=false
6363
GOLEM__HTTP_HOST="0.0.0.0"
6464
GOLEM__HTTP_PORT=8084
6565
GOLEM__BLOB_STORAGE__TYPE="S3"
66+
#GOLEM__BLOB_STORAGE__CONFIG__AWS_CREDENTIALS=
6667
#GOLEM__BLOB_STORAGE__CONFIG__AWS_ENDPOINT_URL=
68+
#GOLEM__BLOB_STORAGE__CONFIG__AWS_PATH_STYLE=
6769
GOLEM__BLOB_STORAGE__CONFIG__COMPILATION_CACHE_BUCKET="golem-compiled-components"
6870
GOLEM__BLOB_STORAGE__CONFIG__COMPONENTS_BUCKET="component-store"
6971
GOLEM__BLOB_STORAGE__CONFIG__COMPRESSED_OPLOG_BUCKETS=["oplog-archive-1"]
@@ -73,7 +75,6 @@ GOLEM__BLOB_STORAGE__CONFIG__OBJECT_PREFIX=""
7375
GOLEM__BLOB_STORAGE__CONFIG__OPLOG_PAYLOAD_BUCKET="oplog-payload"
7476
GOLEM__BLOB_STORAGE__CONFIG__PLUGIN_WASM_FILES_BUCKET="golem-plugin-wasm-files"
7577
GOLEM__BLOB_STORAGE__CONFIG__REGION="us-east-1"
76-
GOLEM__BLOB_STORAGE__CONFIG__USE_MINIO_CREDENTIALS=false
7778
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_ATTEMPTS=3
7879
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_DELAY="1s"
7980
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_JITTER_FACTOR=0.15

golem-component-compilation-service/config/component-compilation-service.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ without_time = false
110110
# oplog_payload_bucket = "oplog-payload"
111111
# plugin_wasm_files_bucket = "golem-plugin-wasm-files"
112112
# region = "us-east-1"
113-
# use_minio_credentials = false
114113
#
115114
# [blob_storage.config.retries]
116115
# max_attempts = 3

golem-service-base/src/config.rs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,49 @@ impl BlobStorageConfig {
9696
}
9797
}
9898

99+
#[derive(Clone, Debug, Serialize, Deserialize)]
100+
pub struct S3BlobStorageCredentialsConfig {
101+
pub access_key_id: String,
102+
pub secret_access_key: String,
103+
pub provider_name: String,
104+
}
105+
106+
impl S3BlobStorageCredentialsConfig {
107+
pub fn new(
108+
access_key_id: impl Into<String>,
109+
secret_access_key: impl Into<String>,
110+
provider_name: impl Into<String>,
111+
) -> Self {
112+
Self {
113+
access_key_id: access_key_id.into(),
114+
secret_access_key: secret_access_key.into(),
115+
provider_name: provider_name.into(),
116+
}
117+
}
118+
}
119+
120+
impl SafeDisplay for S3BlobStorageCredentialsConfig {
121+
fn to_safe_string(&self) -> String {
122+
let mut result = String::new();
123+
let _ = writeln!(&mut result, "access key id: ****");
124+
let _ = writeln!(&mut result, "secret access key: ****");
125+
let _ = writeln!(&mut result, "provider name: {}", self.provider_name);
126+
result
127+
}
128+
}
129+
99130
#[derive(Clone, Debug, Serialize, Deserialize)]
100131
pub struct S3BlobStorageConfig {
101132
pub retries: RetryConfig,
102133
pub region: String,
103134
pub object_prefix: String,
104135
pub aws_endpoint_url: Option<String>,
136+
pub aws_credentials: Option<S3BlobStorageCredentialsConfig>,
137+
pub aws_path_style: Option<bool>,
105138
pub compilation_cache_bucket: String,
106139
pub custom_data_bucket: String,
107140
pub oplog_payload_bucket: String,
108141
pub compressed_oplog_buckets: Vec<String>,
109-
pub use_minio_credentials: bool,
110142
pub initial_component_files_bucket: String,
111143
pub components_bucket: String,
112144
pub plugin_wasm_files_bucket: String,
@@ -123,6 +155,13 @@ impl SafeDisplay for S3BlobStorageConfig {
123155
if let Some(endpoint_url) = &self.aws_endpoint_url {
124156
let _ = writeln!(&mut result, "aws_endpoint_url: {endpoint_url}");
125157
}
158+
if let Some(aws_credentials) = &self.aws_credentials {
159+
let _ = writeln!(&mut result, "aws_credentials:");
160+
let _ = writeln!(&mut result, "{}", aws_credentials.to_safe_string_indented());
161+
}
162+
if let Some(path_style) = &self.aws_path_style {
163+
let _ = writeln!(&mut result, "aws_path_style: {path_style}");
164+
}
126165
let _ = writeln!(
127166
&mut result,
128167
"compilation cache bucket: {}",
@@ -143,11 +182,6 @@ impl SafeDisplay for S3BlobStorageConfig {
143182
"compressed oplog buckets: {:?}",
144183
self.compressed_oplog_buckets
145184
);
146-
let _ = writeln!(
147-
&mut result,
148-
"use MinIO credentials: {}",
149-
self.use_minio_credentials
150-
);
151185
let _ = writeln!(
152186
&mut result,
153187
"initial component files bucket: {}",
@@ -174,8 +208,9 @@ impl Default for S3BlobStorageConfig {
174208
oplog_payload_bucket: "oplog-payload".to_string(),
175209
object_prefix: "".to_string(),
176210
aws_endpoint_url: None,
211+
aws_credentials: None,
212+
aws_path_style: None,
177213
compressed_oplog_buckets: vec!["oplog-archive-1".to_string()],
178-
use_minio_credentials: false,
179214
initial_component_files_bucket: "golem-initial-component-files".to_string(),
180215
components_bucket: "component-store".to_string(),
181216
plugin_wasm_files_bucket: "golem-plugin-wasm-files".to_string(),

golem-service-base/src/storage/blob/s3.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,29 @@ impl S3BlobStorage {
5858
config_builder = config_builder.endpoint_url(endpoint_url);
5959
}
6060

61-
if config.use_minio_credentials {
62-
let creds = Credentials::new("minioadmin", "minioadmin", None, None, "test");
61+
if let Some(credentials) = config.aws_credentials.clone() {
62+
let creds = Credentials::new(
63+
credentials.access_key_id,
64+
credentials.secret_access_key,
65+
None,
66+
None,
67+
credentials.provider_name.leak(),
68+
);
6369
config_builder = config_builder.credentials_provider(creds);
6470
}
6571

6672
let sdk_config = config_builder.load().await;
6773

74+
let s3_config: aws_sdk_s3::config::Config = (&sdk_config).into();
75+
76+
let s3_config = if let Some(path_style) = &config.aws_path_style {
77+
s3_config.to_builder().force_path_style(*path_style).build()
78+
} else {
79+
s3_config
80+
};
81+
6882
Self {
69-
client: aws_sdk_s3::Client::new(&sdk_config),
83+
client: aws_sdk_s3::Client::from_conf(s3_config),
7084
config,
7185
}
7286
}

golem-service-base/tests/blob_storage.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use futures::stream::BoxStream;
2424
use golem_common::model::component::ComponentId;
2525
use golem_common::model::environment::EnvironmentId;
2626
use golem_common::widen_infallible;
27-
use golem_service_base::config::S3BlobStorageConfig;
27+
use golem_service_base::config::{S3BlobStorageConfig, S3BlobStorageCredentialsConfig};
2828
use golem_service_base::db::sqlite::SqlitePool;
2929
use golem_service_base::replayable_stream::ErasedReplayableStream;
3030
use golem_service_base::replayable_stream::ReplayableStream;
@@ -128,7 +128,11 @@ impl GetBlobStorage for S3Test {
128128
region: "us-east-1".to_string(),
129129
object_prefix: self.prefixed.clone().unwrap_or_default(),
130130
aws_endpoint_url: Some(format!("http://127.0.0.1:{host_port}")),
131-
use_minio_credentials: true,
131+
aws_credentials: Some(S3BlobStorageCredentialsConfig::new(
132+
"minioadmin",
133+
"minioadmin",
134+
"test",
135+
)),
132136
..std::default::Default::default()
133137
};
134138
create_buckets(host_port, &config).await;

golem-worker-executor/config/worker-executor.sample.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ GOLEM__ACTIVE_WORKERS__TTL="8h"
155155
GOLEM__AGENT_TYPES_SERVICE__TYPE="Grpc"
156156
GOLEM__AGENT_TYPES_SERVICE__CONFIG__CACHE_TIME_TO_IDLE="1m"
157157
GOLEM__BLOB_STORAGE__TYPE="S3"
158+
#GOLEM__BLOB_STORAGE__CONFIG__AWS_CREDENTIALS=
158159
#GOLEM__BLOB_STORAGE__CONFIG__AWS_ENDPOINT_URL=
160+
#GOLEM__BLOB_STORAGE__CONFIG__AWS_PATH_STYLE=
159161
GOLEM__BLOB_STORAGE__CONFIG__COMPILATION_CACHE_BUCKET="golem-compiled-components"
160162
GOLEM__BLOB_STORAGE__CONFIG__COMPONENTS_BUCKET="component-store"
161163
GOLEM__BLOB_STORAGE__CONFIG__COMPRESSED_OPLOG_BUCKETS=["oplog-archive-1"]
@@ -165,7 +167,6 @@ GOLEM__BLOB_STORAGE__CONFIG__OBJECT_PREFIX=""
165167
GOLEM__BLOB_STORAGE__CONFIG__OPLOG_PAYLOAD_BUCKET="oplog-payload"
166168
GOLEM__BLOB_STORAGE__CONFIG__PLUGIN_WASM_FILES_BUCKET="golem-plugin-wasm-files"
167169
GOLEM__BLOB_STORAGE__CONFIG__REGION="us-east-1"
168-
GOLEM__BLOB_STORAGE__CONFIG__USE_MINIO_CREDENTIALS=false
169170
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_ATTEMPTS=3
170171
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_DELAY="1s"
171172
GOLEM__BLOB_STORAGE__CONFIG__RETRIES__MAX_JITTER_FACTOR=0.15

golem-worker-executor/config/worker-executor.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ without_time = false
262262
# oplog_payload_bucket = "oplog-payload"
263263
# plugin_wasm_files_bucket = "golem-plugin-wasm-files"
264264
# region = "us-east-1"
265-
# use_minio_credentials = false
266265
#
267266
# [blob_storage.config.retries]
268267
# max_attempts = 3

0 commit comments

Comments
 (0)