https://pulumi.com logo
Title
d

damp-fall-39416

01/18/2023, 9:42 PM
Hey guys, has anyone tried to implement unique ids in the URN of the resource with pulumi python? I'm working on a project where we are handling a naming convention but we need something that pulumi can provide us to solve this. I'll keep an eye out if anyone knows :D
e

echoing-dinner-19531

01/18/2023, 9:58 PM
Not totally sure what your asking for here? All pulumi logical names must be unique, the engine will error if a program tries to register the same name twice. By default pulumi will append random characters to the end of physical names (what's sent to the cloud provider) to try and ensure global uniqueness.
d

damp-fall-39416

01/19/2023, 2:07 PM
Okay, I'll try to be a little clearer. I'm trying for example to do something like this:
for subnet, nat_gateway in zip(
            subnets["subnets_objects"], nat_gateway_objects):

    private_route_table = RouteTable(
                f'myRouteTableExample-{region_suffix}',
    vpc_id=vpc.output.id,
    routes=[{"cidr_block": "0.0.0.0/0",
          "target_id": nat_gateway.id}])
Here I am trying to create several route tables dynamically, which I am iterating inside a for loop but the problem is that the resource_name would be the same and I would have to program something so that this resource_name is not repeated. What I want to know is if Pulumi provides a solution for this or should I implement something additional.
e

echoing-dinner-19531

01/19/2023, 4:04 PM
Yeh you need to do something custom there, probably putting the subnet and nat id's as part of the name or something
d

damp-fall-39416

01/20/2023, 3:15 PM
Ok, thanks for the quick response
e

early-cat-34152

01/26/2023, 9:34 AM
Why wouldn't autonaming work here? Multiple
RouteTable
instances are created, and get postfixed, no?
e

echoing-dinner-19531

01/26/2023, 9:37 AM
They each need a unique logical name as well
Autonaming is for trying to keep resource physical names unique across multiple stacks, it's on you the programmer to ensure logical names are unique within one stack
e

early-cat-34152

01/26/2023, 9:38 AM
It seems to me that autonaming could cover cases like these as well, in the future.
e

echoing-dinner-19531

01/26/2023, 9:39 AM
Maybe, but it starts getting into really hard to debug cases based on program ordering.
e

early-cat-34152

01/26/2023, 9:39 AM
Combined with timestamped logging, it would work..
e

echoing-dinner-19531

01/26/2023, 9:55 AM
I don't think it would, logical names are used for state tracking and the timestamp or program order of them isn't a feature we can safely track by