-
Notifications
You must be signed in to change notification settings - Fork 757
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
Conditional resources and modules decompilation #1150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment.
Codecov Report
@@ Coverage Diff @@
## main #1150 +/- ##
==========================================
+ Coverage 94.24% 94.38% +0.14%
==========================================
Files 330 331 +1
Lines 16067 16355 +288
Branches 14 14
==========================================
+ Hits 15142 15437 +295
+ Misses 925 918 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
} | ||
} | ||
var publicIpAddressId = { | ||
id: resourceId(publicIpResourceGroupName, 'Microsoft.Network/publicIPAddresses', publicIpName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to tie this contractually to the value of publicIpNewOrExisting
as this template is going to be in a broken state if someone tries to deploy it with new
and have specified a different resource group for publicIpResourceGroupName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I refactored the template so that all resourceId
s are tied to createNew...
.
@@ -0,0 +1,263 @@ | |||
param location string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alex-frankel mind taking a look at this example file?
default: resourceGroup().name | ||
} | ||
|
||
var storageAccountId = createNewStorageAccount ? storageAccount.id : resourceId(storageAccountResourceGroupName, 'Microsoft.Storage/storageAccounts/', storageAccountName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this pattern is the weird part right? because in the template today you would use the resourceId()
function for both new and existing and because the storageAccountName is the same in both cases it happens to work. With bicep we have arguably made it more complex (though I'd argue more obvious).
Going forward this will be something like:
external resource existingStorage ...
var storageAccountId = createNewStorageAccount ? storageAccount.id : existingStorageAccount.id
Which seems good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wait nevermind, I got that wrong. It will be:
resource storageAccount 'Microsoft.Storage/storageAccounts@2017-06-01' = if (createNewStorageAccount) {
name: storageAccountName
location: location
kind: 'Storage'
sku: {
name: storageAccountType
}
} else existing ...
Then you use the same symbolic name regardless if the storage account is being created or not. So I think we are good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Closes #1151.