feat: use AWS Lambda entry point if ImageConfig.EntryPoint is set (#7326)
This commit is contained in:
parent
8576195462
commit
a9cec5e780
@ -1001,6 +1001,10 @@ class LambdaFunction(CloudFormationModel, DockerModel):
|
||||
"host.docker.internal": "host-gateway"
|
||||
}
|
||||
|
||||
# Change entry point if requested
|
||||
if self.image_config.entry_point:
|
||||
run_kwargs["entrypoint"] = self.image_config.entry_point
|
||||
|
||||
# The requested image can be found in one of a few repos:
|
||||
# - User-provided repo
|
||||
# - mlupin/docker-lambda (the repo with up-to-date AWSLambda images
|
||||
|
@ -377,3 +377,39 @@ def test_invoke_lambda_with_proxy():
|
||||
|
||||
expected_payload = {"id": vol.id, "state": vol.state, "size": vol.size}
|
||||
assert json.loads(payload) == expected_payload
|
||||
|
||||
|
||||
@mock_aws
|
||||
def test_invoke_lambda_with_entrypoint():
|
||||
conn = boto3.client("lambda", _lambda_region)
|
||||
function_name = str(uuid4())[0:6]
|
||||
conn.create_function(
|
||||
FunctionName=function_name,
|
||||
Runtime=PYTHON_VERSION,
|
||||
Role=get_role_name(),
|
||||
Handler="lambda_function.lambda_handler",
|
||||
Code={"ZipFile": get_test_zip_file1()},
|
||||
ImageConfig={
|
||||
"EntryPoint": [
|
||||
"/var/rapid/init",
|
||||
"--bootstrap",
|
||||
"/var/runtime/bootstrap",
|
||||
"--enable-msg-logs",
|
||||
],
|
||||
},
|
||||
Description="test lambda function",
|
||||
Timeout=3,
|
||||
MemorySize=128,
|
||||
Publish=True,
|
||||
)
|
||||
|
||||
in_data = {"hello": "world"}
|
||||
result = conn.invoke(
|
||||
FunctionName=function_name,
|
||||
InvocationType="RequestResponse",
|
||||
Payload=json.dumps(in_data),
|
||||
)
|
||||
assert result["StatusCode"] == 200
|
||||
payload = result["Payload"].read().decode("utf-8")
|
||||
|
||||
assert json.loads(payload) == in_data
|
||||
|
Loading…
Reference in New Issue
Block a user