[BUG] MWAA CLI endpoint runs any Airflow subcommand, not only the MWAA-supported ones
Service
MWAA (Amazon Managed Workflows for Apache Airflow)
AWS API Action
The Airflow CLI endpoint: CreateCliToken, then POST https://<WebServerHostname>/aws_mwaa/cli
Expected behavior
Amazon MWAA runs only the Airflow CLI commands it lists as supported for the environment's Airflow version: Apache Airflow CLI command reference, Supported commands. For Airflow v2, which covers every version Floci offers (2.8.4, 2.9.3, 2.10.5), that list is:
cheat-sheet,versionconnections add,connections deletedags backfill,delete,list,list-import-errors,list-jobs,list-runs,next-execution,pause,report,reserialize,show,state,test,trigger,unpausedb cleanproviders behaviours,get,hooks,links,list,notifications,secrets,triggerer,widgetsroles add-perms,create,del-perms,listtasks clear,failed-deps,list,render,run,state,states-for-dag-run,testvariables delete,get,list,set
Some rows carry a minimum minor version (between 2.0 and 2.8); every version Floci supports meets them. Any other command isn't available through the CLI endpoint.
Actual behavior
Floci passes any airflow subcommand through to the Airflow container, for example users list, users create, db shell, config get-value, webserver, scheduler or celery worker. Since #4750 no shell is involved and each exec is time-bounded, but the endpoint still exposes more of the Airflow CLI than MWAA does, so a script that works against Floci can fail on AWS.
Reproduction
aws --endpoint-url http://localhost:4566 mwaa create-cli-token --name my-env
# take CliToken and WebServerHostname from the output
curl -s --request POST "http://$WEB_SERVER_HOSTNAME/aws_mwaa/cli" \
--header "Authorization: Bearer $CLI_TOKEN" \
--header "Content-Type: text/plain" \
--data-raw "users list"
# runs and returns the user list; users list is not a supported MWAA CLI commandEnvironment
- Floci version / image tag: main at 49501ac
- Java SDK version (if applicable): n/a
- How you're running Floci: n/a, found while reviewing #4750
Follow-up from #4750. The check belongs before runAirflowCli builds the argv: compare the first one or two arguments against the list for the environment's Airflow version.
Source: floci-io/floci