Incompatible with Kong 1.0 (kong_plugin cannot create with service_id or route_id)
Closed this issue · 10 comments
Since upgrading to Kong 1.0, the Kong Plugin resource fails to create when given a service_id
(or route_id
).
Terraform Version
Terraform v0.11.11
+ provider.heroku v1.7.2
+ provider.kong v1.9.1
+ provider.random v2.0.0
Affected Resource(s)
Please list the resources as a list, for example:
- kong_plugin
Terraform Configuration Files
variable "name" {
type = "string"
}
variable "heroku_team" {
type = "string"
}
variable "heroku_region" {
type = "string"
default = "us"
}
locals {
kong_app_name = "${var.name}-proxy"
kong_base_url = "https://${local.kong_app_name}.herokuapp.com"
kong_admin_uri = "${local.kong_base_url}/kong-admin"
}
provider "heroku" {
version = "~> 1.7"
}
provider "kong" {
version = "~> 1.7"
kong_admin_uri = "${local.kong_admin_uri}"
kong_api_key = "${random_id.kong_admin_api_key.b64_url}"
}
provider "random" {
version = "~> 2.0"
}
resource "random_id" "kong_admin_api_key" {
byte_length = 32
}
# Proxy app
resource "heroku_app" "kong" {
name = "${local.kong_app_name}"
acm = true
region = "${var.heroku_region}"
config_vars {
KONG_HEROKU_ADMIN_KEY = "${random_id.kong_admin_api_key.b64_url}"
}
organization {
name = "${var.heroku_team}"
}
}
resource "heroku_addon" "kong_pg" {
app = "${heroku_app.kong.name}"
plan = "heroku-postgresql:hobby-dev"
}
resource "heroku_build" "kong" {
app = "${heroku_app.kong.name}"
buildpacks = ["https://github.com/heroku/heroku-buildpack-kong#v7.0.0"]
source = {
# This app uses a community buildpack, set it in `buildpacks` above.
url = "https://github.com/heroku/heroku-kong/archive/v7.0.0.tar.gz"
version = "v7.0.0"
}
}
resource "heroku_formation" "kong" {
app = "${heroku_app.kong.name}"
type = "web"
quantity = 1
size = "Standard-1x"
depends_on = ["heroku_build.kong"]
provisioner "local-exec" {
command = "./bin/kong-health-check ${local.kong_base_url}/kong-admin"
}
}
# Microservice app w/ proxy config
resource "random_id" "wasabi_internal_api_key" {
byte_length = 32
}
resource "heroku_app" "wasabi" {
name = "${var.name}-wasabi"
acm = true
region = "${var.heroku_region}"
config_vars {
INTERNAL_API_KEY = "${random_id.wasabi_internal_api_key.b64_url}"
}
organization {
name = "${var.heroku_team}"
}
}
resource "heroku_build" "wasabi" {
app = "${heroku_app.wasabi.name}"
buildpacks = ["https://github.com/heroku/heroku-buildpack-nodejs"]
source = {
# This app uses a community buildpack, set it in `buildpacks` above.
url = "https://github.com/mars/wasabi-secure/archive/v1.0.0.tar.gz"
version = "v1.0.0"
}
}
resource "heroku_formation" "wasabi" {
app = "${heroku_app.wasabi.name}"
type = "web"
quantity = 1
size = "Standard-1x"
depends_on = ["heroku_build.wasabi"]
}
resource "kong_service" "wasabi" {
name = "wasabi"
protocol = "https"
host = "${heroku_app.wasabi.name}.herokuapp.com"
port = 443
depends_on = ["heroku_formation.kong"]
}
resource "kong_route" "wasabi_hostname" {
protocols = ["https"]
paths = ["/wasabi"]
strip_path = true
service_id = "${kong_service.wasabi.id}"
}
resource "kong_plugin" "wasabi_internal_api_key" {
name = "request-transformer"
service_id = "${kong_service.wasabi.id}"
config_json = <<EOT
{
"add": { "headers": [ "X-Internal-API-Key: ${random_id.wasabi_internal_api_key.b64_url}" ]}
}
EOT
}
output "wasabi_service_url" {
value = "${local.kong_base_url}/wasabi"
}
Debug Output
https://gist.github.com/mars/6ae8b3117758198e265572db1628997c
Panic Output
(No panic)
Expected Behavior
The configuration should apply successfully, creating the plugin.
Actual Behavior
kong_plugin.wasabi_internal_api_key: Creating...
config_json: "" => "{\"add\":{\"headers\":[\"X-Internal-API-Key: xxxxx\"]}}"
name: "" => "request-transformer"
service_id: "" => "1ea6056b-82a6-4402-84e2-490109ff9883"
Error: Error applying plan:
1 error(s) occurred:
* kong_plugin.wasabi_internal_api_key: 1 error(s) occurred:
* kong_plugin.wasabi_internal_api_key: failed to create kong plugin: &{request-transformer 1ea6056b-82a6-4402-84e2-490109ff9883 map[add:map[headers:[X-Internal-API-Key: xxxxx]]]} error: could not create plugin, err: {"message":"schema violation (service_id: unknown field)","name":"schema violation","fields":{"service_id":"unknown field"},"code":2}
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Important Factoids
(None)
References
(None)
If we upgrade CI to Kong 1.0, would we see this error?
Looks like upgrading gokong's container runner to use the Kong 1.0's new "bootstrap" process will be required.
I found that for the Heroku Buildpack to launch Kong 1.0, the migrations commands are:
kong migrations bootstrap -c $KONG_CONF
kong migrations up -c $KONG_CONF
Thanks for reporting the issue. Quite a bit of work needs to be done in gokong and the terraform provider to make it all compatible with kong 1.0.0 as they have changed quite a few things
Sorry so to answer your question directly yes you will get an error if you upgrade to kong v1.0.0 as the terraform provider does not support this yet
Any news on this? We've upgraded to kong 1.0 and can't downgrade, but made the terraform / kong provider impossible to use.
@lucastex as far as I can tell, no one has begun working on the Kong 1.0 changes required to the Go client.
@kevholditch, perhaps adding a big not compatible with Kong 1.0 warning to the README is in order? Unfortunately the first paragraph in the README mentions “1.0” which is quite confusing, easy to misinterpret as Kong 1.0.
@mars have added a note to the readme to warn people that it is not compatible with kong 1.0.0 currently.
Amazing ✨ I’ll try it out this week!
@mars thanks, let me know how it works for you