Search code examples
airflowboto3amazon-ecsaws-fargate

Airflow ECS Register Task Operator, error when passing env. variables


when I am trying to pass env. variables to my ECSRegisterTaskOperator, I get the following error:

Unknown parameter in input: "environment", must be one of: family, taskRoleArn, executionRoleArn, networkMode, containerDefinitions, volumes, placementConstraints, requiresCompatibilities, cpu, memory, tags, pidMode, ipcMode

However according to the documentation for boto3 with Ecs, one has to pass env variables via the environment dictionary. [reference: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ecs.html#ECS.Client.register_task_definition ]

The part of my task looks like this:

register_task_kwargs={
"cpu": "256",
"memory": "512",
"networkMode": "awsvpc",
"environment": [
{
"name": "REDSHIFT_HOST",
"value": redshift_cluster_test_connection.host
},
{
"name": "REDSHIFT_USER",
"value": "redshift_cluster_test_connection.user"
},
{ "name": "REDSHIFT_PW",
"value": redshift_cluster_test_connection.password}
]

Solution

  • The environment settings go inside the containerDefinitions. You have them at the top level, instead of inside the containerDefinitions.