https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
https://qiita.com/turupon/items/e5cf3699fffc40de3b3c
-- 1. macにTerraformインストール
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
brew update
brew upgrade hashicorp/tap/terraform
terraform -help
terraform -version
-- 2. Azureログイン
az login --use-device-code
az account show
az version
az configure --list-defaults
az configure --defaults location=japaneast
az configure --list-defaults
az group list
az upgrade
-- 3. tfファイル作成
vim main.tf
terraform{
required_providers{
azurerm={
source = "hashicorp/azurerm"
version = "=3.6.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "rg9999999" {
name = "rg9999999"
location = "Japan East"
}
resource "azurerm_storage_account" "st99999999" {
name = "st99999999"
resource_group_name = azurerm_resource_group.rg9999999.name
location = azurerm_resource_group.rg9999999.location
account_kind = "StorageV2"
account_tier = "Standard"
account_replication_type = "LRS"
access_tier = "Hot"
}
resource "azurerm_storage_container" "container01" {
name = "container01"
storage_account_name = azurerm_storage_account.st99999999.name
container_access_type = "private"
}
-- 4. terraform 実行
terraform init -upgrade
terraform plan
terraform apply
terraform output
terraform state list
connectionString=$(az storage account show-connection-string \
--resource-group rg9999999 \
--name st99999999 \
--query connectionString \
--output tsv )
echo $connectionString
echo test > test.txt
az storage blob upload \
--account-name st99999999 \
--container-name container01 \
--name test.txt \
--file test.txt \
--connection-string $connectionString
az storage blob list \
--account-name st99999999 \
--container-name container01 \
--output table \
--connection-string $connectionString
-- 5. Azureクリーンアップ
terraform destroy
az group list