<p>I'm trying to run a curl command in my helm chart that triggers a lambda. If I run my lambda on localhost and hit it with a curl from command line then it works perfectly. However, if I deploy the lambda and try to hit it the way it would work on production, by running through my helm chart, it breaks with the following error :</p>
<p>bash: {&quot;message&quot;:: command not found</p>
<p>Here is the helm chart I created:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: clean-receiver-list
spec:
  template:
    spec:
      initContainers:
      - name: check-author
        image: &quot;{{ .Values.global.utils.repository }}:{{ .Values.global.utils.imageTag }}&quot;
        imagePullPolicy: {{ .Values.global.utils.pullPolicy }}
        command: ['bash', '-c', 'while [ $(curl -sw &quot;%{http_code}&quot; &quot;http://{{ .Release.Name }}-stuff/healthcheck&quot; -o /dev/null) -ne 200 ]; do sleep 15; done' ]
      containers:
        - name: clean-receiver-list
          image: &quot;{{ .Values.global.utils.repository }}:{{ .Values.global.utils.imageTag }}&quot;
          command: ['bash',  '-c', '$(curl -d {&quot;podNamespace&quot;: &quot;{{ .Release.Name }}&quot;} &quot;https://mylambda/runTask&quot;)']
      restartPolicy: Never
  backoffLimit: 4
</code></pre>
<p>So it is the second curl command with my deployed lambda that is breaking.</p>

IceMan
<p>You're invoking the command as</p>
<pre class="lang-sh prettyprint-override"><code>bash -c $(curl ...)
</code></pre>
<p>which runs the <code>curl</code> command; but since it's wrapped inside <code>$(...)</code>, it takes the response from that and tries to run it as a shell command.  If the URL you're posting to returns a JSON body, this will produce an error very much like what you're seeing.</p>
<p>The easiest answer is to remove the <code>$(...)</code> around the command:</p>
<pre class="lang-yaml prettyprint-override"><code>command: ['bash',  '-c', 'curl -d {&quot;podNamespace&quot;: &quot;{{ .Release.Name }}&quot;} &quot;https://mylambda/runTask&quot;']
</code></pre>
<p>However, you're not doing anything in this command that actually requires a shell (environment variable expansion, command substitution, running multiple commands, ...) and skipping the shell-wrapper layer might be an improvement.  In particular there are quoting problems that this avoids (is your current form getting an HTTP error because the shell is swallowing the double quotes, so the POST body isn't valid JSON?).  I might write instead:</p>
<pre class="lang-yaml prettyprint-override"><code>command:
  - curl
  - -d
  # Using YAML &quot;block scalar&quot; syntax to avoid quoting problems
  - &gt;-
      {&quot;podNamespace&quot;: &quot;{{ .Release.Name }}&quot;}
  - https://mylambda/runTask
</code></pre>
