Skip to content

Commit

Permalink
Add Region to CF Bucket Endpoint URL (#802)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Stanton <ian@tembo.io>
  • Loading branch information
ianstanton committed May 30, 2024
1 parent 6d0c3cb commit 51e82c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 14 additions & 4 deletions conductor/src/aws/cloudformation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions conductor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(())
Expand Down

0 comments on commit 51e82c9

Please sign in to comment.