This folder encapsulates the Terraform Provider that issues API calls to the pkid.
- Initialize Terraform
terraform init
- Try applications
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
- 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"
}
- 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 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.
make test