Given an existing function ARN, update the configuration variables.
(
self,
lambda_arn,
function_name,
handler,
description="Zappa Deployment",
timeout=30,
memory_size=512,
ephemeral_storage={"Size": 512},
publish=True,
vpc_config=None,
efs_config=None,
runtime="python3.13",
aws_environment_variables=None,
aws_kms_key_arn=None,
layers=None,
snap_start=None,
wait=True,
)
| 1363 | return resource_arn |
| 1364 | |
| 1365 | def update_lambda_configuration( |
| 1366 | self, |
| 1367 | lambda_arn, |
| 1368 | function_name, |
| 1369 | handler, |
| 1370 | description="Zappa Deployment", |
| 1371 | timeout=30, |
| 1372 | memory_size=512, |
| 1373 | ephemeral_storage={"Size": 512}, |
| 1374 | publish=True, |
| 1375 | vpc_config=None, |
| 1376 | efs_config=None, |
| 1377 | runtime="python3.13", |
| 1378 | aws_environment_variables=None, |
| 1379 | aws_kms_key_arn=None, |
| 1380 | layers=None, |
| 1381 | snap_start=None, |
| 1382 | wait=True, |
| 1383 | ): |
| 1384 | """ |
| 1385 | Given an existing function ARN, update the configuration variables. |
| 1386 | """ |
| 1387 | logger.info("Updating Lambda function configuration..") |
| 1388 | |
| 1389 | if not vpc_config: |
| 1390 | vpc_config = {} |
| 1391 | if not efs_config: |
| 1392 | efs_config = [] |
| 1393 | if not self.credentials_arn: |
| 1394 | self.get_credentials_arn() |
| 1395 | if not aws_kms_key_arn: |
| 1396 | aws_kms_key_arn = "" |
| 1397 | if not aws_environment_variables: |
| 1398 | aws_environment_variables = {} |
| 1399 | if not layers: |
| 1400 | layers = [] |
| 1401 | |
| 1402 | if wait: |
| 1403 | # Wait until function is ready, otherwise expected keys will be missing from 'lambda_aws_config'. |
| 1404 | self.wait_until_lambda_function_is_updated(function_name) |
| 1405 | |
| 1406 | # Check if there are any remote aws lambda env vars so they don't get trashed. |
| 1407 | # https://github.com/Miserlou/Zappa/issues/987, Related: https://github.com/Miserlou/Zappa/issues/765 |
| 1408 | lambda_aws_config = self.lambda_client.get_function_configuration(FunctionName=function_name) |
| 1409 | if "Environment" in lambda_aws_config: |
| 1410 | lambda_aws_environment_variables = lambda_aws_config["Environment"].get("Variables", {}) |
| 1411 | # Append keys that are remote but not in settings file |
| 1412 | for key, value in lambda_aws_environment_variables.items(): |
| 1413 | if key not in aws_environment_variables: |
| 1414 | aws_environment_variables[key] = value |
| 1415 | |
| 1416 | kwargs = { |
| 1417 | "FunctionName": function_name, |
| 1418 | "Role": self.credentials_arn, |
| 1419 | "Description": description, |
| 1420 | "Timeout": timeout, |
| 1421 | "MemorySize": memory_size, |
| 1422 | "EphemeralStorage": ephemeral_storage, |