Skip to content

justtrackio/terraform-provider-keep

Repository files navigation

terraform-provider-keep

docs downloads latest version license

This is a terraform provider for managing your keep instance.

Note: This provider is not official terraform provider for keep.

Installation

Add the following to your terraform configuration

terraform {
  required_providers {
    keep = {
      source  = "pehlicd/keep"
      version = "~> 0.0.1"
    }
  }
}

Example

provider "keep" {
  backend_url = "http://localhost:8080" # or use environment variable KEEP_BACKEND_URL
  api_key = "your apikey" # or use environment variable KEEP_API_KEY
}

resource "keep_workflow" "example_workflow" {
  workflow_file_path = "path/to/workflow.yml"
}

resource "keep_mapping" "example_mapping" {
  name = "example_mapping"
  mapping_file_path = "path/to/mapping.yml"
  matchers = [
    "your unique matcher",
  ]
  #priority = 1 (optional)
}

resource "keep_provider" "example_provider" {
  name = "example_provider"
  type = "supported_provider_type"
  auth_config = {
    //...
    // Add your provider specific configuration
    //...
  }
  #install_webhook = true (optional)
}

data "keep_workflow" "example_workflow_data" {
  id = keep_workflow.example_workflow.id
}

data "keep_mapping" "example_mapping_data" {
  id = keep_mapping.example_mapping.id
}

Testing

To run the acceptance tests for this provider, you'll need to set the following environment variables:

# Keep API Configuration
export KEEP_BACKEND_URL="your-keep-backend-url"
export KEEP_API_KEY="your-keep-api-key"
export KEEP_TIMEOUT="30s"  # Optional, defaults to 30s

# AKS Provider Test Configuration
export AKS_SUBSCRIPTION_ID="your-subscription-id"
export AKS_CLIENT_ID="your-client-id"
export AKS_CLIENT_SECRET="your-client-secret"
export AKS_TENANT_ID="your-tenant-id"
export AKS_RESOURCE_GROUP_NAME="your-resource-group"
export AKS_RESOURCE_NAME="your-resource-name"

Then run the tests using:

# Run all tests
TF_ACC=1 go test ./... -v

# Run specific tests
TF_ACC=1 go test ./keep -v -run "TestAccProvider|TestAccResourceProvider"

Note: These are acceptance tests that create and destroy real resources. Make sure you're using test credentials and resources.

Running Tests with Docker Compose

You can also run the tests using Docker Compose, which will automatically set up a local Keep backend instance.

Then run the tests with:

# Start the Keep backend
docker compose up -d

# Run tests with test credentials
export AKS_SUBSCRIPTION_ID=test-subscription-id
export AKS_CLIENT_ID=test-client-id
export AKS_CLIENT_SECRET=test-client-secret
export AKS_TENANT_ID=test-tenant-id
export AKS_RESOURCE_GROUP_NAME=test-resource-group
export AKS_RESOURCE_NAME=test-resource-name
TF_ACC=1 KEEP_BACKEND_URL=http://localhost:8080 KEEP_API_KEY=keepappkey go test ./... -v

# Clean up
docker compose down

For more information, please refer to the documentation.

You can also find some hands-on examples in the examples directory.

You feel overwhelmed with these bunch of information? Don't worry, we got you covered. Just join keep slack workspace and throw your questions.

Slack

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •