Skip to content

Commit 046b00a

Browse files
committed
always check S3 Tables region
1 parent 7a2fee6 commit 046b00a

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

src/sql/src/pure.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,34 @@ async fn purify_create_sink(
563563
}
564564
};
565565

566+
// For S3 Tables connections in the Materialize Cloud product, verify the
567+
// AWS region matches the environment's region. This check only applies when
568+
// the enable_s3_tables_region_check dyncfg is set.
569+
if let Some(s3tables) = connection.s3tables_catalog() {
570+
let enable_region_check =
571+
ENABLE_S3_TABLES_REGION_CHECK.get(scx.catalog.system_vars().dyncfgs());
572+
if enable_region_check {
573+
let env_id = &catalog.config().environment_id;
574+
if matches!(env_id.cloud_provider(), CloudProvider::Aws) {
575+
let env_region = env_id.cloud_provider_region();
576+
// Later on we default to "us-east-1" if the region is not set on the S3 Tables
577+
// connection, so we need to do the same check here.
578+
let s3_tables_region = s3tables
579+
.aws_connection
580+
.connection
581+
.region
582+
.clone()
583+
.unwrap_or_else(|| "us-east-1".to_string());
584+
if s3_tables_region != env_region {
585+
Err(IcebergSinkPurificationError::S3TablesRegionMismatch {
586+
s3_tables_region,
587+
environment_region: env_region.to_string(),
588+
})?;
589+
}
590+
}
591+
}
592+
}
593+
566594
// Validate the sink's (optional) AWS connection even though we never use it.
567595
// TODO(kynan): If we do start using the sink's creds, check again that this validation
568596
// accurately reflects what we need.
@@ -582,34 +610,6 @@ async fn purify_create_sink(
582610
}
583611
};
584612

585-
// For S3 Tables connections in the Materialize Cloud product, verify the
586-
// AWS region matches the environment's region. This check only applies when
587-
// the enable_s3_tables_region_check dyncfg is set.
588-
if let Some(s3tables) = connection.s3tables_catalog() {
589-
let enable_region_check =
590-
ENABLE_S3_TABLES_REGION_CHECK.get(scx.catalog.system_vars().dyncfgs());
591-
if enable_region_check {
592-
let env_id = &catalog.config().environment_id;
593-
if matches!(env_id.cloud_provider(), CloudProvider::Aws) {
594-
let env_region = env_id.cloud_provider_region();
595-
// Later on we default to "us-east-1" if the region is not set on the S3 Tables
596-
// connection, so we need to do the same check here.
597-
let s3_tables_region = s3tables
598-
.aws_connection
599-
.connection
600-
.region
601-
.clone()
602-
.unwrap_or_else(|| "us-east-1".to_string());
603-
if s3_tables_region != env_region {
604-
Err(IcebergSinkPurificationError::S3TablesRegionMismatch {
605-
s3_tables_region,
606-
environment_region: env_region.to_string(),
607-
})?;
608-
}
609-
}
610-
}
611-
}
612-
613613
let _sdk_config = aws_connection
614614
.load_sdk_config(
615615
&storage_configuration.connection_context,

0 commit comments

Comments
 (0)