https://pulumi.com logo
#python
Title
# python
l

little-river-49422

02/05/2019, 12:23 PM
i dont see what governs this behaviour
i

incalculable-sundown-82514

02/05/2019, 5:52 PM
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

little-river-49422

02/05/2019, 6:27 PM
but I do specify it
it takes my input and adds random string at the end
i

incalculable-sundown-82514

02/05/2019, 6:27 PM
can you give a code example?
l

little-river-49422

02/05/2019, 6:28 PM
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

incalculable-sundown-82514

02/05/2019, 6:29 PM
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

little-river-49422

02/05/2019, 6:30 PM
eh. what does the first parameter assign?
i thought that is the name?
i

incalculable-sundown-82514

02/05/2019, 6:32 PM
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

little-river-49422

02/05/2019, 6:32 PM
oh, ok