I have AWS clientVPN which was created manually from AWS console and it has around 20 plus route table entry. Now, I want to terraform this so we can add any new route using terraform.
I have imported the ClientVPN information using terraform import. To import all the existing routes, I can import one route at a time also for each route Import I need to add resource entry in main.tf as shown below:
Command used to import the route table entry:
$ terraform import aws_ec2_client_vpn_route.example cvpn-endpoint-0e3e121d2,subnet-08acf2,<CIDR>
This command updates the .tfstate file and when I run terraform plan it gives me an error because I need to add resource section for this in main.tf file.
resource "aws_ec2_client_vpn_route" "example" {
client_vpn_endpoint_id = var.client_vpn_endpoint_id
destination_cidr_block = "CIDR"
target_vpc_subnet_id = var.target_vpc_subnet_id
}
resource "aws_ec2_client_vpn_route" "example1" {
client_vpn_endpoint_id = var.client_vpn_endpoint_id
destination_cidr_block = "CIDR"
target_vpc_subnet_id = var.target_vpc_subnet_id
}
Each time, I import the route, I need to add resource in main.tf. If I have 20 route table entry then I have to write 20 resource entry in main.tf file?
I just want to use one resource entry in main.tf, how is it possible?