I have a question regarding AWS lambda(seoul region) invokation from Airflow(Amazon Managed Workflows for Apache Airflow in tokyo region).
The problem is when I invoke a Lambda function from Airflow, the Airflow UI says the function failed.
The weird thing is when I checked if that is true from AWS log, the Lambda function at issue worked fine; the status code 200.
I heard that there is a timeout threshold for Lambda from Airflow is 5 minutes.
In fact, other Lambda functions less than 5 minutes are successful in airflow.
My question is:
- Is the 5 minute limit is true?
- If so, can I configure the limitation somewhere?
Your help would be appreciated
Below is a part of my code.
config = Config(
read_timeout=900,
connect_timeout=900,
retries={"max_attempts": 1}
)
# invoke lambda func
def _invoke_lambda_func(lambda_name,payload):
lambda_hook = AwsLambdaHook(function_name=lambda_name,config=config)
response = lambda_hook.invoke_lambda(payload=payload)
if response['StatusCode'] == 200:
return True
with DAG(
dag_id='lambda_test',
default_args = args,
dagrun_timeout = timedelta(hours=1),
start_date = days_ago(2),
#schedule_interval='0 3 * * *',
schedule_interval=None,
tags=['lambda_test'],
) as dag:
# Start task
for lambda_name in lambda_func_list:
lambda_task = PythonOperator(
task_id=f'{lambda_name}_lambda_func',
python_callable=_invoke_lambda_func,
op_kwargs={
'lambda_name':lambda_name,
'payload':'null'
}
)
lambda_func[lambda_name] = lambda_task
test = PythonOperator(
task_id='final_func',
python_callable=_op_complete
)
lambda_func['extract_message_target_users'] >> test