@@ -31,6 +31,7 @@ import { Rule } from 'aws-cdk-lib/aws-events';
31
31
import * as targets from 'aws-cdk-lib/aws-events-targets' ;
32
32
import { Policy } from 'aws-cdk-lib/aws-iam' ;
33
33
import {
34
+ Architecture ,
34
35
CfnFunction ,
35
36
ILayerVersion ,
36
37
LayerVersion ,
@@ -134,6 +135,12 @@ export type FunctionProps = {
134
135
*/
135
136
runtime ?: NodeVersion ;
136
137
138
+ /**
139
+ * The architecture of the target platform for the lambda environment.
140
+ * Defaults to X86_64.
141
+ */
142
+ architecture ?: FunctionArchitecture ;
143
+
137
144
/**
138
145
* A time interval string to periodically run the function.
139
146
* This can be either a string of `"every <positive whole number><m (minute) or h (hour)>"`, `"every day|week|month|year"` or cron expression.
@@ -246,6 +253,7 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
246
253
ephemeralStorageSizeMB : this . resolveEphemeralStorageSize ( ) ,
247
254
environment : this . resolveEnvironment ( ) ,
248
255
runtime : this . resolveRuntime ( ) ,
256
+ architecture : this . resolveArchitecture ( ) ,
249
257
schedule : this . resolveSchedule ( ) ,
250
258
bundling : this . resolveBundling ( ) ,
251
259
layers : this . props . layers ?? { } ,
@@ -401,6 +409,25 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
401
409
return this . props . runtime ;
402
410
} ;
403
411
412
+ private resolveArchitecture = ( ) => {
413
+ const architectureDefault = 'x86_64' ;
414
+
415
+ if ( ! this . props . architecture ) {
416
+ return architectureDefault ;
417
+ }
418
+
419
+ if ( ! ( this . props . architecture in architectureMap ) ) {
420
+ throw new AmplifyUserError ( 'InvalidArchitectureError' , {
421
+ message : `Invalid function architecture of ${ this . props . architecture } ` ,
422
+ resolution : `architecture must be one of the following: ${ Object . keys (
423
+ architectureMap
424
+ ) . join ( ', ' ) } `,
425
+ } ) ;
426
+ }
427
+
428
+ return this . props . architecture ;
429
+ } ;
430
+
404
431
private resolveSchedule = ( ) => {
405
432
if ( ! this . props . schedule ) {
406
433
return [ ] ;
@@ -539,6 +566,7 @@ class AmplifyFunction
539
566
entry : props . entry ,
540
567
timeout : Duration . seconds ( props . timeoutSeconds ) ,
541
568
memorySize : props . memoryMB ,
569
+ architecture : architectureMap [ props . architecture ] ,
542
570
ephemeralStorageSize : Size . mebibytes ( props . ephemeralStorageSizeMB ) ,
543
571
runtime : nodeVersionMap [ props . runtime ] ,
544
572
layers : props . resolvedLayers ,
@@ -678,3 +706,10 @@ const nodeVersionMap: Record<NodeVersion, Runtime> = {
678
706
20 : Runtime . NODEJS_20_X ,
679
707
22 : Runtime . NODEJS_22_X ,
680
708
} ;
709
+
710
+ export type FunctionArchitecture = 'x86_64' | 'arm64' ;
711
+
712
+ const architectureMap : Record < FunctionArchitecture , Architecture > = {
713
+ arm64 : Architecture . ARM_64 ,
714
+ x86_64 : Architecture . X86_64 ,
715
+ } ;
0 commit comments