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

aws+sm datasource only supports path-like secret names #868

Closed
RecuencoJones opened this issue Jun 11, 2020 · 5 comments · Fixed by #874
Closed

aws+sm datasource only supports path-like secret names #868

RecuencoJones opened this issue Jun 11, 2020 · 5 comments · Fixed by #874
Assignees
Labels

Comments

@RecuencoJones
Copy link

RecuencoJones commented Jun 11, 2020

As per #867, looks like aws+sm schema only works with Unix path secret names (/like/this) but would fail otherwise,

Test with a secret named some-secrets:

gomplate \
  -c 'secrets=aws+sm://some-secrets?type=application/json' \
  --in {{ .secrets.test }}

Failing with:

Couldn't read datasource 'secrets': Error reading aws+sm from AWS using GetSecretValue with input {
  SecretId: ""
}

However, when just using aws+sm: as a datasource then it can be used like this:

gomplate \
  -d 'secrets=aws+sm:?type=application/json' \
  --in '{{ (ds "secrets" "some-secrets").test }}'
@hairyhenderson hairyhenderson changed the title aws+sm schema only supports path-like secret names aws+sm datasource only supports path-like secret names Jun 12, 2020
@hairyhenderson
Copy link
Owner

Hmm... There's some ambiguity here. Given aws+sm:///foo, should the name be /foo or foo? absolute URL paths always start with /, which is why the behaviour is as-is right now. But that's clearly not OK in this particular case.

An option is to support an opaque URI, like aws+sm:foo, and then use foo as the name.

What would be especially awkward is to use the authority part and have aws+sm://foo, but I don't like that at all, since it closes the door on being able to override the aws+sm endpoint. Plus it's not a hostname 😉

How does the opaque option sound @RecuencoJones? In your example you'd use this command:

gomplate \
  -c 'secrets=aws+sm:some-secrets?type=application/json' \
  --in {{ .secrets.test }}

If this works, it probably should be applied to the aws+smp datasource as well.

@RecuencoJones
Copy link
Author

I think the opaque URI fits really well, I actually tested the following and worked with a secret named /some-secrets btw:

gomplate \
  -c 'secrets=aws+sm:/some-secrets?type=application/json' \
  --in {{ .secrets.test }}

So definitely, having just aws+sm:<secret-name>[?query][#fragment] would be perfect and much more intuitive for this datasource 😄

@hairyhenderson hairyhenderson self-assigned this Jun 13, 2020
@hairyhenderson
Copy link
Owner

I think aws+sm:/some-secrets would be normalized to aws+sm:///some-secrets internally, which is why it works.

Glad to hear the opaque one works - I'll use that for the bugfix 🙂

@shashank201192
Copy link

shashank201192 commented Nov 5, 2024

@hairyhenderson, I am currently trying to use aws+sm datasource but it seems to be broken with 4.x gomplate while same is working with gomplate 3.x. After checking related cloudtrail event, I see that gomplate is adding "/" as prefix for Opaque URLs to secret manager ID.

For example, with gomplate 4.x, when I try running gomplate -c 'secrets=aws+sm:foo' --in {{.secrets}} then it's trying to get secret value for ID "/foo".

Is it related to breaking changes in 4.x gomplate?

@hairyhenderson
Copy link
Owner

@shashank201192 please file an issue or start a discussion - this issue has been closed for over 4 years

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