In the docs, if an item doesn't have a 'Import' se...
# general
b
In the docs, if an item doesn't have a 'Import' section, is it a resource that can't be imported? For example,
aws:ec2/mainRouteTableAssociation:MainRouteTableAssociation
or is a matter of figuring out the correct Id to use?
l
That might be a doc bug. The docs for route table associations is correct: https://www.pulumi.com/registry/packages/aws/api-docs/ec2/routetableassociation/ (Well, apart from some missing text...)
👍 1
b
I'm specifying the id on the import as subnet-id/routeTable-id and getting. So its finding it but can't import the RouteTableAssociation. I'm using the latest Pulumi.Aws and the 3.15.0 cli.
l
Nuts. Must be different for MainRouteTableAssociation... maybe because the subnet id isn't mandatory? Looks like you'll have to guess... 😞 Maybe the TF docs have more info? Onesec...
Nope. Do you want to try vpc.id/routeTable.id? Since they're the only two properties, and they're both mandatory...
b
I'm trying to import a RouteTableAssociation not a MainRouteTableAssociation. I was messing around with both. I could easily code it up but wanted to see if I could get import working. I'm kind of curious how it all works, might have to dig around in the cli code 🙂 But yeah, I can view the imported RouteTable in the stack and it looks good.
Sure
l
You couldn't import the RouteTableAssociation either? I thought it was just the MainRouteTableAssociation that wasn't working.
b
I skipped the MainRouteTableAssociation and am trying RouteTableAssociation.
Copy code
No association found between route table ID rtb-0b60460a8ee6c26fa and target ID vpc-0fcfcc82840f34979
dumping the tf state, I can see the
aws_route_table_association
has an id, route_table_id and subnet_id. I've tried both id and route_table_id
l
To clarify: you're importing a RouteTableAssociation, for a RouteTable that is already in state, and a Subnet that already exists in state? You need to set the import property to subnet.id/routeTable.id.
You can hardcode those values since they're used only once.
RouteTables aren't associated with VPCs, they're associated with subnets.
b
In this case, the 3 resources are in a json as a bulk import.
l
Did the import work? What code was generated? Does it include the gatewayId property? If it does, then that's the error; remove the gatewayId.
b
no code generated
l
You're running
pulumi import
and seeing this? Or
pulumi preview
?
b
Copy code
pulumi import -f import-network.json -y -o import-network.cs
l
I can't see a problem with that. I would raise an issue and hand-craft the source. It's a small amount of code.
You just need to add the import property to the opt parameter of the RouteTableAssociation initially, then remove it after the import works.
👍 1
b
ok, will do. I just tried with 3.16.0 for kicks and same issue
l
🤞
b
What do you mean by, add the import property to the opt parameter?
oh, in code you mean
l
Yes. Write the Pulumi code for the association, add the opt parameter, put the import property in it initially, and remove it after it's in state.
That's the "old" way for importing resources, it still works.
b
makes sense, thanks
👍 1