From 2b6393b5d1db4445ff13fe64baa558e5b32117e4 Mon Sep 17 00:00:00 2001 From: adwhalen <115283320+adwhalen@users.noreply.github.com> Date: Wed, 15 Mar 2023 19:40:43 -0400 Subject: [PATCH] Fixed using {} instead of undefined and to use Fn.select on Fn.getAZs (#92) --- src/synthesizer/typescript_synthesizer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/synthesizer/typescript_synthesizer.rs b/src/synthesizer/typescript_synthesizer.rs index 7672084e..5870a0bb 100644 --- a/src/synthesizer/typescript_synthesizer.rs +++ b/src/synthesizer/typescript_synthesizer.rs @@ -374,7 +374,7 @@ pub fn to_string_ir(resource_value: &ResourceIr) -> Option { ResourceIr::If(bool_expr, true_expr, false_expr) => { let bool_expr = pretty_name(bool_expr); let true_expr = match to_string_ir(true_expr) { - None => String::from("{}"), + None => String::from("undefined"), Some(x) => x, }; let false_expr = match to_string_ir(false_expr) { @@ -417,7 +417,12 @@ pub fn to_string_ir(resource_value: &ResourceIr) -> Option { } ResourceIr::Select(index, obj) => { let str = to_string_ir(obj.as_ref()).unwrap(); - Option::Some(format!("{}[{}]", str, *index)) + match obj as &ResourceIr { + ResourceIr::GetAZs(_) => { + Option::Some(format!("cdk.Fn.select({}, {})", *index, str)) + } + _ => Option::Some(format!("{}[{}]", str, *index)), + } } ResourceIr::Cidr(ip_block, count, cidr_bits) => { let ip_block_str = to_string_ir(ip_block.as_ref()).unwrap();