https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/storageaccount/
Python: 3.9.13
-- 1. macにPulumiインストール
brew install pulumi/tap/pulumi
-- 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. Create new project
mkdir test
cd test
pulumi new azure-python
Japan East
japaneast
↑locationはどちらの表記でもOK
az account list-locations --output table
pulumi config get azure-native:location
pulumi config set azure-native:location japaneast
pulumi config get azure-native:location
vim __main__.py
import pulumi
import pulumi_azure_native as azure_native
rg9999999 = azure_native.resources.ResourceGroup("rg9999999",
resource_group_name="rg9999999")
st123 = azure_native.storage.StorageAccount("st123",
account_name="st123",
kind="StorageV2",
resource_group_name=rg9999999.name,
access_tier="Hot",
sku=azure_native.storage.SkuArgs(
name="Standard_LRS",
),
)
container01 = azure_native.storage.BlobContainer("container01",
account_name="st123",
container_name="container01",
resource_group_name="rg9999999")
primary_key = (
pulumi.Output.all(rg9999999.name, st123.name)
.apply(
lambda args: azure_native.storage.list_storage_account_keys(
resource_group_name=args[0], account_name=args[1]
)
)
.apply(lambda accountKeys: accountKeys.keys[0].value)
)
pulumi.export("primary_storage_key", primary_key)
-- 4. pulumi 実行
pulumi up
※依存性を考慮してデプロイされない
export key="XXXX"
echo test > test.txt
az storage blob upload \
--account-name st123 \
--container-name container01 \
--name test.txt \
--file test.txt \
--account-key $key
az storage blob list \
--account-name st123 \
--container-name container01 \
--output table \
--account-key $key
-- 5. Azureクリーンアップ
pulumi destroy
pulumi stack rm dev --force