Skip to content

Commit

Permalink
Merge branch 'feature/328' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
takekazuomi committed Mar 3, 2021
2 parents 9e5ca1e + 38d65aa commit 8718d04
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
IMAGE_NAME ?= takekazuomi/devcontainers-bicep
TAG ?= 0.0.9
BICEP_RELEASE = v0.2.212
TAG ?= 0.3.1
BICEP_RELEASE = v0.3.1

help: ## Show this help.
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
Expand Down
9 changes: 4 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
}
},
"runArgs": [],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
Expand All @@ -22,10 +21,10 @@
"dandric.vscode-jq",
"redhat.vscode-yaml",
"dotjoshjohnson.xml",
"timonwong.shellcheck",
"editorconfig.editorconfig",
"/tmp/vscode-bicep.vsix"
// "ms-azuretools.vscode-bicep"
"timonwong.shellcheck",
"editorconfig.editorconfig",
//"/tmp/vscode-bicep.vsix"
"ms-azuretools.vscode-bicep"
],
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ This definition requires an Azure subscription to use. You can create a [free ac

## ChangeLog

- v0.3.1 bicep v0.3.1 loop support
- v0.0.9 bicep v0.2.212 conditional resources support
- v0.0.7 install GNU make
- v0.0.6 bicep v0.2.14 module support
Expand Down
28 changes: 28 additions & 0 deletions src/array-loop.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var subnets = [
{
name: 'api'
subnetPrefix: '10.144.0.0/24'
}
{
name: 'worker'
subnetPrefix: '10.144.1.0/24'
}
]

resource vnet 'Microsoft.Network/virtualNetworks@2018-11-01' = {
name: 'vnet'
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
'10.144.0.0/20'
]
}
subnets: [for subnet in subnets: {
name: subnet.name
properties: {
addressPrefix: subnet.subnetPrefix
}
}]
}
}
51 changes: 51 additions & 0 deletions src/array-loop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"functions": [],
"variables": {
"subnets": [
{
"name": "api",
"subnetPrefix": "10.144.0.0/24"
},
{
"name": "worker",
"subnetPrefix": "10.144.1.0/24"
}
]
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "vnet",
"location": "[resourceGroup().location]",
"properties": {
"copy": [
{
"name": "subnets",
"count": "[length(variables('subnets'))]",
"input": {
"name": "[variables('subnets')[copyIndex('subnets')].name]",
"properties": {
"addressPrefix": "[variables('subnets')[copyIndex('subnets')].subnetPrefix]"
}
}
}
],
"addressSpace": {
"addressPrefixes": [
"10.144.0.0/20"
]
}
}
}
],
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.2.480.26409",
"templateHash": "7567681426364362554"
}
}
}
37 changes: 37 additions & 0 deletions src/loop-index.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
param storageAccountNamePrefix string

var storageConfigurations = [
{
suffix: 'local'
sku: 'Standard_LRS'
}
{
suffix: 'geo'
sku: 'Standard_GRS'
}
]

resource storageAccountResources 'Microsoft.Storage/storageAccounts@2019-06-01' = [for (config, i) in storageConfigurations: {
name: storageAccountNamePrefix + config.suffix + i
location: resourceGroup().location
properties: {
supportsHttpsTrafficOnly: true
accessTier: 'Hot'
encryption: {
keySource: 'Microsoft.Storage'
services: {
blob: {
enabled: true
}
file: {
enabled: true
}
}
}
}
kind: 'StorageV2'
sku: {
name: config.sku
}
}]

9 changes: 9 additions & 0 deletions src/nested-loops.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource parentResources 'Microsoft.Example/examples@2020-06-06' = [for parent in parents where parent.enabled: {
name: parent.name
properties: {
children: [for child in parent.children where parent.includeChildren && child.enabled: {
name: child.name
setting: child.settingValue
}]
}
}]
26 changes: 26 additions & 0 deletions src/simple-storage-loop.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// array of storage account names
param storageAccounts array

resource storageAccountResources 'Microsoft.Storage/storageAccounts@2019-06-01' = [for storageName in storageAccounts: {
name: storageName
location: resourceGroup().location
properties: {
supportsHttpsTrafficOnly: true
accessTier: 'Hot'
encryption: {
keySource: 'Microsoft.Storage'
services: {
blob: {
enabled: true
}
file: {
enabled: true
}
}
}
}
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}]
48 changes: 48 additions & 0 deletions src/simple-storage-loop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccounts": {
"type": "array"
}
},
"functions": [],
"resources": [
{
"copy": {
"name": "storageAccountResources",
"count": "[length(parameters('storageAccounts'))]"
},
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccounts')[copyIndex()]]",
"location": "[resourceGroup().location]",
"properties": {
"supportsHttpsTrafficOnly": true,
"accessTier": "Hot",
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
},
"file": {
"enabled": true
}
}
}
},
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
}
}
],
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.2.480.26409",
"templateHash": "4721744551949130037"
}
}
}

0 comments on commit 8718d04

Please sign in to comment.