Extract to module
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
Make it easy to select a section of code in a bicep file and move that code into a module and replace the selected code with the instantiation of that now module.
For example, if I have a bicep file like the below:
```bicep
param namePrefix string
resource stg 'Microsoft.Storage/storageAccounts@2023-04-01' = {
name: '${namePrefix}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
sku: {
name: 'Premium_LRS'
}
kind: 'StorageV2'
}
```
If I highlight the storage account resource and execute an "extract to module" command, I should get something like the following:
main.bicep
```bicep
param namePrefix string
module storageDeploy 'storage.bicep' = {
params: {
namePrefix: namePrefix
}
}
```
storage.bicep (the command should ask me for this filename)
```storage.bicep
param namePrefix string
resource stg 'Microsoft.Storage/storageAccounts@2023-04-01' = {
name: '${namePrefix}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
sku: {
name: 'Premium_LRS'
}
kind: 'StorageV2'
}
```
Note the command would have needed to notice that the `namePrefix` param was used in the resource declaration, and replicate that over to the module accordingly.
Contributor guide
Assessment
This issue has not been assessed yet.