Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "architecture",
"description": "Add support for Arm64 processor ([1808](https://github.com/aws/chalice/issues/1808)]"
}
21 changes: 18 additions & 3 deletions chalice/awsclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def create_function(
security_group_ids: OptStrList = None,
subnet_ids: OptStrList = None,
layers: OptStrList = None,
architecture: OptStr = None,
) -> str:
# pylint: disable=too-many-locals
kwargs: Dict[str, Any] = {
Expand All @@ -426,6 +427,8 @@ def create_function(
)
if layers is not None:
kwargs['Layers'] = layers
if architecture is not None:
kwargs['Architectures'] = [architecture]
arn, state = self._create_lambda_function(kwargs)
# Avoid the GetFunctionConfiguration call unless
# we're not immediately active.
Expand Down Expand Up @@ -906,6 +909,7 @@ def update_function(
subnet_ids: OptStrList = None,
security_group_ids: OptStrList = None,
layers: OptStrList = None,
architecture: OptStr = None,
) -> Dict[str, Any]:
"""Update a Lambda function's code and configuration.

Expand All @@ -914,7 +918,9 @@ def update_function(
the targeted lambda function.
"""
return_value = self._update_function_code(
function_name=function_name, zip_contents=zip_contents
function_name=function_name,
zip_contents=zip_contents,
architecture=architecture,
)
self._update_function_config(
environment_variables=environment_variables,
Expand All @@ -933,12 +939,21 @@ def update_function(
return return_value

def _update_function_code(
self, function_name: str, zip_contents: str
self,
function_name: str,
zip_contents: str,
architecture: OptStr = None,
) -> Dict[str, Any]:
lambda_client = self._client('lambda')
kwargs: Dict[str, Any] = {
'FunctionName': function_name,
'ZipFile': zip_contents
}
if architecture is not None:
kwargs['Architectures'] = [architecture]
try:
result = lambda_client.update_function_code(
FunctionName=function_name, ZipFile=zip_contents
**kwargs
)
except _REMOTE_CALL_ERRORS as e:
context = LambdaErrorContext(
Expand Down
10 changes: 10 additions & 0 deletions chalice/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ def lambda_timeout(self) -> int:
varies_per_chalice_stage=True,
varies_per_function=True)

@property
def lambda_architecture(self) -> str:
value = self._chain_lookup(
'lambda_architecture',
varies_per_chalice_stage=True,
varies_per_function=True)
if value is None:
return 'x86_64'
return value

@property
def automatic_layer(self) -> bool:
v = self._chain_lookup('automatic_layer',
Expand Down
1 change: 1 addition & 0 deletions chalice/deploy/appgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ def _build_lambda_function(
subnet_ids=subnet_ids,
reserved_concurrency=config.reserved_concurrency,
layers=lambda_layers,
architecture=config.lambda_architecture,
managed_layer=self._get_managed_lambda_layer(config),
xray=config.xray_enabled,
)
Expand Down
12 changes: 9 additions & 3 deletions chalice/deploy/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ def handle_deploymentpackage(self, config, resource):
# type: (Config, models.DeploymentPackage) -> None
if isinstance(resource.filename, models.Placeholder):
zip_filename = self._packager.create_deployment_package(
config.project_dir, config.lambda_python_version)
config.project_dir,
config.lambda_python_version,
architecture=config.lambda_architecture)
resource.filename = zip_filename


Expand All @@ -472,7 +474,9 @@ def handle_lambdafunction(self, config, resource):
if isinstance(resource.deployment_package.filename,
models.Placeholder):
zip_filename = self._lambda_packager.create_deployment_package(
config.project_dir, config.lambda_python_version
config.project_dir,
config.lambda_python_version,
architecture=config.lambda_architecture
)
resource.deployment_package.filename = zip_filename
if resource.managed_layer is not None and \
Expand All @@ -489,7 +493,9 @@ def handle_lambdalayer(self, config, resource):
models.Placeholder):
try:
zip_filename = self._layer_packager.create_deployment_package(
config.project_dir, config.lambda_python_version
config.project_dir,
config.lambda_python_version,
architecture=config.lambda_architecture,
)
resource.deployment_package.filename = zip_filename
except EmptyPackageError:
Expand Down
1 change: 1 addition & 0 deletions chalice/deploy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class LambdaFunction(ManagedModel):
reserved_concurrency: int
# These are customer created layers.
layers: List[str]
architecture: str
managed_layer: Opt[LambdaLayer] = None
log_group: Opt[LogGroup] = None

Expand Down
Loading
Loading