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

implicitly discards parameters that have same base name but in other path hierarchy #50

Closed
aereal opened this issue Aug 16, 2021 · 1 comment · Fixed by #51
Closed

Comments

@aereal
Copy link
Contributor

aereal commented Aug 16, 2021

expected behavior

We have these parameters in SSM parameter store:

  • /my/external-service-1/sercret-key
  • /my/external-service-2/secret-key

and run ssmwrap -paths /my then get these environment variables:

  • MY_EXTERNAL_SERVICE_1_SECRET_KEY
  • MY_EXTERNAL_SERVCIE_2_SECRET_KEY

actual behavior

We only get SECRET_KEY that from /my/external-service-2/secret-key and have no way to get /my/external-service-1/secret-key.

This is caused by formatParametersAsEnvVars that uses only a last part of the path for environment variable name.

ssmwrap/dest_env.go

Lines 36 to 46 in 207423a

func (d DestinationEnv) formatParametersAsEnvVars(parameters map[string]string) []string {
envVars := []string{}
for name, value := range parameters {
parts := strings.Split(name, "/")
key := strings.ToUpper(d.Prefix + parts[len(parts)-1])
envVars = append(envVars, fmt.Sprintf("%s=%s", key, value))
}
return envVars
}

solution

We should use the entire path as environment variable name because parameter uniqueness is guaranteed by its entire path not only the last part of the path.

@aereal aereal changed the title implicitly discards parameters that have same base name in other path hierarchy implicitly discards parameters that have same base name but in other path hierarchy Aug 16, 2021
aereal added a commit to aereal/ssmwrap that referenced this issue Aug 17, 2021
refs. handlename#50
Parameters' uniqueness guaranteed by its entire path not only the last part of the path.
aereal added a commit to aereal/ssmwrap that referenced this issue Aug 17, 2021
BREAKING CHANGE: Parameters' uniqueness guaranteed by its entire path not only the last part of the path.
refs. handlename#50
@handlename
Copy link
Owner

@aereal released as v1.2.0
https://github.com/handlename/ssmwrap/releases/tag/v1.2.0

Please use -env-entire-path option to enable feature.
Thank you for your contributing again!

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.

2 participants