@@ -119,6 +119,10 @@ pub struct RunArgs {
119119 /// The ARN of the role that the Lambda will execute as
120120 #[ clap( long, required_unless_present = "cdk-output" ) ]
121121 lambda_execution_role_arn : Option < String > ,
122+
123+ /// Lambda architecture to target (x86_64 or arm64)
124+ #[ clap( long, default_value = "x86_64" ) ]
125+ architecture : crate :: build_bundle:: LambdaArchitecture ,
122126}
123127
124128#[ derive( Debug , Eq , PartialEq ) ]
@@ -127,6 +131,7 @@ struct Options {
127131 sdk_release_tag : Option < ReleaseTag > ,
128132 sdk_path : Option < PathBuf > ,
129133 musl : bool ,
134+ architecture : crate :: build_bundle:: LambdaArchitecture ,
130135 expected_speech_text_by_transcribe : Option < String > ,
131136 lambda_function_memory_size_in_mb : i32 ,
132137 lambda_code_s3_bucket_name : String ,
@@ -194,6 +199,7 @@ impl Options {
194199 sdk_release_tag : run_opt. sdk_release_tag ,
195200 sdk_path : run_opt. sdk_path ,
196201 musl : run_opt. musl ,
202+ architecture : run_opt. architecture ,
197203 expected_speech_text_by_transcribe : run_opt. expected_speech_text_by_transcribe ,
198204 lambda_function_memory_size_in_mb : run_opt
199205 . lambda_function_memory_size_in_mb
@@ -210,6 +216,7 @@ impl Options {
210216 sdk_release_tag : run_opt. sdk_release_tag ,
211217 sdk_path : run_opt. sdk_path ,
212218 musl : run_opt. musl ,
219+ architecture : run_opt. architecture ,
213220 expected_speech_text_by_transcribe : run_opt. expected_speech_text_by_transcribe ,
214221 lambda_function_memory_size_in_mb : run_opt
215222 . lambda_function_memory_size_in_mb
@@ -362,6 +369,7 @@ async fn build_bundle(options: &Options) -> Result<PathBuf> {
362369 sdk_release_tag : options. sdk_release_tag . clone ( ) ,
363370 sdk_path : options. sdk_path . clone ( ) ,
364371 musl : options. musl ,
372+ architecture : options. architecture ,
365373 manifest_only : false ,
366374 } ;
367375 info ! ( "Compiling the canary bundle for Lambda with {build_args:?}. This may take a few minutes..." ) ;
@@ -430,10 +438,16 @@ async fn create_lambda_fn(
430438 ) ,
431439 } ;
432440
441+ let lambda_arch = match options. architecture {
442+ crate :: build_bundle:: LambdaArchitecture :: X86_64 => Architecture :: X8664 ,
443+ crate :: build_bundle:: LambdaArchitecture :: Arm64 => Architecture :: Arm64 ,
444+ } ;
445+
433446 lambda_client
434447 . create_function ( )
435448 . function_name ( bundle_name)
436449 . runtime ( Runtime :: Providedal2 )
450+ . architectures ( lambda_arch)
437451 . role ( & options. lambda_execution_role_arn )
438452 . handler ( "aws-sdk-rust-lambda-canary" )
439453 . code (
@@ -544,6 +558,7 @@ async fn delete_lambda_fn(lambda_client: lambda::Client, bundle_name: &str) -> R
544558
545559#[ cfg( test) ]
546560mod tests {
561+ use crate :: build_bundle:: LambdaArchitecture ;
547562 use crate :: run:: { Options , RunArgs , DEFAULT_LAMBDA_FUNCTION_MEMORY_SIZE_IN_MB } ;
548563 use clap:: Parser ;
549564
@@ -562,7 +577,8 @@ mod tests {
562577 lambda_test_s3_bucket_name: None ,
563578 lambda_execution_role_arn: None ,
564579 lambda_test_s3_mrap_bucket_arn: None ,
565- lambda_test_s3_express_bucket_name: None
580+ lambda_test_s3_express_bucket_name: None ,
581+ architecture: LambdaArchitecture :: X86_64 ,
566582 } ,
567583 RunArgs :: try_parse_from( [
568584 "run" ,
@@ -605,6 +621,7 @@ mod tests {
605621 sdk_release_tag: None ,
606622 sdk_path: Some ( "artifact-aws-sdk-rust/sdk" . into( ) ) ,
607623 musl: false ,
624+ architecture: LambdaArchitecture :: X86_64 ,
608625 expected_speech_text_by_transcribe: Some ( "Good day to you transcribe." . to_owned( ) ) ,
609626 lambda_function_memory_size_in_mb: DEFAULT_LAMBDA_FUNCTION_MEMORY_SIZE_IN_MB ,
610627 lambda_code_s3_bucket_name: "bucket-for-code" . to_owned( ) ,
0 commit comments