Skip to content

fix: Add tests for instance and app association - #2198

Merged
kylecarbs merged 1 commit into
mainfrom
instanceassociation
Jun 9, 2022
Merged

fix: Add tests for instance and app association#2198
kylecarbs merged 1 commit into
mainfrom
instanceassociation

Conversation

@kylecarbs

Copy link
Copy Markdown
Member

This was regressed in #2187. There was bad testing around this
before, and this should prevent a similar situation from happening
again!

@kylecarbs
kylecarbs requested a review from deansheather June 9, 2022 12:59
@kylecarbs kylecarbs self-assigned this Jun 9, 2022
@kylecarbs
kylecarbs requested a review from johnstcn June 9, 2022 13:03
@johnstcn
johnstcn requested a review from mafredri June 9, 2022 13:06

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not as familiar with this part of the codebase, but this proposed change LGTM!

Comment thread provisioner/terraform/resources.go Outdated
This was regressed in #2187. There was bad testing around this
before, and this should prevent a similiar situation from happening
again!
@kylecarbs
kylecarbs force-pushed the instanceassociation branch from 83651bc to bc84d9f Compare June 9, 2022 13:21
@kylecarbs
kylecarbs enabled auto-merge (squash) June 9, 2022 13:21
@kylecarbs
kylecarbs merged commit fff59ef into main Jun 9, 2022
@kylecarbs
kylecarbs deleted the instanceassociation branch June 9, 2022 13:34

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

"aws_instance": "id",
"azurerm_linux_virtual_machine": "id",
"azurerm_windows_virtual_machine": "id",
}[resource.Type]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😄

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants