Skip to content

Commit 242cccd

Browse files
committed
add cc methods for lambda function resource provider
1 parent 4832016 commit 242cccd

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

localstack-core/localstack/services/lambda_/resource_providers/aws_lambda_function.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,30 @@ def _get_lambda_code_param(
272272
return code
273273

274274

275+
def _transform_function_to_model(function):
276+
model_properties = [
277+
"MemorySize",
278+
"Description",
279+
"TracingConfig",
280+
"Timeout",
281+
"Handler",
282+
"SnapStartResponse",
283+
"Role",
284+
"FileSystemConfigs",
285+
"FunctionName",
286+
"Runtime",
287+
"PackageType",
288+
"LoggingConfig",
289+
"Environment",
290+
"Arn",
291+
"EphemeralStorage",
292+
"Architectures",
293+
]
294+
response_model = util.select_attributes(function, model_properties)
295+
response_model["Arn"] = function["FunctionArn"]
296+
return response_model
297+
298+
275299
class LambdaFunctionProvider(ResourceProvider[LambdaFunctionProperties]):
276300
TYPE = "AWS::Lambda::Function" # Autogenerated. Don't change
277301
SCHEMA = util.get_schema_path(Path(__file__)) # Autogenerated. Don't change
@@ -407,7 +431,14 @@ def read(
407431
- lambda:GetFunction
408432
- lambda:GetFunctionCodeSigningConfig
409433
"""
410-
raise NotImplementedError
434+
function_name = request.desired_state["FunctionName"]
435+
lambda_client = request.aws_client_factory.lambda_
436+
get_fn_response = lambda_client.get_function(FunctionName=function_name)
437+
438+
return ProgressEvent(
439+
status=OperationStatus.SUCCESS,
440+
resource_model=_transform_function_to_model(get_fn_response["Configuration"]),
441+
)
411442

412443
def delete(
413444
self,
@@ -521,5 +552,5 @@ def list(
521552
functions = request.aws_client_factory.lambda_.list_functions()
522553
return ProgressEvent(
523554
status=OperationStatus.SUCCESS,
524-
resource_models=[LambdaFunctionProperties(**fn) for fn in functions["Functions"]],
555+
resource_models=[_transform_function_to_model(fn) for fn in functions["Functions"]],
525556
)

0 commit comments

Comments
 (0)