``` if args.token == "azure:core/getSubscri...
# python
v
Copy code
if args.token == "azure:core/getSubscription:getSubscription":
            return {
                "id": "00000000-0000-0000-0000-000000000000",
                "display_name": "subscription",
                "tenant_id": "11111111-1111-1111-1111-111111111111"
            }
f
The keys here are expected to be property keys and not the language SDK-specific keys. Property keys in Pulumi are always camelCased. If you try using
displayName
and
tenantId
does that work?
v
Thank you so much! That totally works!
So I have one more issue with azureadindex/getGroupgetGroup
Copy code
root: DEBUG: Invoking function prepared: tok=azuread:index/getGroup:getGroup
root: DEBUG: resource registration prepared: ty=azure:authorization/userAssignedIdentity:UserAssignedIdentity, name=dev-servicefabric-identity
root: DEBUG: RPC failed with exception:
root: DEBUG: Traceback (most recent call last):
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/rpc_manager.py", line 65, in rpc_wrapper
so I have this but it still fails:
Copy code
ty=azure:authorization/userAssignedIdentity:UserAssignedIdentity, name=dev-servicefabric-identity
Copy code
elif args.token == "azuread:index/getGroup:getGroup":
            return {
                'displayName': "Developers",
                'mailEnabled': True,
                'name': "Developers",
                'objectId': "11111111-1111-1111-1111-111111111111",
                'securityEnabled': True
            },
Does this resource have to be mocked so that getGroup can run?
Thanks again for your input on this.
f
Yes, you need to mock invokes as well: https://www.pulumi.com/docs/guides/testing/unit/#add-mocks — you can see there’s a method called
call
which is used for mocking out the invokes (vs.
new_resource
for mocking out resource creation)
v
Thanks. So this is what I am running
Copy code
def call(self, args):
        # <https://github.com/pulumi/pulumi/issues/5671>
        if args.token == "azure:core/getSubscription:getSubscription":
            return {
                "id": "00000000-0000-0000-0000-000000000000",
                "displayName": "subscriptionname",
                "subscriptionId": "00000000-0000-0000-0000-000000000000",
                "tenantId": "11111111-1111-1111-1111-111111111111"
            }
        elif args.token == "azuread:index/getGroup:getGroup":
            return {
                'displayName': "Developers",
                'mailEnabled': True,
                'name': "Developers",
                'objectId': "11111111-1111-1111-1111-111111111111",
                'securityEnabled': True,
                'owners': ["engineering"],
                'id': "groupid",
                'description': "this is a group",
                'behaviors': ['WelcomeEmailDisabled']
            },
This is the error now:
Copy code
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/julianalcala/git/sourcescrub/sourcescrub.azureinfrastructure/infra/projects/bare/__main__.py", line 147, in <module>
    dev_group = azuread.get_group(
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi_azuread/get_group.py", line 177, in get_group
    __ret__ = pulumi.runtime.invoke('azuread:index/getGroup:getGroup', __args__, opts=opts, typ=GetGroupResult).value
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/invoke.py", line 144, in invoke
    invoke_result, invoke_error = _sync_await(asyncio.ensure_future(do_rpc()))
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/sync_await.py", line 54, in _sync_await
    return loop.run_until_complete(fut)
  File "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/invoke.py", line 139, in do_rpc
    raise exn
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/rpc_manager.py", line 65, in rpc_wrapper
    result = await rpc
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/invoke.py", line 116, in do_invoke
    resp, error = await asyncio.get_event_loop().run_in_executor(None, do_invoke)
  File "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/invoke.py", line 112, in do_invoke
    return monitor.Invoke(req), None
  File "/Users/julianalcala/virtuals/infra/lib/python3.9/site-packages/pulumi/runtime/mocks.py", line 171, in Invoke
    (ret, failures) = tup[0], [provider_pb2.CheckFailure(property=failure[0], reason=failure[1]) for failure in tup[1]]
IndexError: tuple index out of range
f
Did you try to debug the index out of range access? It looks like it’s trying to access the 1-index — do you have code that does that?
and i”m guessing that stray comma at the end of the code block you pasted might be affecting you
since by default, it’s a tuple of
[value, None]
and maybe now it’s not
None
and so it’s checking the error condition
v
You were right. Ugh trailing comma lol. Thank you so much.