i dont see what governs this behaviour
# python
l
i dont see what governs this behaviour
i
We’ve got a TODO for documenting that: https://github.com/pulumi/docs/issues/486. The short answer is that, if you don’t specify an explicit name for a resource, Pulumi will autoname it by taking the name that you gave the object and adding a random suffix to it.
l
but I do specify it
it takes my input and adds random string at the end
i
can you give a code example?
l
sample code:
Copy code
import pulumi
from pulumi_azure.core import ResourceGroup
from pulumi_azure.signalr import Service
from pulumi_azure.storage import Account
from pulumi_azure.containerservice import KubernetesCluster, Registry
from pulumi_azure.network import VirtualNetwork, Subnet

rg = ResourceGroup(
    'rg',
    location='westeurope'
)

storageacct = Account(
    'storage',
    location=rg.location,
    resource_group_name=rg.name,
    account_replication_type='LRS',
    account_tier='standard'
)

signalracct = Service(
    'signalr',
    location=rg.location,
    resource_group_name=rg.name,
    sku={
        "name": "Free_F1",
        "capacity": 1
    }
)

vnet = VirtualNetwork(
    'vnet',
    location=rg.location,
    resource_group_name=rg.name,
    address_spaces=['10.0.0.0/8']
)
i
By “specifying a name explicitly” I mean “giving a value to the
name
property” - many resource have a
name
property that will be passed verbatim to the resource you create.
Like
VirtualNetwork('vnet', name="My Virtual Net")
l
eh. what does the first parameter assign?
i thought that is the name?
i
It’s a name in the Pulumi object model. It’s not super clear in the programming model docs (https://pulumi.io/reference/programming-model.html#overview) but this particular name refers to the Pulumi object model - it must be unique in a Pulumi program. It doesn’t have a direct relationship with the name of resources that ultimately get created, except that Pulumi uses it to autoname things if you didn’t explicitly provide a resource name.
l
oh, ok