@@ -15,15 +15,14 @@ use std::time::Duration;
15
15
use bytesize:: ByteSize ;
16
16
use mz_build_info:: BuildInfo ;
17
17
use mz_catalog;
18
- use mz_cloud_resources:: AwsExternalIdPrefix ;
19
18
use mz_controller:: clusters:: ReplicaAllocation ;
20
19
use mz_orchestrator:: MemoryLimit ;
21
20
use mz_ore:: cast:: CastFrom ;
22
21
use mz_ore:: metrics:: MetricsRegistry ;
23
- use mz_repr:: GlobalId ;
24
22
use mz_secrets:: SecretsReader ;
25
23
use mz_sql:: catalog:: EnvironmentId ;
26
24
use mz_sql:: session:: vars:: ConnectionCounter ;
25
+ use mz_storage_types:: connections:: aws:: AwsPrincipalContext ;
27
26
use serde:: { Deserialize , Serialize } ;
28
27
29
28
use crate :: config:: SystemParameterSyncConfig ;
@@ -223,61 +222,3 @@ impl Default for ClusterReplicaSizeMap {
223
222
Self ( inner)
224
223
}
225
224
}
226
-
227
- /// Context used to generate an AWS Principal.
228
- ///
229
- /// In the case of AWS PrivateLink connections, Materialize will connect to the
230
- /// VPC endpoint as the AWS Principal generated via this context.
231
- #[ derive( Debug , Clone , Serialize ) ]
232
- pub struct AwsPrincipalContext {
233
- pub aws_account_id : String ,
234
- pub aws_external_id_prefix : AwsExternalIdPrefix ,
235
- }
236
-
237
- impl AwsPrincipalContext {
238
- pub fn to_privatelink_principal_string ( & self , aws_external_id_suffix : GlobalId ) -> String {
239
- format ! (
240
- "arn:aws:iam::{}:role/mz_{}_{}" ,
241
- self . aws_account_id, self . aws_external_id_prefix, aws_external_id_suffix
242
- )
243
- }
244
-
245
- pub fn to_aws_connection_principal_string ( & self ) -> String {
246
- format ! (
247
- "arn:aws:iam::{}:role/MaterializeConnection" ,
248
- self . aws_account_id
249
- )
250
- }
251
-
252
- pub fn to_aws_connection_external_id ( & self , aws_external_id_suffix : GlobalId ) -> String {
253
- format ! (
254
- "mz_{}_{}" ,
255
- self . aws_external_id_prefix, aws_external_id_suffix
256
- )
257
- }
258
-
259
- pub fn to_aws_example_trust_policy (
260
- & self ,
261
- aws_external_id_suffix : GlobalId ,
262
- ) -> serde_json:: Value {
263
- serde_json:: json!(
264
- {
265
- "Version" : "2012-10-17" ,
266
- "Statement" : [
267
- {
268
- "Effect" : "Allow" ,
269
- "Principal" : {
270
- "AWS" : self . to_aws_connection_principal_string( )
271
- } ,
272
- "Action" : "sts:AssumeRole" ,
273
- "Condition" : {
274
- "StringEquals" : {
275
- "sts:ExternalId" : self . to_aws_connection_external_id( aws_external_id_suffix)
276
- }
277
- }
278
- }
279
- ]
280
- }
281
- )
282
- }
283
- }
0 commit comments