gentle-zoo-32137
09/04/2022, 6:44 AMvictorious-church-57397
09/04/2022, 12:34 PMgentle-zoo-32137
09/04/2022, 12:59 PMvictorious-church-57397
09/04/2022, 1:33 PMgentle-zoo-32137
09/04/2022, 1:36 PMvictorious-church-57397
09/04/2022, 1:37 PMlittle-cartoon-10569
09/04/2022, 9:27 PMgetProject()
and getStack()
functions, but they return the current project and stack names. StackReference has a name
property.
There is no way to get the org, project or stack name from another stack.
@gentle-zoo-32137 Why do you need to get the organization name? Since you know what project you're in, you can safely hard code the organization and project values. I think you shouldn't extract this logic into re-usable functions that might be called from different organizations or projects. There is too great a risk of getting the wrong stack reference when moving code around. A value like organization name can be made a const string in your index.ts and passed around: it doesn't make coupling worse, and there is no loss of re-usability.gentle-zoo-32137
09/05/2022, 8:02 AMlittle-cartoon-10569
09/05/2022, 9:37 PMimport * as pulumiConstants from "@mycompany/PulumiConstants";
// Get a stack reference to the same stack in the _Base_ project.
const baseStackRef = new pulumi.StackReference(`${pulumiConstants.ORG_NAME}/Base/${pulumi.getStack()}`);
gentle-zoo-32137
09/06/2022, 6:25 AMlimited-rainbow-51650
09/06/2022, 6:53 AMgetOrganization()
method available:
https://github.com/pulumi/pulumi/releases/tag/v3.39.0gentle-zoo-32137
09/06/2022, 6:54 AM