https://pulumi.com logo
#general
Title
# general
c

creamy-monkey-35142

04/02/2024, 2:14 PM
@echoing-dinner-19531 and guys, could you help me share example of get id of an existing Dynamic Resource Provider? currently I’m trying
WorkspaceMember.get()
but it return error
Copy code
Cannot access member "get" for type "type[WorkspaceMember]" Member "get" is unknownPylancereportAttributeAccessIssue (function) get: Unknown
e

echoing-dinner-19531

04/02/2024, 2:19 PM
I don't think get works for dynamic resources
c

creamy-monkey-35142

04/02/2024, 2:19 PM
;(
e

echoing-dinner-19531

04/02/2024, 2:20 PM
There's no
read
method on dynamic providers for the engine to lookup a resource with
c

creamy-monkey-35142

04/02/2024, 2:20 PM
let me explain my context: currently we want assign
member
into a
Project
, we want Project depend on member to make sure member is created before Project create
e

echoing-dinner-19531

04/02/2024, 2:20 PM
Just use a depends_on property?
c

creamy-monkey-35142

04/02/2024, 2:21 PM
yes, but I don’t know how to pass depends_on property, that’s why I’m looking on
get
function
Copy code
pulumi:pulumi:Stack                   pulum-bytebase                   **failed**              1 error; 42 messages
     ├─ pulumi-python:dynamic:Resource     Project_A                                                      
 +   │  └─ pulumi-python:dynamic:Resource  ProjectMember_A                        **creating failed**     1 error
 +   ├─ pulumi-python:dynamic:Resource     <mailto:WorkspaceMember_a@example.com|WorkspaceMember_a@example.com>  created (0.56s)         
 +   └─ pulumi-python:dynamic:Resource     <mailto:WorkspaceMember_b@example.com|WorkspaceMember_b@example.com>     created (1s)
as above, the WorkspaceMember_* is in a Dynamic Provider, and ProjectMember is another Provider
and Workspace member can be passed into multiple Project
e

echoing-dinner-19531

04/02/2024, 2:24 PM
So pass the member resources to the Project_A depends_on option
c

creamy-monkey-35142

04/02/2024, 2:26 PM
Copy code
if workspace_members:
                for member in set(workspace_members):
                    response = WorkspaceMember(f"{member}", {"users": member})
the currently Python code look like that, I think the
response
only available for
create
user as pulumi output above, only resource of a & b@example.com will be returned. Did I understand right?
in case I want to pass
<mailto:c@example.com|c@example.com>
which created before as depend_on for Porject A, what should I do?
e

echoing-dinner-19531

04/02/2024, 2:28 PM
ah... yeh that's not supported. Again there's no
read
for dynamic providers
c

creamy-monkey-35142

04/02/2024, 2:29 PM
, we want Project depend on member to make sure member is created before Project create
then do you have any suggestion or other approach for this case? 🥲
like control the order of resource creation to allow WorkspaceMember create before Project
e

echoing-dinner-19531

04/02/2024, 2:37 PM
well given c must be a resource that's being created elsewhere just write the code in your program to check if it exists and if it doesn't exit out?
c

creamy-monkey-35142

04/02/2024, 2:41 PM
I see 2 points: • the current approach is combine members from projects into one unique list to perform
WorkspaceMember
, because of an user can be member of multiple project. it’ll help save API call with unique list • your approach is check user exist on every project’s member section, it’ll have duplicated call as user belong to multiple project. it still work but it’s not a good approach. too waste api call and need more time to go through all members
e

echoing-dinner-19531

04/02/2024, 2:44 PM
yeh but I think given the limits of dynamic providers here its tricky to unify this in one way
c

creamy-monkey-35142

04/02/2024, 2:45 PM
;( do we have any plan to add
read
function for Dynamic Provider 😄
e

echoing-dinner-19531

04/02/2024, 3:04 PM
Nothing on the roadmap for it
Probably doable, but haven't heard any plans for it