I got it working after numerous trial and error:
aws apigateway update-stage --rest-api-id $api_id --stage-name
'test_stage' --patch-operations
op="replace",path=/variables/server,value="8.8.8.8"
op="replace" works instead of "add" (odd for me as i am trying to add a variable). The variable name is in the path and the value after that. AWS return me the following response after executing the command this way:
{
"stageName": "test_stage",
"variables": {
"server": "8.8.8.8"
},
"cacheClusterEnabled": false,
"cacheClusterStatus": "NOT_AVAILABLE",
"deploymentId": "kg39574",
"lastUpdatedDate": 1512838534,
"createdDate": 1512705498,
"methodSettings": {}
}