This message was deleted.
# general
s
This message was deleted.
t
This is actually intentional. The best practice is not to give fixed names to resources unless required, so that’s Pulumi’s default. If you need to set a fixed name, you can always pass it as
name
property.
l
@quiet-painter-30539 in my TF days, I wrote quite some code where in general we always added a random part. This was to prevent running over each other’s toes when multiple deployments needed to be done with the same TF code. We consistently used DataSources to lookup the correct resource via tags. The reason to do it like that was that TF complained at the DataSource when it wasn’t found, rather than later where you fix the name and assume it is there.
I now get the randomization for free with Pulumi. 😉
q
Ok. Is there some documentation how to use DataSources to look for the actual resource name?
l
In Pulumi, it is not called DataSources (this is a TF concept), but in the libraries, you have several methods prefixed with
get
. This is the Pulumi equivalent.
q
Ok. Thanks!
l
Well, just checked some docs, and Pulumi also calls them Data Sources, e.g. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/gcp/projects/
getProject
&
getOrganizationPolicy
q
Just to make sure we are talking about the same thing. I was referring that I need to query the secret value in a Java application. But in Java I don't know the resource name Pulumi created. Is there some way to find this out in the Java application?
l
@quiet-painter-30539 is the Java application deployed via Pulumi? If so, you can pass the credential name as an env variable to the Java app during the deployment. From there, the Java app reads the env variable and queries the correct secret
q
In Terraform this never was a problem since we always append the environment prefix to all resources, e.g. "dev-rds-password", "qa-rds-password" etc. and there never was any name conflicts. And in Java application code we just took the prefix somewhere and added it to the resource name and this way we could query the resource in Java code. Now that there is this random postfix Pulumi creates we cannot access the resources in Java since we don't know the resource name. This might be a show-stopper for us. Nope. We don't deploy apps using Pulumi. We should be able to do deployments without Pulumi.
l
Then use the suggestion of Mikhail and set the
name
property of the secret in Pulumi to prevent the randomization to happen.
q
Yes. I guess we have to do that.
I turned off auto-naming for those resources that I need to access from the application code (e.g. Java application). Thanks for the help, this is not an issue anymore.