How to resolve "Error: public_subnet_range: duplicate local. local value must be unique" error while deploying a Konvoy cluster
Overview/Background
Konvoy enables users to add custom Terraform resources or override the default resources created by Konvoy as documented here. It utilizes the concept of Override files in Terraform Configuration Language. To override resources you can define them in files with names ending in _override.tf. However due to a know issue in Terraform 0.11, that Konvoy uses, resources using locals would run into errors with overrides similar to the following block
STAGE [Provisioning Infrastructure] Error: public_subnet_range: duplicate local. local value must be unique Error: private_subnet_range: duplicate local. local value must be unique Error: control_plane_subnet_range: duplicate local. local value must be unique
Workaround
This issue can be worked around by copying the entire subnet resource definition and modifying the desired values. This modified file can then be placed in extras/provisioner directory under the working directory for your Konvoy cluster. To copy the original subnets.tf file, first run konvoy up without -y or --yes flags.
konvoy up
This will launch the mesosphere/konvoy docker container for the version you are running and wait at the prompt
This process will take about 15 minutes to complete (additional time may be required for larger clusters), do you want to continue [y/n]:
giving us time to copy files from the container. Open a new terminal session and use docker ps to get the container id
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 848b9c044947 mesosphere/konvoy:v1.5.1 "konvoy up" 13 seconds ago Up 12 seconds bold_curran
The container ID from the command output can then be used to copy the subnets.tf out of the container
docker cp 848b9c044947:/opt/konvoy/providers/aws/subnets.tf .
Make sure to replace 848b9c044947with the contained ID you get and aws with azure or gcp as needed. Now you should have a subnets.tf file in your current directory. You can modify this file to your linking and place it in extras/provisioner directory to customize your install. You can also press Enter to exit out to the konvoy up session you started earlier.