This is a Terraform provider for managing Komodo resources via the Komodo API.
- Requirements
- Quick Start
- Using the Provider
- Resources
- Examples
- Troubleshooting
- Developing the Provider
# Clone the repository
git clone <your-repo-url>
cd terraform-provider-komodo
# Build the provider
go build -o terraform-provider-komodoFor local development, use Terraform's development overrides.
Create or edit ~/.terraformrc:
provider_installation {
dev_overrides {
"jkossis/komodo" = "/path/to/terraform-provider-komodo"
}
direct {}
}Replace /path/to/terraform-provider-komodo with the actual path to your repository directory.
Set your Komodo credentials:
export KOMODO_ENDPOINT="https://your-komodo-server.com"
export KOMODO_USERNAME="your-username"
export KOMODO_PASSWORD="your-password"Create a file named main.tf:
terraform {
required_providers {
komodo = {
source = "jkossis/komodo"
}
}
}
provider "komodo" {
# endpoint, username, and password will be read from environment variables
}
resource "komodo_api_key" "example" {
name = "my-api-key"
}
output "api_key" {
value = komodo_api_key.example.key
}
output "api_secret" {
value = komodo_api_key.example.secret
sensitive = true
}# Initialize Terraform
terraform init
# Plan the changes
terraform plan
# Apply the configuration
terraform apply
# When you're done, destroy the resources
terraform destroyThe provider requires three configuration values:
endpoint- The URL of your Komodo API endpointusername- Your Komodo usernamepassword- Your Komodo password
These can be configured in three ways:
provider "komodo" {
endpoint = "https://your-komodo-server.com"
username = "your-username"
password = "your-password"
}export KOMODO_ENDPOINT="https://your-komodo-server.com"
export KOMODO_USERNAME="your-username"
export KOMODO_PASSWORD="your-password"provider "komodo" {
endpoint = "https://your-komodo-server.com"
# username and password will be read from environment variables
}Manages a Komodo API key.
Example Usage:
# Create an API key
resource "komodo_api_key" "example" {
name = "my-api-key"
expires = 0 # 0 means never expires
}
# Output the credentials
output "api_key" {
value = komodo_api_key.example.key
}
output "api_secret" {
value = komodo_api_key.example.secret
sensitive = true
}Schema:
name(Required, String) - A human-friendly name for the API key.expires(Optional, Int64) - Expiration timestamp in milliseconds since epoch. Use 0 for no expiration. Default:0
Computed Attributes:
key(String) - The API key identifiersecret(String, Sensitive) - The API key secret (only available on creation)user_id(String) - The ID of the user who owns this keycreated_at(Int64) - Creation timestamp in milliseconds since epoch
Important Notes:
- The secret is only returned when the key is created. It's not available after creation, so store it securely.
- API keys are immutable. Changing the
nameorexpiresattributes will force the resource to be destroyed and recreated with a new key and secret.
Check out the examples directory for more configurations:
If you see an error like "provider registry.terraform.io/jkossis/komodo not found", make sure:
- You've set up the dev overrides in
~/.terraformrccorrectly - The path in dev overrides points to the directory containing the built binary
- You've built the provider binary (
go build -o terraform-provider-komodo)
If you see authentication errors:
- Verify your Komodo credentials are correct
- Check that the endpoint URL is correct (including protocol)
- Ensure your user has permission to create API keys
If you see connection errors:
- Verify your Komodo instance is running and accessible
- Check that the endpoint URL is correct
- Check Komodo logs for any API errors
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.
To generate or update documentation, run make generate.
To run the full suite of acceptance tests, you'll need a running Komodo instance.
Set up your test environment:
export KOMODO_ENDPOINT="https://your-komodo-server.com"
export KOMODO_USERNAME="your-username"
export KOMODO_PASSWORD="your-password"Then run the tests:
make testaccThis provider is published under the MPL-2.0 license.