Exemplo n.º 1
0
"""An Azure RM Python Pulumi program"""

import pulumi
from pulumi_azure_native import storage
from pulumi_azure_native import resources

# Create an Azure Resource Group
resource_group = resources.ResourceGroup('cloudskills-rg')

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

# 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)
Exemplo n.º 2
0
                               family="Y",
                               capacity=0))

# Export the Azure Resource Group
pulumi.export('resourcegroup', resource_group.name)

# Export the Storage Account
pulumi.export('storageaccount', account.name)

# Export the Consumption Plan
pulumi.export('consumptionplan', plan.name)

# List of storage account keys
storageAccountKeys = 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]))
# Primary storage account key
primaryStorageKey = storageAccountKeys.apply(
    lambda accountKeys: accountKeys.keys[0].value)
# Build a storage connection string out of it:
storageConnectionString = Output.concat(
    "DefaultEndpointsProtocol=https;AccountName=", account.name,
    ";AccountKey=", primaryStorageKey)

# Export the storageacountkey as a secret
pulumi.export("storageaccountkeys", pulumi.Output.secret(storageAccountKeys))
# Export the primarystoragekey as a secret
pulumi.export('primarystoragekey', pulumi.Output.secret(primaryStorageKey))
# Export the storageconnectionstring  as a secret
pulumi.export('storageconnectionstring',
              pulumi.Output.secret(storageConnectionString))