'Pass value to stdin subprocess

I'm trying to replicate this command in the subprocess library.

kubectl patch secret foo --type=json --patch-file=/dev/stdin <<-EOF
  [
    {
      "op": "replace",
      "path": "/data/metadata/name",
      "value": "bar"
    }
  ]
EOF

How do I go about passing the below value via stdin?

<<-EOF
  [
    {
      "op": "replace",
      "path": "/data/metadata/name",
      "value": "bar"
    }
  ]
EOF


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source