Skip to content

Commit

Permalink
add storage account example for az native
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxxstorm committed Mar 3, 2023
1 parent 72b4255 commit 9c7b80c
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 41 deletions.
2 changes: 2 additions & 0 deletions python/azure/storage_account/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
venv/
6 changes: 6 additions & 0 deletions python/azure/storage_account/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: azure_storage_account
runtime:
name: python
options:
virtualenv: venv
description: A minimal Azure Native Python Pulumi program
52 changes: 52 additions & 0 deletions python/azure/storage_account/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""An Azure RM Python Pulumi program"""

import pulumi
import pulumi_azure as azure
from pulumi_azure_native import storage
from pulumi_azure_native import resources

# Create an Azure Resource Group
resource_group = resources.ResourceGroup("resource_group")

classic_account = azure.storage.Account(
"classic",
resource_group_name=resource_group.name,
account_tier="Standard",
account_kind="BlobStorage",
access_tier="Hot",
account_replication_type="RAGRS",
)

pulumi.export("classic_connection_string", classic_account.primary_connection_string)

# # Create an Azure resource (Storage Account)
account = storage.StorageAccount(
"account",
resource_group_name=resource_group.name,
sku=storage.SkuArgs(
name=storage.SkuName.STANDARD_LRS,
),
kind=storage.Kind.STORAGE_V2,
)

"""
The primary connection string is not an API response from the ARM API
We can use the actual API responses to form the connection string
"""
def get_connection_string(resource_group_name: pulumi.Output[str], account_name: pulumi.Output[str]) -> pulumi.Output[str]:
keys = storage.list_storage_account_keys_output(resource_group_name=resource_group_name, account_name=account_name)
"""
This is a secret because it contains the storage account key
"""
return pulumi.Output.secret(pulumi.Output.format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix=core.windows.net", account_name, keys.keys[0].value))

pulumi.export("native_connnection_string", get_connection_string(resource_group.name, account.name))

# # Export the primary key of the Storage Account
# primary_key = pulumi.Output.all(resource_group.name, account.name) \
# .apply(lambda args: 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)
2 changes: 2 additions & 0 deletions python/azure/storage_account/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi-azure-native>=1.0.0,<2.0.0
11 changes: 0 additions & 11 deletions terraform/eks/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions terraform/eks/main.tf

This file was deleted.

14 changes: 0 additions & 14 deletions terraform/eks/providers.tf

This file was deleted.

0 comments on commit 9c7b80c

Please sign in to comment.