Hi there! I am using Pulumi to create some custom ...
# python
c
Hi there! I am using Pulumi to create some custom infrastructure and am having trouble accessing the outputs of my resources. On the docs (https://www.pulumi.com/docs/intro/concepts/resources/#dynamic-resource-outputs) it says that what I am doing should be correct, but there is also little mention of how to actually access the outputs, so I could be wrong. This is what my resource and provider look like; am I doing anything wrong?
Copy code
class 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))
g
Given your code you should be able to access the outputs like so:
Copy code
new_account = Account("new_account1", props=AccountCredentials(sid=account_sid, auth_token=auth_token))

new_account_sid = new_account.sid
Does that not work? Are you getting an error?
c
I don't get an error doing that, but when the value is consumed I get the error
TypeError: 'Output' object is not iterable, consider iterating the underlying value inside an 'apply'
. When I use the apply stuff from https://www.pulumi.com/docs/intro/concepts/inputs-outputs/ I also get the same error
g
Can you share your full code?