Last active
May 4, 2023 02:15
-
-
Save igoravl/0921e9be7e1b85e46e3be192768fbcc5 to your computer and use it in GitHub Desktop.
Create a storage account for subsequent Terraform usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@description('Specifies the name of the Azure Storage account.') | |
param storageAccountName string | |
@description('Specifies the name of the blob container.') | |
param containerName string = 'tfstate' | |
@description('Specifies the location in which the Azure Storage resources should be deployed.') | |
param location string = resourceGroup().location | |
@description('Specifies the SKU for the Storage Account.') | |
param sku string = 'Standard_LRS' | |
resource sa 'Microsoft.Storage/storageAccounts@2021-06-01' = { | |
name: storageAccountName | |
location: location | |
sku: { | |
name: sku | |
} | |
kind: 'StorageV2' | |
properties: { | |
accessTier: 'Hot' | |
} | |
} | |
resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2021-06-01' = { | |
parent: sa | |
name: 'default' | |
} | |
resource container 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-06-01' = { | |
parent: blobService | |
name: containerName | |
} | |
// Output connection string | |
var blobStorageConnectionString = 'DefaultEndpointsProtocol=https;AccountName=${sa.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${sa.listKeys().keys[0].value}' | |
output connectionString string = blobStorageConnectionString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment