From 9cc3033482082f9b1873e995df48521d64c51b3b Mon Sep 17 00:00:00 2001 From: Henrik Simonsen Knutsen <46495473+hknutsen@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:18:53 +0100 Subject: [PATCH 1/2] feat: add parameter `containerName` Create blob container with the specified name. Set previously hard coded value as default to ensure backwards compatability. --- README.md | 5 +++-- main.bicep | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c6f0d3e..20fc8ce 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Azure Resource Manager (ARM) template that creates an Azure Storage account to s - Creates a storage account with the specified name. - Configures the storage account according to [security recommendations](https://learn.microsoft.com/en-us/azure/storage/blobs/security-recommendations). -- Creates a storage container `tfstate`. +- Creates a blob container with the specified name. - Grants access to the storage account for specified user, group and service principals. - Creates a read-only lock to prevent changes to the storage account. @@ -83,6 +83,7 @@ Azure Resource Manager (ARM) template that creates an Azure Storage account to s | Name | Description | Type | Default | | - | - | - | - | | `storageAccountName` | The name of the storage account to create. | `string` | | +| `containerName` | The name of the blob container to create. | `string` | `tfstate` | | `ipRules` | An array of IP addresses or ranges that should be granted access to the storage account. If empty, all IP addresses and ranges will be granted access to the storage account. | `array` | `[]` | | `principalIds` | An array of object IDs for user, group or service principals that should be granted access to the storage account. | `array` | `[]` | @@ -91,7 +92,7 @@ Azure Resource Manager (ARM) template that creates an Azure Storage account to s | Name | Description | Type | | - | - | - | | `storageAccountName` | The name of the storage account that was created. | `string` | -| `containerName` | The name of the storage container that was created. | `string` | +| `containerName` | The name of the blob container that was created. | `string` | ## References diff --git a/main.bicep b/main.bicep index 092937c..47725bc 100644 --- a/main.bicep +++ b/main.bicep @@ -1,6 +1,9 @@ @description('The name of the Storage account to create.') param storageAccountName string +@description('The name of the blob container to create.') +param containerName string + @description('An array of IP addresses or IP ranges that should be allowed to bypass the firewall of the Terraform backend. If empty, the firewall will be disabled.') param ipRules array = [] @@ -52,7 +55,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = { } resource container 'containers' = { - name: 'tfstate' + name: containerName } } @@ -115,5 +118,5 @@ resource lock 'Microsoft.Authorization/locks@2020-05-01' = { @description('The name of the Storage account that was created.') output storageAccountName string = storageAccount.name -@description('The name of the Storage container that was created.') +@description('The name of the blob container that was created.') output containerName string = storageAccount::blobService::container.name From 38db24cb8526d40acce02c8484e55e627296dd61 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:28:26 +0000 Subject: [PATCH 2/2] Build Bicep file --- azuredeploy.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/azuredeploy.json b/azuredeploy.json index 80b2734..0053bfe 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "0.32.4.45862", - "templateHash": "6435624962667709005" + "templateHash": "8688306575345230913" } }, "parameters": { @@ -15,6 +15,12 @@ "description": "The name of the Storage account to create." } }, + "containerName": { + "type": "string", + "metadata": { + "description": "The name of the blob container to create." + } + }, "ipRules": { "type": "array", "defaultValue": [], @@ -34,7 +40,7 @@ { "type": "Microsoft.Storage/storageAccounts/blobServices/containers", "apiVersion": "2023-05-01", - "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), 'default', 'tfstate')]", + "name": "[format('{0}/{1}/{2}', parameters('storageAccountName'), 'default', parameters('containerName'))]", "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccountName'), 'default')]" ] @@ -172,9 +178,9 @@ "containerName": { "type": "string", "metadata": { - "description": "The name of the Storage container that was created." + "description": "The name of the blob container that was created." }, - "value": "tfstate" + "value": "[parameters('containerName')]" } } } \ No newline at end of file