In AWS, using Terraform I have launched certain instances running in private subnet. I have to install certain packages in the private instances. So i make a temporary associaton with a route table which is connected to internet gateway. After installation of the packages when i want to make the association of that particular subnet with the route table which is connected to NAT, it is throwing an error telling that route table association already exist. But if i go to aws console i'm able to do it manually. Is there any way on how can i do it using terraform?
Thank you in Advance.
Without seeing your Terraform file is a bit difficult. But from your explanation it seems that the default behaviour of the VPC is to use the route table that is connected to a NAT instance. You can create the route table and then make it VPC's default with Terraform in this way:
Then when you want to temporarily associate a subnet to your internet gateway it's just a matter of adding the following:
Once you're done remove the route table association.