cool-belgium-78445
08/16/2021, 2:55 PMclass AccountProvider(ResourceProvider):
def __init__(self, props):
self.parent_client = Client(props["sid"], props["auth_token"])
def create(self, props):
subaccount = self.parent_client.api.accounts.create(friendly_name="{}-{}".format(props["name"], stack))
return CreateResult(id_=subaccount.sid, outs={'sid':subaccount.sid, 'auth_token':subaccount.auth_token})
def delete(self, id, props):
self.parent_client.api.accounts(id).update(status="closed")
class Account(Resource):
sid: Output[str]
auth_token: Output[str]
def __init__(self, name: str, props, opts: Optional[ResourceOptions] = None):
super().__init__(AccountProvider(props), name, {"name":name, 'sid':None, 'auth_token':None}, opts)
new_account = Account("new_account1", props=AccountCredentials(sid=account_sid, auth_token=auth_token))
witty-candle-66007
08/16/2021, 3:29 PMnew_account.sid
, it throws an error or something?cool-belgium-78445
08/16/2021, 3:31 PMwitty-candle-66007
08/16/2021, 3:31 PMcool-belgium-78445
08/16/2021, 3:34 PMnew_account.sid
everything works fine but when I pass that into another resource I get the following:
TypeError: 'Output' object is not callable
error: an unhandled error occurred: Program exited with non-zero exit code: 1
TypeError: 'Output' object is not iterable, consider iterating the underlying value inside an 'apply'
witty-candle-66007
08/16/2021, 4:08 PMapply
stuff in Pulumit:
https://www.pulumi.com/docs/intro/concepts/inputs-outputs/cool-belgium-78445
08/16/2021, 4:09 PM<http://requests.post|requests.post>("<http://localhost:5000>", {"f":new_account.sid.apply(lambda sid: f"{sid}")})
, and that did not workTypeError: 'Output' object is not iterable, consider iterating the underlying value inside an 'apply'
same errorwitty-candle-66007
08/16/2021, 5:09 PMcool-belgium-78445
08/16/2021, 5:15 PMwitty-candle-66007
08/16/2021, 5:27 PMdef create(self, props):
subaccount = self.parent_client.api.accounts.create(friendly_name="{}-{}".format(props["name"], stack))
Are you sure subaccount
and more importantly subaccount.sid
is defined? or that new_account.sid
is defined in the calling code?cool-belgium-78445
08/16/2021, 5:29 PMwitty-candle-66007
08/16/2021, 5:32 PMpulumi.export("new_account", new_account)
after the new_account
declaration, and see that new_account has the various properties?cool-belgium-78445
08/16/2021, 5:32 PMpulumi stack export
I everything outputs like it shouldwitty-candle-66007
08/16/2021, 5:35 PMpulumi.export
in your code and see what it shows - just to see what outputs the code sees.cool-belgium-78445
08/16/2021, 6:44 PMwitty-candle-66007
08/16/2021, 7:16 PM<http://requests.post|requests.post>("<http://localhost:5000>", {"f":new_account.sid.apply(lambda sid: f"{sid}")}),
new_account.sid.apply(lambda sid: <http://request.post|request.post>("<http://localhost:5000>", {"f":sid}))
cool-belgium-78445
08/16/2021, 7:37 PMwitty-candle-66007
08/16/2021, 7:43 PMcool-belgium-78445
08/16/2021, 7:49 PM