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 custom types on module outputs #9570

Closed
WhitWaldo opened this issue Jan 18, 2023 · 3 comments · Fixed by #10052
Closed

Allow custom types on module outputs #9570

WhitWaldo opened this issue Jan 18, 2023 · 3 comments · Fixed by #10052
Assignees
Labels
enhancement New feature or request intermediate language Related to the intermediate language type system
Milestone

Comments

@WhitWaldo
Copy link

WhitWaldo commented Jan 18, 2023

I have a lot of modules, that, because of scoping, looping and organizational complexity pass a bunch of variables from the outputs back to the caller. Especially once I'm able to define these custom types in one place and import them around the solution, I'd like to be able to apply the outputs of a module as a custom type so I might trivially pass the output from the module into a parameter of another module using the same type rather than having to manually map it regularly on either end.

Especially if I'm able to rely on explicit and implicit validation on the values passed into these custom types, this would go a long way towards eliminating development error and assumptions about the values being shuffled between modules that violate constraints on dependencies.

An example of what I'd like to see (mixing one of my linked asks to simplify the example):

//kv-module.bicep
type resourceIdentifier = {
  subscriptionId: string
  resourceGroupName: string
  resourceName: string
}

param KeyVaultName string

resource KV 'Microsoft.KeyVault/vaults@2022-07-01' = {
  name: KeyVault.resourceName
  properties: {
    //...
  }
}

output KeyVaultResource resourceIdentifier = {
  subscriptionId: subscription().subscriptionId //I don't know this syntax is right - just scribbling this example off the top of my head
  resourceGroupName: resourceGroup().name
  resourceName: KeyVaultName
}
//other-module.bicep
type resourceIdentifier = {
  subscriptionId: string
  resourceGroupName: string
  resourceName: string
}

param KeyVaultId resourceIdentifier

module Doodad './other-other-module.bicep' = {
  //...
}
//root.bicep
module KV './kv-module.bicep' = {
  name: 'dp-kv-a'
  params: {
    KeyVaultName: 'mykeyvault'
  }
}

module OtherThing './other-module.bicep' = {
  name: 'dp-other'
  params: {
    KeyVaultId: KV.outputs.KeyVaultResource
  }
}

This would go a long way to not only bundle like-values into a single discrete type for downstream use from the output, but would also work to eliminate development-time errors (especially invalid scope assignments) by ensuring that when the input parameters require the type derived from an output, I just return that value directly from said output and eliminate an opportunity to mis-map that in some manner.

@WhitWaldo WhitWaldo added the enhancement New feature or request label Jan 18, 2023
@ghost ghost added the Needs: Triage 🔍 label Jan 18, 2023
@stephaniezyen stephaniezyen added the intermediate language Related to the intermediate language label Feb 1, 2023
@stephaniezyen stephaniezyen added this to the Committed Backlog milestone Feb 1, 2023
@github-project-automation github-project-automation bot moved this to Todo in Bicep Feb 1, 2023
@jeskew jeskew modified the milestones: Committed Backlog, v0.16 Feb 6, 2023
@jeskew jeskew self-assigned this Mar 6, 2023
@jeskew jeskew moved this from Todo to In Progress in Bicep Mar 8, 2023
@jeskew jeskew moved this from In Progress to In Review in Bicep Mar 9, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Bicep Mar 13, 2023
@santo2
Copy link

santo2 commented Apr 17, 2023

hey guys, where can I find the information about this? the import as specified above gives me an error. Is this expected?

image

image

@jeskew
Copy link
Contributor

jeskew commented Apr 17, 2023

Hi @santo2, The import statement used in the issue description has not been implemented. This issue was just about using custom types on outputs; syntax for how to share types across templates is still being discussed in #10121.

I'll edit the imports out of the description to clarify what was implemented in #10052.

@santo2
Copy link

santo2 commented Apr 17, 2023

ok thanks for the feedback, guess I'll have to wait a bit longer :-)

@ghost ghost locked as resolved and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request intermediate language Related to the intermediate language type system
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants