Skip to content

rawdaGastan/terraform-provider-plugin

Repository files navigation

Terraform provider plugin

This folder encapsulates the Terraform Provider that issues API calls to the pkid.

Run the example

  • Initialize Terraform
terraform init

Run the example locally

To run the Terraform Provider locally there are a few steps to complete:

Step 1: Make sure your pkid server is running

Step 2: Build the source code locally and move into the local terraform plugin folder:

mkdir -p ~/.terraform.d/plugins/example.com/local/plugin/1.0.0/linux_amd64
go build -o ~/.terraform.d/plugins/example.com/local/plugin/1.0.0/linux_amd64 

Or:

make build

Note: The plugin folder may need to be created.

Step 3: Use:

terraform {
  required_providers {
    plugin = {
      source  = "example.com/local/plugin"
      version = "~> 1.0.0"
    }
  }
}

Step 4: Initialize Terraform:

terraform init

Step 5: Try applications

Applications

Create

  • Run an apply via Terraform:
terraform apply

The output generated should look similar to the following:

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

vm_1 = {
  "encrypt" = true
  "id" = "pkid_key"
  "key" = "key"
  "project" = "pkid"
  "timeouts" = null /* object */
  "value" = "value"
}

vm_2 = {
  "encrypt" = true
  "id" = "pkid_key"
  "key" = "key"
  "project" = "pkid"
  "timeouts" = null /* object */
  "value" = "value"
}

Update

  • make a change in the resource
  • Run an apply via Terraform:
terraform apply

The output generated should look similar to the following:

Apply complete! Resources: 0 added, 2 changed, 0 destroyed.

Outputs:

vm_1 = {
  "encrypt" = false
  "id" = "pkid_key"
  "key" = "key"
  "project" = "pkid"
  "timeouts" = null /* object */
  "value" = "value"
}

vm_2 = {
  "encrypt" = false
  "id" = "pkid_key"
  "key" = "key"
  "project" = "pkid"
  "timeouts" = null /* object */
  "value" = "value"
}

Delete

  • delete via terraform
terraform destroy -target=plugin_pkid_key_query.vm_1

The output generated should look similar to the following:

Destroy complete! Resources: 1 destroyed.

Test

make test

About

A terraform plugin (provider) to manage PKID data store

Resources

Stars

Watchers

Forks

Packages

No packages published