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

Allow string interpolation in property names #267

Closed
alex-frankel opened this issue Aug 19, 2020 · 4 comments · Fixed by #566
Closed

Allow string interpolation in property names #267

alex-frankel opened this issue Aug 19, 2020 · 4 comments · Fixed by #566
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@alex-frankel
Copy link
Collaborator

Those strings should support string interpolation so I can use expressions:

var uamiId = resourceId(subId, rgName, 'Microsoft.ManagedIdentity/userAssignedIdentities', uamiName)

resource dScript '...' = {
  ...
  properties: {
    managedIdentities: {
      '${uamiId}': {}
    }
  }
}
@majastrz
Copy link
Member

ship it!

@anthony-c-martin
Copy link
Member

A drawback of allowing unrestricted interpolation that we should probably discuss: all our type safety goes out of the window as soon as anyone uses it.

For example:

{
  '${myKey}': true // if myKey evaluates to 'abc' at runtime, we've got a duplicate key
  abc: false
}

Or:

...inside resource declaration...
properties: {
  '${myKey}': true // myKey evaluates to something that the resource schema doesn't allow
}

@majastrz
Copy link
Member

We could probably restrict it to places that are using additionalProperties in the swagger.

An even more restrictive option could be to only allow its use at identity.userAssignedIdentities.* property names and use feedback to discover other places where it's needed. (Or do we need to scan quickstart ourselves?)

@anthony-c-martin anthony-c-martin changed the title Allow strings in property names Allow string interpolation in property names Aug 20, 2020
@alex-frankel alex-frankel added the enhancement New feature or request label Aug 24, 2020
@majastrz
Copy link
Member

majastrz commented Sep 5, 2020

What if we required the property name (not property value) to be of type resourceId on properties inside identity.userAssignedIdentities? This would be the same type that we're planning to use for setting deployment scopes, which is a subtype of string.

I think this would give us decent type safety and would prevent arbitrary strings from being used that way. Since we're planning functions to construct resourceId values anyway, the users could construct them out of component parts pretty easily. Could also consider exposing resourceId as a parameter or output type, which would benefit module validation as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants