Reputation: 51
I have installed Airflow 2.0.1 on EC2 with PostgreSQL RDS as metadata db. I want to trigger DAG from Lambda so tried to test the code with curl but am receiving Unauthorized as response. What if anything should I be doing differently?
Steps:
airflow users create -u lambda_user -p some_pwd -f Lambda -l User -r User -e [email protected]
curl -H "Authorization: Basic Base64(username:password)" -H "Content-type: application/json" -H "Accept: application/json" -X GET --user "${LAMBDA_USER}:${LAMBDA_PWD}" "${ENDPOINT_URL}/api/v1/dags/sns_test/dagRuns"
Response I receive is this:
{
"detail": null,
"status": 401,
"title": "Unauthorized",
"type": "https://airflow.apache.org/docs/2.0.1/stable-rest-api-ref.html#section/Errors/Unauthenticated"
}
Upvotes: 2
Views: 7487
Reputation: 51
After revising call to
curl -H "Content-type: application/json" -H "Accept: application/json"
-X POST --user "${LAMBDA_USER}:${LAMBDA_PWD}" "${ENDPOINT_URL}/api/v1/dags/sns_test/dagRuns" -d '{"conf": {}}'
dag was triggered!
Upvotes: 2
Reputation: 1156
You are creating a user with the role User
.
This is because you have -r User
in the command.
Now Airflow requires at least Viewer
permissions for the end point you are calling. You can find that information on the Apache Airflow website here.
If you change your command it will work. Change it from
airflow users create -u lambda_user -p some_pwd -f Lambda -l User -r User -e [email protected]
to
airflow users create -u lambda_user -p some_pwd -f Lambda -l User -r Viewer -e [email protected]
Upvotes: 0