The Kion Terraform Provider enables you to manage your Kion resources using HashiCorp's Terraform infrastructure as code tool. This provider supports creating, updating, reading, and deleting resources through Terraform, as well as querying existing resources using filters.
# Configure the Kion Provider
terraform {
  required_providers {
    kion = {
      source  = "kionsoftware/kion"
      # Kion recommends pinning the provider to a specific version, though usually you want to use the latest one.
      # version = "x.x.x"
    }
  }
}
provider "kion" {
  # If these are commented out, they will be loaded from environment variables.  To load them from the environment variables, be sure you're prefixing the exported environment variable correctly with TF_VAR
  # kion_url    = "https://kion.example.com"
  # kion_apikey = "key here"
}
# Create an IAM policy
resource "kion_aws_iam_policy" "example" {
  name        = "example-policy"
  description = "Example IAM Policy"
  policy      = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Action    = "*"
      Resource  = "*"
    }]
  })
}- Install Terraform (1.0+)
 - Create a new directory for your Terraform configuration
 - Create a 
providers.tffile with the following content: 
terraform {
  required_providers {
    kion = {
      source    = "kionsoftware/kion"
      # Recommended: Pin to a specific version
      # version = "x.x.x"
    }
  }
}
provider "kion" {
  # If these are commented out, they will be loaded from environment variables.  To load them from the environment variables, be sure you're prefixing the exported environment variable correctly with TF_VAR
  # kion_url    = "https://kion.example.com"
  # kion_apikey = "key here"
}- Initialize Terraform:
 
terraform initYou can authenticate with Kion using either environment variables or provider configuration:
export TF_VAR_kion_url="https://kion.example.com"
export TF_VAR_kion_apikey="your-api-key"provider "kion" {
  kion_url    = "https://kion.example.com"
  kion_apikey = "your-api-key"
}For a complete list of available resources and data sources, please refer to our provider documentation.
The provider supports importing existing Kion resources into Terraform state. This allows you to manage existing resources without recreating them.
To import a resource:
- Create the resource configuration in your Terraform files
 - Import the resource state:
 
terraform import [resource_type].[resource_name] [resource_id]Example:
terraform import kion_aws_cloudformation_template.audit_logging 20For a complete list of available data sources, please refer to our provider documentation.
For repository maintainers pushing to the Terraform Registry:
- Update the version in the Makefile
 - Create and push a new tag:
 
git tag -a vX.Y.Z -m "Description of changes"
git push origin vX.Y.Z