First of all I would like to thank your work. It´s a great provider!
I have found a problem using check_hook under check resource item.
provider "aws" {
region = var.aws_region
profile = "***************"
assume_role {
role_arn = "arn:aws:iam::***************:role/***************"
session_name = "session"
}
alias = "aws"
}
provider "sensu" {
api_url = "https://***************/"
username = "***************"
password = "***************"
namespace = "default"
insecure_skip_tls_verify = true
}
# S3 Backend
terraform {
required_version = ">= 0.14.8"
backend "s3" {
bucket = "***************"
key = "***************/***************"
region = "eu-west-1"
profile = "***************"
dynamodb_table = "***************"
role_arn = "arn:aws:iam::******:role/***********"
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.58.0"
}
sensu = {
source = "jtopjian/sensu"
version = "~> 0.12.0"
}
}
}
resource "sensu_hook" "ntp_hook" {
name = "ntp_hook"
command = "sudo systemctl restart ntpd.service"
}
This works like a charm.
resource "sensu_check" "ntp_linux" {
namespace = data.sensu_namespace.default.name
name = "ntp_linux"
annotations = {
"sensu.io.json_attributes" = "{\"keepalive\":false}"
}
command = "check-ntp.rb"
publish = true
interval = 3600
timeout = 30
ttl = 7200
handlers = ["default", "*******", "*******"]
subscriptions = [
"Linux"
]
check_hook {
hook = "ntp_hook"
trigger = "1"
}
}
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
~ update in-place
Terraform will perform the following actions:
# sensu_check.ntp_linux will be updated in-place
~ resource "sensu_check" "ntp_linux" {
id = "ntp_linux"
name = "ntp_linux"
# (17 unchanged attributes hidden)
+ check_hook {
+ hook = "ntp_hook"
+ trigger = "1"
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
sensu_check.ntp_linux: Modifying... [id=ntp_linux]
╷
│ Error: Plugin did not respond
│
│ with sensu_check.ntp_linux,
│ on 09-linux_ntp.tf line 1, in resource "sensu_check" "ntp_linux":
│ 1: resource "sensu_check" "ntp_linux" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call.
│ The plugin logs may contain more details.
╵
Releasing state lock. This may take a few moments...
Stack trace from the terraform-provider-sensu_v0.12.0 plugin:
panic: interface conversion: interface {} is *schema.Set, not []interface {}
goroutine 98 [running]:
github.com/jtopjian/terraform-provider-sensu/sensu.resourceCheckUpdate(0xc0004ed500, 0x20aeca0, 0xc0001ae780, 0x24, 0x2e926e0)
github.com/jtopjian/terraform-provider-sensu/sensu/resource_check.go:482 +0x1d27
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00028f580, 0xc0000baaf0, 0xc00082fe60, 0x20aeca0, 0xc0001ae780, 0x1f43501, 0xc0001b7888, 0xc0005a85a0)
github.com/hashicorp/[email protected]/helper/schema/resource.go:311 +0x263
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00028fe00, 0xc00017ba38, 0xc0000baaf0, 0xc00082fe60, 0xc0006fd168, 0xc000287590, 0x1f46220)
github.com/hashicorp/[email protected]/helper/schema/provider.go:294 +0x99
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0000a0cb8, 0x240f6e0, 0xc0002ba0f0, 0xc00082a4e0, 0xc0000a0cb8, 0xc0002ba0f0, 0xc0006c5ba0)
github.com/hashicorp/[email protected]/internal/helper/plugin/grpc_provider.go:885 +0x8b4
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x20b3500, 0xc0000a0cb8, 0x240f6e0, 0xc0002ba0f0, 0xc00082a480, 0x0, 0x240f6e0, 0xc0002ba0f0, 0xc00018e800, 0x762)
github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3189 +0x217
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000489040, 0x241d880, 0xc000642900, 0xc0003a4400, 0xc0004fdfb0, 0x2e52f60, 0x0, 0x0, 0x0)
google.golang.org/[email protected]/server.go:1082 +0x50a
google.golang.org/grpc.(*Server).handleStream(0xc000489040, 0x241d880, 0xc000642900, 0xc0003a4400, 0x0)
google.golang.org/[email protected]/server.go:1405 +0xccd
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0006a0360, 0xc000489040, 0x241d880, 0xc000642900, 0xc0003a4400)
google.golang.org/[email protected]/server.go:746 +0xa1
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:744 +0xa1
Error: The terraform-provider-sensu_v0.12.0 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
Time: 0h:00m:26s