fix: Add tests for instance and app association - #2198
Conversation
johnstcn
left a comment
There was a problem hiding this comment.
I'm not as familiar with this part of the codebase, but this proposed change LGTM!
This was regressed in #2187. There was bad testing around this before, and this should prevent a similiar situation from happening again!
83651bc to
bc84d9f
Compare
| "aws_instance": "id", | ||
| "azurerm_linux_virtual_machine": "id", | ||
| "azurerm_windows_virtual_machine": "id", | ||
| }[resource.Type] |
There was a problem hiding this comment.
So I'm still pretty noobish when it comes to Terraform, but it seems like we're automatically mapping these resource types for all agents. So for instance if there's both a google_compute_instance, and an aws_instance, one would overwrite the other?
I'm sure the above wouldn't be a common use case, but I imagine it would be possible to create a semi-complex Terraform template with multiple providers depending on certain selections? And I imagine this would be a use-case for having multiple agents, are there others?
If my questions make no sense, feel free to disregard 😄
There was a problem hiding this comment.
If my questions make no sense, feel free to disregard 😄
All questions I'm happy to answer!
So for instance if there's both a google_compute_instance, and an aws_instance, one would overwrite the other?
There's a one -> many mapping of resource to agent. If a resource isn't using token authentication, we assume it's using the zero-trust providers we support: *-instance-identity under the auth parameter on an agent. An instance ID can be manually associated with the coder_agent_instance resource, but we automatically associate it with one of the listed resource types. There isn't an explicit reason we need to do this, and it might end up adding more confusion, so it's not impossible we remove it at some point.
There was a problem hiding this comment.
Ok, thanks for clarifying @kylecarbs! I don't think we need to make any changes to it at this point, but good to be aware of it.
This was regressed in #2187. There was bad testing around this
before, and this should prevent a similar situation from happening
again!