Complete the code to set the default retry delay to 5 minutes in an Airflow DAG.
default_args = {
'retry_delay': timedelta(minutes=[1])
}The retry delay is set to 5 minutes using timedelta(minutes=5) to optimize task retries and avoid unnecessary costs.
Complete the code to schedule the DAG to run once every day at midnight.
dag = DAG(
'cost_optimization',
schedule_interval='[1]',
default_args=default_args
)The cron expression '0 0 * * *' schedules the DAG to run daily at midnight, which helps in regular cost monitoring.
Fix the error in the task definition by completing the operator name correctly.
task1 = [1]( task_id='check_unused_resources', bash_command='echo Checking unused cloud resources', dag=dag )
The BashOperator runs bash commands, which fits the task of echoing a message for checking resources.
Fill both blanks to create a dictionary comprehension that maps resource names to their cost if the cost is greater than 0.
costs = {resource: [1] for resource, cost in resource_costs.items() if cost [2] 0}The comprehension maps each resource to its cost only if the cost is greater than zero, helping to focus on resources that incur costs.
Fill all three blanks to create a filtered dictionary of resources with cost above 100, using uppercase resource names as keys.
filtered_costs = { [1]: [2] for [3], cost in resource_costs.items() if cost > 100}This comprehension creates a dictionary with uppercase resource names as keys and their costs as values, filtering only those with costs above 100 to optimize expenses.