https://pulumi.com logo
Title
b

bumpy-byte-21437

10/16/2020, 1:28 PM
for x in conf.require('sa_name')
sa_account = azure.storage.Account(
  x,
  resource_group_name=resource_group.name,
  location=resource_group.location,
  allow_blob_public_access=False,
  is_hns_enabled=True,
  account_kind="StorageV2",
  account_tier="Standard",
  min_tls_version="TLS1_2",
  enable_https_traffic_only=True,
  account_replication_type="GRS",
  tags={
    "environment": "dev",
  }
)
t

tall-librarian-49374

10/16/2020, 1:38 PM
b

bumpy-byte-21437

10/16/2020, 3:09 PM
my question is rather how to loop through the resource_name
data *=* conf.require_object("data")
bla *=* data.get("nums")
*for* x *in* bla:
sa_account *=* azure.storage.Account(
resource_name*=*,
resource_group_name*=*resource_group.name,
location*=*resource_group.location,
allow_blob_public_access*=*False,
is_hns_enabled*=*True,
account_kind*=*"StorageV2",
account_tier*=*"Standard",
min_tls_version*=*"TLS1_2",
enable_https_traffic_only*=*True,
account_replication_type*=*"GRS",
tags*=*{
"environment": "dev",
}
)
i would expect simply x, but i get a
IndentationError: expected an indented block
on this
and bla is
['sanmlps', 'sanmsds', 'sansdsd']
s

sparse-park-68967

10/16/2020, 9:32 PM
At least indentation error sounds legit in python based on what you pasted? you need to indent
sa_account = ...
b

bumpy-byte-21437

10/17/2020, 9:21 AM
Ok, can you give a example based on my code?
What i want to know is how to properly iterate using python lang in combination with an pulumi resource
In terraform iteration is very easy through complex objects, but i dont know how pulumi resources deal with it
@sparse-park-68967, @tall-librarian-49374 thanks for your comment
*for* x *in* bla:
sa_account *=* azure.storage.Account(
resource_name*=*x,
resource_group_name*=*resource_group.name,
location*=*resource_group.location,
allow_blob_public_access*=*False,
is_hns_enabled*=*True,
account_kind*=*"StorageV2",
account_tier*=*"Standard",
min_tls_version*=*"TLS1_2",
enable_https_traffic_only*=*True,
account_replication_type*=*"GRS",
tags*=*{
"environment": "dev",
}
)
fixed the indent indeed.. this is my first encounter with pulumi and python as well
gotta get familiar with the rules 🙂
as i understand tab/spaces are actually part of the language itself right
s

sparse-park-68967

10/17/2020, 12:19 PM
Good to hear! Welcome to python…