Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case change for variable names #20

Open
rafaelmagu opened this issue Oct 28, 2020 · 5 comments
Open

Case change for variable names #20

rafaelmagu opened this issue Oct 28, 2020 · 5 comments

Comments

@rafaelmagu
Copy link

Problem

While implementing this plugin to work with a Terraform pipeline, we found that the key names used in the pipeline YAML do not have their case respected when the variables are exported.

For example:

steps:
  - label: ":building_construction: build"
    command: 'echo \$MY_env_var'
    plugins:
      - seek-oss/aws-sm#v2.2.0:
          env:
            MY_env_var: "my/secret/value"

Yields:

🔑 Reading secrets from AWS SM
Reading <long_arn> from AWS SM into environment variable MY_ENV_VAR

This problem does not occur for the json-to-env method, presumably because the keys are not being passed through Buildkite's plugin framework (which I believe is the real culprit).

Resources

Terraform respects the case sensitivity of variables when the OS allows: https://www.terraform.io/docs/configuration/variables.html#environment-variables

@rafaelmagu
Copy link
Author

rafaelmagu commented Oct 29, 2020

I have confirmed with Buildkite support that the key names passed down to plugins are kept in their correct case, so the problem lies with how this plugin interprets them.

You can see the correct values from Buildkite on a test pipeline by going to the step where the plugin is used and clicking on the Environment tab, then scrolling to the BUILDKITE_PLUGINS value.

@72636c
Copy link
Member

72636c commented Nov 2, 2020

Heya @rafaelmagu, is Buildkite now recommending to parse BUILDKITE_PLUGINS? We currently pull values out of BUILDKITE_PLUGIN_<PLUGIN_NAME>_<CONFIGURATION_PROPERTY> as documented in their tutorial, which does not preserve property case sensitivity: https://buildkite.com/docs/plugins/writing#plugin-tutorial-add-a-plugin-dot-yml

@rafaelmagu
Copy link
Author

@72636c I've asked Buildkite to pitch in on that answer.

@dominics
Copy link

Taking the view that we probably can't rely on property case sensitivity when using BUILDKITE_PLUGIN_* (and we don't really want to rebuild or overcomplicate the whole parsing business) I have suggested a feature that would allow a workaround in #23

It still wouldn't allow the simple case to work:

plugins:
  - vital-software/aws-sm#v2.4.0:
      env:
        MY_env_var: my/secret/value # <- produces MY_ENV_VAR
        MY_FOO: other/secret/value

But it does build upon the existing secret-id support to move the specification of the environment variable name to a value instead of a property name, which is case-preserving:

plugins:
  - vital-software/aws-sm#v2.4.0:
      env:
        my_env_var: # <- not used
          export-name: MY_env_var # <- produces MY_env_var
          secret-id: my/secret/value
        MY_FOO: other/secret/value

@tarciosaraiva
Copy link

Any plans to retackle this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants