Terraform was always passing a port on agent_to_agent and agent_to_server tests. This is fine for agent_to_agent as that test type does indeed require a port to be passed, but not for agent_to_server since ICMP based tests mustn't contain a port and TCP tests do not require the port to be passed (it'll default to 80 on ThousandEyes).
There are many approaches possible to fix this, but my constraints were:
Keep using the common schemas variable
Not separate agent_to_server resource into two resources: one for ICMP and one for TCP (which would allow us to create a specific port schema for each)
These constraints meant that the port had to be optional and not have default value for the agent_to_server resource. This meant that the schema definition for the port had to be different for agent_to_agent and agent_to_server, so I created this schema override logic.
Additionally, since port is now optional and has no default for agent_to_server, this means that agent_to_server TCP based resources/tests are now created using ThousandEyes' default port, which is 80. This also means that terraform will try to change the port back to 0 on every plan if using the ThousandEyes' default. To address this I used the DiffSuppressFunc, which checks if the new value of the port is "0".
The side effect of this is that you can create a new TCP based agent_to_server test with some port and then later remove the port parameter from the resource, and terraform will suppress the change. IMO this isn't a big deal. The previous behaviour would be to change the port to the terraform default which was 41953. I think I would rather have it not change the value then set it to 41953.
Let me hear your thoughts!
go vet ./... && echo && go test ./...
? github.com/thousandeyes/terraform-provider-thousandeyes [no test files]
ok github.com/thousandeyes/terraform-provider-thousandeyes/thousandeyes 0.427s
Terraform was always passing a port on
agent_to_agent
andagent_to_server
tests. This is fine foragent_to_agent
as that test type does indeed require a port to be passed, but not foragent_to_server
sinceICMP
based tests mustn't contain a port andTCP
tests do not require the port to be passed (it'll default to 80 on ThousandEyes).There are many approaches possible to fix this, but my constraints were:
schemas
variableagent_to_server
resource into two resources: one for ICMP and one for TCP (which would allow us to create a specific port schema for each)These constraints meant that the port had to be optional and not have default value for the
agent_to_server
resource. This meant that the schema definition for the port had to be different foragent_to_agent
andagent_to_server
, so I created this schema override logic.Additionally, since port is now optional and has no default for
agent_to_server
, this means thatagent_to_server
TCP based resources/tests are now created using ThousandEyes' default port, which is 80. This also means that terraform will try to change the port back to 0 on every plan if using the ThousandEyes' default. To address this I used theDiffSuppressFunc
, which checks if the new value of the port is"0"
.agent_to_server
test with some port and then later remove the port parameter from the resource, and terraform will suppress the change. IMO this isn't a big deal. The previous behaviour would be to change the port to the terraform default which was 41953. I think I would rather have it not change the value then set it to 41953.Let me hear your thoughts!