Skip to content

Commit

Permalink
update: reworked location constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Dec 9, 2024
1 parent 47a4675 commit 8892386
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY
AWS_REGION=us-west-1
AWS_REGION=us-east-1
# For Aws sdk
AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566
# For Omniqueue
Expand All @@ -19,7 +19,7 @@ MADARA_ORCHESTRATOR_EVENT_BRIDGE_TRIGGER_POLICY_NAME=madara-orchestrator-worker-

#### ALERTS ####

MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-west-1:000000000000:madara-orchestrator-arn
MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-east-1:000000000000:madara-orchestrator-arn


#### DATA AVAILABILITY ####
Expand Down Expand Up @@ -66,7 +66,7 @@ MADARA_ORCHESTRATOR_ATLANTIC_RPC_NODE_URL=http://127.0.0.1:8545
MADARA_ORCHESTRATOR_SQS_PREFIX=madara_orchestrator
MADARA_ORCHESTRATOR_SQS_SUFFIX=queue
MADARA_ORCHESTRATOR_EVENT_BRIDGE_TARGET_QUEUE_NAME=madara_orchestrator_worker_trigger_queue
MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-west-1.localhost.localstack.cloud:4566/000000000000
MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000

#### SETTLEMENT ####

Expand Down
25 changes: 13 additions & 12 deletions crates/orchestrator/src/data_storage/aws_s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ impl AWSS3 {
// this is necessary for it to work with localstack in test cases
s3_config_builder.set_force_path_style(Some(true));
let client = Client::from_conf(s3_config_builder.build());

let region_str = aws_config.region().expect("Could not get region as string").to_string();
let location_constraint: BucketLocationConstraint = BucketLocationConstraint::from_str(region_str.as_str()).expect("Could not get location constraint from region string");
Self {
client,
bucket: s3_config.bucket_name.clone(),
bucket_location_constraint: location_constraint,
}
let location_constraint: BucketLocationConstraint = BucketLocationConstraint::from_str(region_str.as_str())
.expect("Could not get location constraint from region string");
Self { client, bucket: s3_config.bucket_name.clone(), bucket_location_constraint: location_constraint }
}
}

Expand Down Expand Up @@ -90,11 +87,15 @@ impl DataStorage for AWSS3 {
}

async fn create_bucket(&self, bucket_name: &str) -> Result<()> {
let create_bucket_config = Some(
CreateBucketConfiguration::builder()
.location_constraint(self.bucket_location_constraint.clone())
.build(),
);
let create_bucket_config = if self.bucket_location_constraint.as_str() == "us-east-1" {
Some(CreateBucketConfiguration::builder().build())
} else {
Some(
CreateBucketConfiguration::builder()
.location_constraint(self.bucket_location_constraint.clone())
.build(),
)
};

self.client
.create_bucket()
Expand Down

0 comments on commit 8892386

Please sign in to comment.