diff --git a/conductor/src/aws/cloudformation.rs b/conductor/src/aws/cloudformation.rs index d35fa9683..57ec9ad00 100644 --- a/conductor/src/aws/cloudformation.rs +++ b/conductor/src/aws/cloudformation.rs @@ -88,11 +88,21 @@ impl AWSConfigState { stack_name: &str, params: &CloudFormationParams, cloudformation_template_bucket: String, + aws_region: String, ) -> Result<(), ConductorError> { - let template_url = format!( - "https://{}.s3.amazonaws.com/{}", - cloudformation_template_bucket, "conductor-cf-template-v2.yaml" - ); + // If region is us-east-1, we don't need to specify the region in the template url + let template_url = if aws_region == "us-east-1" { + format!( + "https://{}.s3.amazonaws.com/{}", + cloudformation_template_bucket, "conductor-cf-template-v2.yaml" + ) + } else { + format!( + "https://{}.s3.{}.amazonaws.com/{}", + cloudformation_template_bucket, aws_region, "conductor-cf-template-v2.yaml" + ) + }; + let parameters = params.clone().parameters(); if !self.does_stack_exist(stack_name).await { // todo(nhudson): We need to add tags to the stack diff --git a/conductor/src/lib.rs b/conductor/src/lib.rs index 6a0a511e0..90f082442 100644 --- a/conductor/src/lib.rs +++ b/conductor/src/lib.rs @@ -400,7 +400,7 @@ pub async fn create_cloudformation( // back to the queue. // If there is an error we will need to alert on it // If we are still waiting for the stack to be created we will need to requeue the message - let region = Region::new(aws_region); + let region = Region::new(aws_region.clone()); let aws_config_state = AWSConfigState::new(region).await; let stack_name = format!("{}-cf", namespace); let iam_role_name = format!("{}-iam", namespace); @@ -416,7 +416,12 @@ pub async fn create_cloudformation( service_account_name, }; aws_config_state - .create_cloudformation_stack(&stack_name, &cf_template_params, cf_template_bucket) + .create_cloudformation_stack( + &stack_name, + &cf_template_params, + cf_template_bucket, + aws_region, + ) .await .map_err(ConductorError::from)?; Ok(())