README
¶
groundcover Terraform Provider
Terraform provider for managing groundcover resources.
Usage Examples
Basic usage examples can be found in the examples/ directory:
- Policy Resource:
examples/resources/groundcover_policy/resource.tf- Demonstrates how to define a
groundcover_policyresource, including roles and data scope.
- Demonstrates how to define a
- ServiceAccount Resource:
examples/resources/groundcover_serviceaccount/resource.tf- Shows how to create and manage service accounts with associated policies.
- API Key Resource:
examples/resources/groundcover_apikey/resource.tf- Illustrates API key creation and management for service accounts.
- Monitor Resource:
examples/resources/groundcover_monitor/resource.tf- Provides examples of configuring monitoring rules and alerts.
Local Development and Testing
To use this provider locally before it is published to the Terraform Registry, follow these steps:
-
Build the Provider: Compile the provider binary using the Makefile:
make buildThis command typically places the compiled
terraform-provider-groundcoverexecutable into the./distdirectory within your project. -
Configure Terraform CLI for Local Override: Terraform needs to know where to find your locally built provider instead of trying to download it from a registry. Create or edit the Terraform CLI configuration file (
~/.terraformrcon macOS/Linux,%APPDATA%\terraform.rcon Windows) and add the followingprovider_installationblock:# ~/.terraformrc or %APPDATA%\terraform.rc provider_installation { # Replace "groundcover/groundcover" if you used a different source # address in main.go. Replace the path with the actual absolute path # to the directory containing the built provider binary (step 1). dev_overrides { "registry.terraform.io/groundcover/groundcover" = "/Users/<YOUR_HOME_FOLDER>/projects/terraform-provider-groundcover/dist" # Example for Windows: # "registry.terraform.io/groundcover/groundcover" = "C:/Users/<YourUser>/path/to/terraform-provider-groundcover/dist" } # For all other providers, install them directly from their origin registries. direct {} }- Important: Replace
registry.terraform.io/groundcover/groundcoverif your provider address inmain.gois different. - Important: Replace
/Users/<YOUR_HOME_FOLDER>/projects/terraform-provider-groundcover/distwith the absolute path to the directory containing theterraform-provider-groundcoverbinary built bymake build.
- Important: Replace
-
Use in a Terraform Project: In a separate directory for your Terraform configuration:
- Create a
.tffile (e.g.,main.tf). - Declare the provider requirement, ensuring the
sourcematches the one used indev_overrides:# main.tf terraform { required_providers { # This 'source' value MUST exactly match: # 1. The key used in your ~/.terraformrc dev_overrides block # 2. The 'Address' set in your provider's main.go groundcover = { source = "registry.terraform.io/groundcover/groundcover" # Version constraint is still good practice, but less critical # for local dev as dev_overrides takes precedence. # Use ">= 0.1.0" or similar if you haven't tagged releases yet. version = ">= 0.0.0" } } } # Configure the provider instance provider "groundcover" { # It's STRONGLY recommended to provide the API key via an environment variable # export TF_VAR_groundcover_api_key="YOUR_API_KEY_HERE" api_key = var.groundcover_api_key # Use this if defining a variable below # Base URL is optional, defaults to api.groundcover.com in the provider code api_url = "https://api.main.groundcover.com" # defaults to https://api.groundcover.com org_name = "groundcover" # your organization ID as provided in the installation } # (Optional but recommended) Define input variables variable "groundcover_api_key" { type = string description = "groundcover API Key" sensitive = true } # Define a policy resource using your provider resource "groundcover_policy" "test_policy" { name = "My Terraform Test Policy" description = "Policy managed via local Terraform provider build" claim_role = "tf-test-claim" role = { admin = "admin" # key is "read"/"write"/"admin" - value is ignored } # Example data_scope (adjust based on actual API needs) data_scope = { simple = { operator = "and" conditions = [ { key = "cluster" origin = "root" type = "string" filters = [ { op = "match" value = "my-prod-cluster" } ] }, { key = "namespace" origin = "root" type = "string" filters = [ { op = "not_match" value = "kube-system" } ] } ] } } } output "policy_id" { value = groundcover_policy.test_policy.uuid } output "policy_revision" { value = groundcover_policy.test_policy.revision_number } - Run
terraform init. Terraform will detect thedev_overridesand use your local build.
- Create a
Requirements
- Terraform >= 1.0 (Check
required_versionif specified inmain.tf) - Go >= 1.21 (to build the provider plugin)
- groundcover Account and API Key.
Provider Reference
Configure the groundcover provider in your Terraform configuration:
provider "groundcover" {
# api_key = "YOUR_API_KEY" # Required
# base_url = "https://api.your-instance.groundcover.com" # Optional
}
Arguments
api_key(String, Required, Sensitive): Your groundcover API key. It is strongly recommended to configure this using theTF_VAR_groundcover_api_keyenvironment variable rather than hardcoding it.base_url(String, Optional): The base URL for the groundcover API. Defaults toapi.groundcover.comif not specified.
Resource Reference
See the REFERENCE.md file for detailed documentation of each resource. For detailed examples of how to use each resource, see the examples directory.
Documentation
¶
There is no documentation for this package.