Skip to content

Commit 9d38748

Browse files
mgrandisvalerena
andauthored
feat: ARM support (#2163)
* feat: ARM architecture support for Function and Layer * Add docs/tests for Globals Architectures (#85) Co-authored-by: Renato Valenzuela <[email protected]>
1 parent 9418439 commit 9d38748

File tree

44 files changed

+996
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+996
-17
lines changed

docs/globals.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Currently, the following resources and properties are being supported:
7070
PermissionsBoundary:
7171
ReservedConcurrentExecutions:
7272
EventInvokeConfig:
73+
Architectures:
7374
7475
Api:
7576
# Properties of AWS::Serverless::Api

integration/config/region_service_exclusion.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@ regions:
88
- IoT
99
- GatewayResponses
1010
- HttpApi
11+
- ARM
1112
ap-east-1:
1213
- Cognito
1314
- IoT
1415
- ServerlessRepo
1516
- HttpApi
17+
- ARM
1618
ap-northeast-2:
1719
- HttpApi
20+
- ARM
1821
ap-northeast-3:
1922
- Cognito
2023
- IoT
2124
- ServerlessRepo
2225
- XRay
2326
- CodeDeploy
2427
- HttpApi
28+
- ARM
2529
ap-south-1:
2630
- HttpApi
2731
ap-southeast-1:
@@ -30,6 +34,7 @@ regions:
3034
- Cognito
3135
- IoT
3236
- HttpApi
37+
- ARM
3338
cn-north-1:
3439
- ServerlessRepo
3540
- Cognito
@@ -39,6 +44,7 @@ regions:
3944
- IoT
4045
- GatewayResponses
4146
- HttpApi
47+
- ARM
4248
cn-northwest-1:
4349
- ServerlessRepo
4450
- Cognito
@@ -48,12 +54,14 @@ regions:
4854
- IoT
4955
- GatewayResponses
5056
- HttpApi
57+
- ARM
5158
eu-north-1:
5259
- ServerlessRepo
5360
- Cognito
5461
- IoT
5562
- HttpApi
5663
- Layers
64+
- ARM
5765
eu-south-1:
5866
- ServerlessRepo
5967
- Cognito
@@ -63,24 +71,29 @@ regions:
6371
- IoT
6472
- GatewayResponses
6573
- HttpApi
74+
- ARM
6675
eu-west-2:
6776
- HttpApi
6877
eu-west-3:
6978
- Cognito
7079
- IoT
7180
- XRay
7281
- HttpApi
82+
- ARM
7383
me-south-1:
7484
- ServerlessRepo
7585
- Cognito
7686
- IoT
7787
- HttpApi
88+
- ARM
7889
sa-east-1:
7990
- IoT
8091
- Cognito
8192
- HttpApi
93+
- ARM
8294
us-east-2:
8395
- HttpApi
8496
us-west-1:
8597
- Cognito
8698
- IoT
99+
- ARM
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"LogicalResourceId": "MyLambdaFunction",
4+
"ResourceType": "AWS::Lambda::Function"
5+
},
6+
{
7+
"LogicalResourceId": "MyLambdaFunctionRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
}
10+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"LogicalResourceId": "MyLambdaFunction",
4+
"ResourceType": "AWS::Lambda::Function"
5+
},
6+
{
7+
"LogicalResourceId": "MyLambdaFunctionRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
}
10+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
{ "LogicalResourceId":"MyLayerVersion", "ResourceType":"AWS::Lambda::LayerVersion"}
3+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Resources:
2+
MyLambdaFunction:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
Handler: index.handler
6+
Runtime: nodejs12.x
7+
CodeUri: ${codeuri}
8+
MemorySize: 128
9+
Architectures: ["arm64"]
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Resources:
2+
MyLambdaFunction:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
Handler: index.handler
6+
Runtime: nodejs12.x
7+
CodeUri: ${codeuri}
8+
MemorySize: 128
9+
Architectures:
10+
- x86_64
11+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Parameters:
2+
Runtimes:
3+
Type: CommaDelimitedList
4+
Default: nodejs12.x,nodejs10.x
5+
LayerName:
6+
Type: String
7+
Default: MyNamedLayerVersion
8+
9+
10+
Resources:
11+
MyLayerVersion:
12+
Type: AWS::Serverless::LayerVersion
13+
Properties:
14+
ContentUri: ${contenturi}
15+
LayerName:
16+
Ref: LayerName
17+
CompatibleRuntimes:
18+
Ref: Runtimes
19+
CompatibleArchitectures: [x86_64, arm64]
20+
21+
Outputs:
22+
MyLayerArn:
23+
Value:
24+
Ref: MyLayerVersion
25+
LayerName:
26+
Value:
27+
Ref: LayerName
28+

integration/single/test_basic_function.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ def test_function_with_http_api_events(self, file_name):
4444

4545
self.assertEqual(requests.get(endpoint).text, self.FUNCTION_OUTPUT)
4646

47+
@parameterized.expand(
48+
[
49+
("single/basic_function", ["x86_64"]),
50+
("single/basic_function_no_envvar", ["x86_64"]),
51+
("single/basic_function_openapi", ["x86_64"]),
52+
("single/basic_function_with_arm_architecture", ["arm64"]),
53+
("single/basic_function_with_x86_architecture", ["x86_64"]),
54+
]
55+
)
56+
@skipIf(current_region_does_not_support(["ARM"]), "ARM is not supported in this testing region")
57+
def test_basic_function_with_architecture(self, file_name, architecture):
58+
"""
59+
Creates a basic lambda function
60+
"""
61+
self.create_and_verify_stack(file_name)
62+
63+
lambda_client = self.client_provider.lambda_client
64+
function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
65+
function_architecture = lambda_client.get_function_configuration(FunctionName=function_name)["Architectures"]
66+
67+
self.assertEqual(function_architecture, architecture)
68+
4769
def test_function_with_deployment_preference_alarms_intrinsic_if(self):
4870
self.create_and_verify_stack("single/function_with_deployment_preference_alarms_intrinsic_if")
4971

integration/single/test_basic_layer_version.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestBasicLayerVersion(BaseTest):
1010
"""
1111

1212
@skipIf(current_region_does_not_support(["Layers"]), "Layers is not supported in this testing region")
13-
def test_basic_layer_version(self):
13+
def test_basic_layer_version(self, filename):
1414
"""
1515
Creates a basic lambda layer version
1616
"""
@@ -46,3 +46,21 @@ def test_basic_layer_with_parameters(self):
4646

4747
self.assertEqual(layer_version_result["LicenseInfo"], license)
4848
self.assertEqual(layer_version_result["Description"], description)
49+
50+
@skipIf(current_region_does_not_support(["Layers"]), "Layers is not supported in this testing region")
51+
@skipIf(current_region_does_not_support(["ARM"]), "ARM is not supported in this testing region")
52+
def test_basic_layer_with_architecture(self):
53+
"""
54+
Creates a basic lambda layer version specifying compatible architecture
55+
"""
56+
self.create_and_verify_stack("single/basic_layer_with_compatible_architecture")
57+
58+
outputs = self.get_stack_outputs()
59+
layer_arn = outputs["MyLayerArn"]
60+
layer_name = outputs["LayerName"]
61+
62+
layer_version_result = self.client_provider.lambda_client.get_layer_version_by_arn(Arn=layer_arn)
63+
self.client_provider.lambda_client.delete_layer_version(
64+
LayerName=layer_name, VersionNumber=layer_version_result["Version"]
65+
)
66+
self.assertEqual(layer_version_result["CompatibleArchitectures"], ["x86_64", "arm64"])

0 commit comments

Comments
 (0)