fleet/tools/terraform
Scott Gress 59f96651b6
Update to Go 1.24.1 (#27506)
For #26713 

# Details

This PR updates Fleet and its related tools and binaries to use Go
version 1.24.1.

Scanning through the changelog, I didn't see anything relevant to Fleet
that requires action. The only possible breaking change I spotted was:

> As [announced](https://tip.golang.org/doc/go1.23#linux) in the Go 1.23
release notes, Go 1.24 requires Linux kernel version 3.2 or later.

Linux kernel 3.2 was released in January of 2012, so I think we can
commit to dropping support for earlier kernel versions.

The new [tools directive](https://tip.golang.org/doc/go1.24#tools) is
interesting as it means we can move away from using `tools.go` files,
but it's not a required update.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [x] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [X] Make sure fleetd is compatible with the latest released version of
Fleet
   - [x] Orbit runs on macOS  , Linux   and Windows. 
- [x] Manual QA must be performed in the three main OSs, macOS ,
Windows and Linux .
2025-03-31 11:14:09 -05:00
..
fleetdm_client Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
provider Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
tf Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
.gitignore Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
generator.yaml Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
go.mod Update to Go 1.24.1 (#27506) 2025-03-31 11:14:09 -05:00
go.sum Bump golang.org/x/net from 0.33.0 to 0.36.0 in /tools/terraform (#27095) 2025-03-13 07:35:32 -03:00
main.go Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
Makefile Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
openapi.json Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00
README.md Support for Terraforming Fleet Teams (#18750) 2024-06-20 12:47:35 -07:00

Terraform Provider for FleetDM Teams

This is a Terraform provider for managing FleetDM teams. When you have 100+ teams in FleetDM, and manually managing them is not feasible. The primary setting of concern is the team's "agent options" which consists of some settings and command line flags. These (potentially dangerously) configure FleetDM all machines.

Usage

All the interesting commands are in the Makefile. If you just want to use the thing, see make install and make apply.

Note that if you run terraform apply in the tf directory, it won't work out of the box. That's because you need to set the TF_CLI_CONFIG_FILE environment variable to point to a file that enables local development of this provider. The Makefile does this for you.

Future work: actually publish this provider.

Development

Code Generation

See make gen. It will create team_resource_gen.go, which defines the types that Terraform knows about. This is automatically run when you run make install.

Running locally

See make plan and make apply.

Running Tests

You probably guessed this. See make test. Note that these tests require a FleetDM server to be running. The tests will create teams and delete them when they're done. The tests also require a valid FleetDM API token to be in the FLEETDM_APIKEY environment variable.

Debugging locally

The basic idea is that you want to run the provider in a debugger. When terraform normally runs, it will execute the provider a few times in the course of operations. What you want to do instead is to run the provider in debug mode and tell terraform to contact it.

To do this, you need to start the provider with the -debug flag inside a debugger. You'll also need to give it the FLEETDM_APIKEY environment variable. The provider will print out a big environment variable that you can copy and paste to your command line.

When you run terraform apply or the like, you'll invoke it with that big environment variable. It'll look something like

TF_REATTACH_PROVIDERS='{"fleetdm.com/tf/fleetdm":{"Protocol":"grpc","ProtocolVersion":6,"Pid":33644,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/32/xw2p1jtd4w10hpnsyrb_4nmm0000gq/T/plugin771405263"}}}' terraform apply

With this magic, terraform will look to your provider that's running in a debugger. You get breakpoints and the goodness of a debugger.