https://pulumi.com logo
#getting-started
Title
# getting-started
m

modern-journalist-43763

08/04/2023, 8:51 AM
Hey.. new here. Thanks for any support. Is there a way to get a resource based on the logical name in Pulumi? I see there is a get function which needs the physical id, but looking for something to fetch a resource base don logical name given in Pulumi. I've a Pulumi typescript dyantrace config organized in following structure: • managementZone.ts • autoTag.ts • alertingProfile.ts and all exported via index.ts. I would like to have the id of managementZone available in
autoTag.ts
&
alertingProfile.ts
. What would be the best way to achieve that? Thanks.
f

full-eve-52536

08/04/2023, 1:58 PM
I would like to have the id of managementZone available in
autoTag.ts
&
alertingProfile.ts
. What would be the best way to achieve that? Thanks.
I image you have something like this in managementZone.ts:
Copy code
export const myManagementZone = dynatrace.getManagementZone({
    name: "Example",
});
In
autoTag.ts
and
alertingProfile.ts
you can import
myMangementZone
and reference it's ID:
Copy code
import { myManagementZone } from './mangementZone.ts'; 

console.log(myManagementZone.id);
As for referencing a resource solely using the logical name, I'm not sure if that's possible.
s

salmon-account-74572

08/04/2023, 3:30 PM
+1 to what @full-eve-52536 said---if I’m reading your post correctly, then you should be able to reference the management zone directly in the other portions of your code (because they are all part of the same stack, tied together via
index.ts
).
m

modern-journalist-43763

08/06/2023, 8:29 PM
Cool.. thanks for your response.. 👍