aio-cli-plugin-runtime icon indicating copy to clipboard operation
aio-cli-plugin-runtime copied to clipboard

ACNA-335 - Env variables in manifest yaml with ${*} syntax break deploy

Open moritzraho opened this issue 5 years ago • 5 comments

Describe the bug Relates to #21 Accessing an environment variable in the manifest yaml with ${*} syntax breaks the runtime deploy cmd.

As a comparison, this syntax works with wskdeploy

Environment variable accessed with $* work fine

moritzraho avatar Jun 13 '19 12:06 moritzraho

JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-335

adobe-bot avatar Jul 01 '19 03:07 adobe-bot

Also, the format $* is supported only for "inputs". It should be supported for all attribute values. Further, this means we cannot dynamically change the names of packages/actions. wskdeploy doesnt seem to support this but serverless does this using a "name" attribute under package/action. We can consider that.

Himavanth avatar Jul 05 '19 06:07 Himavanth

@moritzraho Can you elaborate more on this? I am unclear on what you are trying to accomplish. A failing test would be awesome!!!

purplecabbage avatar Jul 10 '19 20:07 purplecabbage

@purplecabbage sorry for the confusing bug description and thanks for looking into this 😄

This is about accessing environment variables in the manifest file. When there are accessed using the ${MY_ENV} syntax, the deployment breaks, while the $MY_ENV syntax works fine. But both work in wskdeploy so I would except the ${MY_ENV} syntax to work here as well or some documentation somewhere on how to access env vars.

I think @Himavanth point is about accessing variables declared in the manifest file. We should probably file this in a separate issue.

Btw I couldn't see any test for deploy with env vars in manifest (not even for the working $ENV syntax). I have smthg like this in mind:

Fixture /deploy/manifest_withEnvVars.yaml

packages:
  testEnv:
    version: 1.0
    license: Apache-2.0
    actions:
      actionWithEnvInput:
        function: /deploy/hello.js
        inputs:
          fakeTestEnv: $FAKE_TEST_ENV
          fakeTestEnvCurly: ${FAKE_TEST_ENV_CURLY}

Test in deploy/index.test.js:

test('deploys actions with env vars as inputs in manifest', () => {
      let cmd = ow.mockResolved(owAction, '')
      command.argv = ['-m', '/deploy/manifest_withEnvVars.yaml']
      process.env['FAKE_TEST_ENV'] = 'fake-test-env'
      process.env['FAKE_TEST_ENV_CURLY'] = 'fake-test-env-curly'
      return command.run()
        .then(() => {
          expect(cmd).toHaveBeenCalledWith({
            name: 'testEnv/actionWithEnvInput',
            action: hello,
            params: { fakeTestEnv: 'fake-test-env', fakeTestEnvCurly: 'fake-test-env-curly' },
          })
          expect(stdout.output).toMatch('')
        })
    })

moritzraho avatar Jul 11 '19 07:07 moritzraho

The syntax doesn't break the runtime deploy anymore, but the variable doesn't get parsed. We should handle the parsing for both $ENV and ${ENV} to stay aligned with wskdeploy.

meryllblanchet avatar Apr 08 '20 09:04 meryllblanchet