Hey.. new here. Thanks for any support. Is there ...
# getting-started
m
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
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
+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
Cool.. thanks for your response.. 👍