Hi, can anyone direct me on how to modify an pulum...
# python
a
Hi, can anyone direct me on how to modify an pulumi output obj - AWS? I have created an RouteTable object with one route. Now I want to modify this object by adding another route to the table. I have the created the object (rt) and now I tried to append to routes by
rt.routes.append(<new route args>)
but I’m getting the followiing error
Copy code
route_table.routes.append(route_args)
TypeError: 'Output' object is not callable
m
The
routes
property is an "output" property of RouteTable, which means it's read-only. To add routes to a route table, you can either declare them on the
RouteTable
declaration itself, like this: https://github.com/pulumi/examples/blob/45eeabec900da9f8d2446d36879887828560f086/aws-py-eks/vpc.py#L24C1-L34C2 or as individual
Route
resources associated to the
RouteTable
, such as https://github.com/pulumi/examples/blob/45eeabec900da9f8d2446d36879887828560f086/aws-py-hub-and-spoke-network/inspection.py#L303-L314
Maybe the second example is more what you're looking for?
a
I think it’s closer to the second example, but is the key the ResourceOptions?
What I’m trying to do is I already have my stack deployed with a set of route tables. Now I’m adding a peering connection and with that i would like to update the current set of route tables with an additional route entry.
So what I have code wise is an array of the route table objects, and I would like to modify/add to the routes field. Would you have a suggestion on how to accomplish this ?
m
Are the new route entry and peering connection being managed by the same Pulumi program that defines the RouteTables?
a
yes
m
So you're adding new code to, say, the same Python file that defines the RouteTables, ok. I haven't tried this myself (not super familiar with these resources) , but I suspect you'll want to do something like this -- this is TypeScript, but the resources are the same, with additional
Route
resources declared that reference a `VpcPeeringConnection`: https://github.com/pulumi/examples/blob/45eeabec900da9f8d2446d36879887828560f086/aws-ts-stackreference-architecture/networking/src/vpc.ts#L311-L335
a
Thank you I’ll take a look
m
You bet, let me know if it helps! There's a bunch of code in there, but I think those are the resources and relationships you're looking for
a
I got it working thanks for the tips/samples