Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Terraform Cloud Agents #242

Merged
merged 16 commits into from
Nov 20, 2020
Merged

Conversation

chrisarcand
Copy link
Member

@chrisarcand chrisarcand commented Nov 17, 2020

Description

This adds support for Terraform Cloud Agents, now that agent pools have a full resource lifecycle and can be managed via Terraform. Specifically this adds a tfe_agent_pool resource and datasource (https://www.terraform.io/docs/cloud/api/agents.html) and allows configuring them for use in a Terraform Cloud workspace with the new execution-mode attribute.

Closes #204

Testing plan

  • Agent pool management should behave as you expect (it's a simple resource)
  • Workspace configuration with execution_mode and agent_pool_id should behave smoothly, allowing for continued use of the deprecated operations argument or a seamless switch to execution_mode. Their use should be mutually exclusive. The only known rough edge I have found is moving from execution_mode = "agent" back to operations = true/false fails schema validations, because of the limitations of validating existing state. This is acceptable though, as if you're already using execution_mode there is no reason to revert back to operations.
  • Agent pool imports should work: simply import by ID, you don't even need the org name: terraform import tfe_agent_pool.name apool-xxxx

External links

TODO

  • Provider documentation
  • Deprecate operations? Might save that for a separate change.
  • Add Terraform Enterprise disclaimers to documentation
  • Bump go-tfe, after verifying CI passes with a ref.

tfe/resource_tfe_agent_pool.go Outdated Show resolved Hide resolved
tfe/resource_tfe_agent_pool.go Outdated Show resolved Hide resolved
tfe/resource_tfe_agent_pool.go Show resolved Hide resolved
tfe/resource_tfe_agent_pool_test.go Outdated Show resolved Hide resolved
tfe/resource_tfe_workspace_test.go Outdated Show resolved Hide resolved
@chrisarcand chrisarcand force-pushed the tfc-agents-rebased branch 7 times, most recently from 7fb1efe to c54bb28 Compare November 19, 2020 23:31
chrisarcand and others added 15 commits November 19, 2020 22:52
Agent pools do not have a full resource lifecycle yet, so an associated
resource here in the provider is not supported - yet.

This has the interesting side effect of needing to create an agent pool
out-of-band of the provider, temporarily.

This datasource is being added now, however, to be able to configure a
workspace to use an organization's single pool.
And utilize it in the data source tests, as well.
And some tests to go with all this.
'operations' can't be set at all, not just 'true'.
This allows importing by solely an ID to work properly.
Copy link
Contributor

@lafentres lafentres left a comment

Choose a reason for hiding this comment

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

i ran this through several different test scenarios and it all looks good to me (aside from that small note about validating execution mode).

i did get some warnings locally about needing to run go mod vendor when building this. it might just be me so this might be something you can ignore.
i'm not sure if i'm just on a different go version or if some of the vendor directories didn't get committed with the last PR but it might be worth running go mod vendor again and making sure all the directories are added/tracked (i've had this get messed up on me before).

Co-authored-by: Krista LaFentres (she/her) <[email protected]>
@chrisarcand chrisarcand merged commit 7fe2653 into master Nov 20, 2020
@chrisarcand chrisarcand deleted the tfc-agents-rebased branch November 20, 2020 17:10
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.

[Feature Request] Updated Workspace to allow for "agent" Operation type.
2 participants