In the pulumi docs, I’ve seen “name”, “logical nam...
# general
c
In the pulumi docs, I’ve seen “name”, “logical name”, and “resource_name” all used apparently interchangeably (see https://www.pulumi.com/docs/intro/concepts/programming-model/#resources , https://www.pulumi.com/docs/intro/concepts/programming-model/#urns ) which is confusing me and my team when we’re talking about these entities. Is one of these monikers preferred over the others?
g
You may have already read through this (based on your first link), but https://www.pulumi.com/docs/intro/concepts/programming-model/#autonaming tries to explain this a bit more. In general, "name" and "logical name" refer to the name you've provided to the resource in your pulumi code based on
name
as in this bit of code:
Copy code
let res = new Resource(name, args, options);
When defined this way, Pulumi will auto-name the physical resource (e.g. the "resource name") appending a random suffix. This is generally helpful for resources that require unique names and is explain in more https://www.pulumi.com/docs/troubleshooting/faq/#why-do-resource-names-have-random-hex-character-suffixes.
So in the case of:
Copy code
let role = new aws.iam.Role("my-role");
The "name" and "logical name" of this resource is
my-role
. The "resource name" or "physical name" of this resource at AWS would end up being something like
my-role-d7c2fa0
.
You can turn off this auto-naming by explicitly providing a
name
property as in:
Copy code
let role = new aws.iam.Role("my-role", {
    name: "my-role",
});
c
ahh, ok, so “name” == “logical name” and “resource name” == “physical name”? I think I’ve gotten myself confused because the first positional argument for pulumi resource constructors in node is
name
( see https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/ec2/instance.ts#L259 ) but in python it’s
resource_name
( see https://github.com/pulumi/pulumi-aws/blob/master/sdk/python/pulumi_aws/ec2/instance.py#L233 ) which made me reason that
name
==
resource_name
. But I guess that’s not the case?
g
Ah, that is confusing. Especially in this case, because EC2 instances don't actually have physical names at AWS anyway.
They're assigned IDs and you can add a "Name" tag to see a name in the AWS console.