fleet/tools/terraform/Makefile
Mike Yoder c7ea0125d6
Support for Terraforming Fleet Teams (#18750)
This project adds support for terraforming teams in Fleet. If you have
100+ teams, managing them is is prone to error, mistakes, lost
configuration, and general pain. An industry standard tool like
terraform can unify this configuration as code.

In order to do this, I wrote a terraform provider that on one end talks
to the Fleet api, and on the other end implements an interface for
terraform. More information is in the README.

A small sample `main.tf` file is supplied.

---------

Co-authored-by: Brock Walters <153771548+nonpunctual@users.noreply.github.com>
2024-06-20 12:47:35 -07:00

42 lines
1.2 KiB
Makefile

#! /usr/bin/env make
#
# While not very elegant as far as Makefiles go, this Makefile does
# contain the basic commands to get you terraforming your FleetDM
# teams. See the README for details.
provider_code_spec.json: openapi.json
tfplugingen-openapi generate --config generator.yaml --output ./provider_code_spec.json ./openapi.json
provider/team_resource_gen.go: provider_code_spec.json
tfplugingen-framework generate resources --input provider_code_spec.json --output ./provider --package provider
.PHONY: install build test tidy gen plan apply
gen: provider/team_resource_gen.go
install: gen
go install ./...
build: gen
go build ./...
test: gen
@test -n "$(FLEETDM_APIKEY)" || (echo "FLEETDM_APIKEY is not set" && exit 1)
FLEETDM_URL='https://rbx.cloud.fleetdm.com' TF_ACC=1 go test ./...
tidy:
go mod tidy
plan: tf/terraformrc-dev-override
cd tf && TF_CLI_CONFIG_FILE=./terraformrc-dev-override terraform plan
apply: tf/terraformrc-dev-override
cd tf && TF_CLI_CONFIG_FILE=./terraformrc-dev-override terraform apply -auto-approve
tf/terraformrc-dev-override:
@echo "provider_installation { \\n\
dev_overrides { \\n\
\"fleetdm.com/tf/fleetdm\" = \"$$HOME/go/bin\" \\n\
} \\n\
direct {} \\n\
}" > $@