I have a requirement to create airflow variables and connections on Amazon MWAA using a lambda function. Here is my python code to create variables:
r = requests.post(
mwaa_webserver_hostname,
headers={
'Authorization': mwaa_auth_token,
'Content-Type': 'text/plain'
},
data="variables set KEY VALUE"
)
it is working fine for variables. But when I try to get or add a connection in the same way, I'm getting 500 error:
r = requests.post(
mwaa_webserver_hostname,
headers={
'Authorization': mwaa_auth_token,
'Content-Type': 'text/plain'
},
data="connections get <CONN_ID>"
)
500 Server Error: INTERNAL SERVER ERROR for url: https://sjkdhfuweyr.<region>.airflow.amazonaws.com/aws_mwaa/cli
What is missing here? Anything specific about the connection to be created in this approach?