https://pulumi.com logo
#general
Title
# general
b

bored-activity-40468

10/20/2021, 6:32 PM
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

little-cartoon-10569

10/20/2021, 6:40 PM
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

bored-activity-40468

10/20/2021, 10:05 PM
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

little-cartoon-10569

10/20/2021, 10:09 PM
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

bored-activity-40468

10/20/2021, 10:13 PM
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

little-cartoon-10569

10/20/2021, 10:14 PM
You couldn't import the RouteTableAssociation either? I thought it was just the MainRouteTableAssociation that wasn't working.
b

bored-activity-40468

10/20/2021, 10:15 PM
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

little-cartoon-10569

10/20/2021, 10:20 PM
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

bored-activity-40468

10/20/2021, 10:20 PM
In this case, the 3 resources are in a json as a bulk import.
l

little-cartoon-10569

10/20/2021, 10:27 PM
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

bored-activity-40468

10/20/2021, 10:28 PM
no code generated
l

little-cartoon-10569

10/20/2021, 10:30 PM
You're running
pulumi import
and seeing this? Or
pulumi preview
?
b

bored-activity-40468

10/20/2021, 10:31 PM
Copy code
pulumi import -f import-network.json -y -o import-network.cs
l

little-cartoon-10569

10/20/2021, 10:32 PM
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

bored-activity-40468

10/20/2021, 10:33 PM
ok, will do. I just tried with 3.16.0 for kicks and same issue
l

little-cartoon-10569

10/20/2021, 10:33 PM
🤞
b

bored-activity-40468

10/20/2021, 10:34 PM
What do you mean by, add the import property to the opt parameter?
oh, in code you mean
l

little-cartoon-10569

10/20/2021, 10:35 PM
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

bored-activity-40468

10/20/2021, 10:35 PM
makes sense, thanks
👍 1
19 Views