https://pulumi.com logo
Title
h

handsome-state-59775

03/30/2021, 1:55 AM
with
pulumi_azure_native.storage
, i'm unable to extract
account_name
from an
StorageAccount
for use in supplying the same field name for
FileShare
1
currently working around this like so:
STORAGE_ACCOUNT_NAME = f'{PREFIX_CLEAN}storage'[:24]

storage_account = az.storage.StorageAccount(
        resource_name='storageAccount',
        resource_group_name=rg.name,
        account_name=STORAGE_ACCOUNT_NAME,  # HACK 1
        kind=az.storage.Kind.STORAGE_V2,
        sku=az.storage.SkuArgs(
                name=az.storage.SkuName.STANDARD_LRS,
        ),
)

file_share = az.storage.FileShare(
        resource_name='fileShare',
        resource_group_name=rg.name,
        # Unable to extract storage_account.account_name:
        account_name=STORAGE_ACCOUNT_NAME,  # HACK 2
        share_name=f'{PREFIX_CLEAN}-share'[:63],
        access_tier=az.storage.ShareAccessTier.TRANSACTION_OPTIMIZED,
        share_quota=5120,
        opts=p.ResourceOptions(
                # Workaround for missing storage_account.account_name:
                depends_on=[
                    storage_account,  # HACK 3
                ],
                parent=storage_account,
        ),
)
is this a bug or am i missing something?
g

gentle-diamond-70147

03/30/2021, 3:21 AM
you should be able to do
account_name=storage_account.name
in your
FileShare
🙌 1
h

handsome-state-59775

03/30/2021, 4:14 AM
thanks! while that worked for me (it didn't before for some reason), isn't it a bit counter-intuitive?
.name
usually maps to the referred resource's
resource_name
, right? and every other property has a getter by the same name except this. just trying to understand if there's a pattern that i'm missing here
t

tall-librarian-49374

03/30/2021, 6:27 AM
FWIW, that’s how Azure API is modelled. They always have an output property called
name
. We build that
name
from
resource_name
if the specific input property like
account_name
is not specified, or from
account_name
if it is.
👍 1