-
Notifications
You must be signed in to change notification settings - Fork 763
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
Add securestring support for template output type #2163
Comments
I think the easiest and most consistent option here would be to add support for the |
It's not just adding decorator, but enabling this in RM itself. Currently it seems it's not supported: https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax#outputs:
Although this leads to another problem - secret must exist before entire template deployment, as it's being checked for existence during validation phase. Referencing KeyVault secrets in module params is tracked in #1028 |
Yup, fair enough. The above is the exact reason why we never implemented the secure support for outputs. However, if there's enough interest (aka upvotes 😊), it's definitely something we can revisit in the runtime as well. |
upvote 👍🏻 |
The peer that implemented the securestring-output in the original template just confirmed that it was implemented as an non-supported 'option' to be switched to a plain string in case the output would be absolutely needed for some reason. Seems like I had to much confidence into the given ARM template. Anyways, though I still believe it is a valid use case, I guess this makes it a RM feature-request rather than a bicep request and this issue should be closed. |
I'm fine leaving it open and collecting more feedback. I will mark it as an "Intermediate Language" fix accordingly |
@alexjneves raised a good example of why this is an important item to get done.
To summarize, the refactoring you need to do to workaround the lack of secure outputs results in very un-modular code, with many potential footguns around dependency ordering. |
Will this not be resolved once we can output a resource (reference) directly? var primaryKey = myStorageMod.outputs.sa. listKeys().keys[0].value Since we can call listKeys directly on the output? |
+1 to being able to set secure outputs. You have to write a whole bunch of code to use a keyvault as an intermediary otherwise and it gets really ugly (e.g. how do you know what the secret name is? ... I've been passing the secret name out as an output of the module that set it). |
#2716 (comment) just prompted me to realize - this is actually something that I think the deployment engine would block - as |
Since this is a resource reference, will it not likely to work on object property values or module property values? However not on variables. |
+1 for secure outputs. I wanted to have secure string/object between modules and couldn't do it properly without KV as a middle man. |
If someone stumbles upon this issue until there is a good way to either handle secure output or to hand over the whole resource reference, here is how I resolved the storage account issue: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value You can just not refer to the outputs of the storageAccount resource itself, but as you should already hand over everything that is needed to the resource, you can just reuse these parameters. |
@itpropro thanks for the workaround. |
Would be awesome to see this feature - just did the workaround described by @anthony-c-martin and thought "there must be a better way!" - and it turns out, no! Not yet! |
+1 for secure outputs For anyone wanting to get the connection strings from an EventHub Namespace, below worked for me based on what @itpropro mentioned but for an EventHub namespace
|
Even using the dependsOn, I am not able to sort out this race condition... main.bicep param location string
var name = uniqueString(resourceGroup().id, location)
module myStorageMod 'storage.bicep' = {
name: 'myStorageMod-${uniqueString(name)}'
params: {
location: location
name: name
}
}
resource storage 'Microsoft.Storage/storageAccounts@2021-04-01' existing = {
name: name
}
var primaryKey = storage.listKeys().keys[0].value
module sample 'sample.bicep' = {
name: 'sample-${uniqueString(name)}'
dependsOn: [
myStorageMod
storage
]
params: {
key: primaryKey
}
}
sample.bicep @secure()
param key string {
"status": "Failed",
"error": {
"code": "DeploymentFailed",
"target": "/subscriptions/edf507a2-6235-46c5-b560-fd463ba2e771/resourceGroups/dcibtestDeploy/providers/Microsoft.Resources/deployments/meta-230406-2104",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "ResourceNotFound",
"message": "The Resource 'Microsoft.Storage/storageAccounts/foosomenamingconvention' under resource group 'dcibtestDeploy' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
}
]
}
} |
Okay, I think this fixes it. Have to use an extra nesting of modules to stop the race condition. param location string
var name = uniqueString(resourceGroup().id, location)
module myStorageMod 'storage.bicep' = {
name: 'myStorageMod-${uniqueString(name)}'
params: {
location: location
name: name
}
}
module nested 'nested.bicep' = {
name: 'nested-${uniqueString(name)}'
dependsOn: [
myStorageMod
]
params: {
name: name
}
}
nested.bicep param name string
resource storage 'Microsoft.Storage/storageAccounts@2021-04-01' existing = {
name: name
}
var primaryKey = storage.listKeys().keys[0].value
module sample 'sample.bicep' = {
name: 'sample-${uniqueString(name)}'
dependsOn: [
storage
]
params: {
key: primaryKey
}
} sample.bicep @secure()
param key string |
FWIW @dciborow, this is a known issue where |
@alex-frankel Do you mean that you are planning to add dependsOn on existing resources? If so, what's the progress on that? |
We need more upvotes! |
@alex-frankel is there any progress on this? |
Unfortunately, not the case it seems. If you enable this experimental bicep feature, and try referencing outputs as you describe, this is what you'd get:
|
Updated the milestone on this one as the work is in progress. @fvilches17 FWIW, I would expect this to work once resource outputs are out of experimental. |
Hi @alex-frankel happy 2025. Is there an ETA on when this feature is expected to be out of experimental? Edit: disregard question. I see it's on the Selenium milestone, aimed for March 31, 2025 🤞 |
What
In contrast to the parameter section there seems to be no support for a
securestring
output type.For example:
output storageAccountSasToken securestring = listAccountSas(storageAccountName, '2019-04-01', accountSasProperties).accountSasToken
Error
If you want to use it regardless, VSCode shows the error:
The output type is not valid. Please specify one of the following types: "array", "bool", "int", "object", "string".bicep(BCP030)
and you are unable to compile thebicep
template.Why
This feature is especially useful if one deploys a storage account and wants to directly leverage it in subsequent deployments. E.g. if using a linked template orchestration (aka master template) where the storage account hosts CSE scripts for a later VM deployment.
The text was updated successfully, but these errors were encountered: