Giter VIP home page Giter VIP logo

terraform-provider-kong's Introduction

Terraform Provider Kong

The Kong Terraform Provider tested against real Kong!

v5.0.0 of the provider supports Terraform 0.12

IMPORTANT

The provider has been updated to support Kong v2.X, there were some breaking changes made between Kong v1 and v2. To use Kong v1 use provider version v6.X.X. That version will no longer be maintained.

Requirements

Usage

First, install the desired plugin release following Terraform's Third-party plugin docs.

To configure the provider:

provider "kong" {
    kong_admin_uri = "http://myKong:8001"
}

Optionally you can configure Username and Password for BasicAuth:

provider "kong" {
    kong_admin_uri  = "http://myKong:8001"
    kong_admin_username = "youruser"
    kong_admin_password = "yourpass"
}

You can use environment variables to set the provider properties instead. The following table shows all of the config options, the corresponding environment variables and their property defaults if you do not set them. When using the kong_api_key parameter ensure that the key name parameter in the key-auth plugin is set to apikey.

Provider property Env variable Default if not set Use
kong_admin_uri KONG_ADMIN_ADDR http://localhost:8001 The url of the kong admin api
kong_admin_username KONG_ADMIN_USERNAME not set Username for the kong admin api
kong_admin_password KONG_ADMIN_PASSWORD not set Password for the kong admin api
tls_skip_verify TLS_SKIP_VERIFY false Whether to skip tls certificate verification for the kong api when using https
kong_api_key KONG_API_KEY not set API key used to secure the kong admin API
kong_admin_token KONG_ADMIN_TOKEN not set API key used to secure the kong admin API in the Enterprise Edition
strict_plugins_match STRICT_PLUGINS_MATCH false Should plugins config_json field strictly match plugin configuration

Documentation

For documentation on how to use the provider see the documentation on the Hashicorp Terraform Registry for this provider

Contributing

I would love to get contributions to the project so please feel free to submit a PR. To setup your dev station you need go and docker installed.

Once you have cloned the repository the env TF_ACC=1 make command will build the code and run all of the tests. If they all pass then you are good to go!

If when you run the make command you get the following error:

goimports needs running on the following files:

Then all you need to do is run make goimports this will reformat all of the code (I know awesome)!!

Please write tests for your new feature/bug fix, PRs will only be accepted with covering tests and where all tests pass. If you want to start work on a feature feel free to open a PR early so we can discuss it or if you need help.

terraform-provider-kong's People

Contributors

andrew-bulford-form3 avatar bartoszj avatar bneutra avatar caryyu avatar charles-d-burton avatar charlie-retzler avatar danaps avatar devanshutanna avatar eduardoespinozaperez avatar ewilde avatar jochen42 avatar kamsz avatar kevholditch avatar kevholditch-f3 avatar kyos avatar mars avatar onematchfox avatar posquit0 avatar quantumew avatar sophaskins avatar stack72 avatar tecnobrat avatar zamrih avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-kong's Issues

Feature: BasicAuth for AdminApi

Hi!

we are using kong with the kong-loopback-admin api according the following article:
https://getkong.org/docs/0.11.x/secure-admin-api/

Now we wan't to manage kong api's with terraform. To be able to do this, we need to support basic-auth for the admin-api requests.

I already created an pull-request in the dependency gokong.
In some minutes i will create an pull-request here. But i guess the Tests will fail until the gokong-pr is merged.

have a nice weekend, jochen

Support for manaje oauth2 applications and tokens

Hello guys,

Exist currently a method to manage the oauth2 applications and tokens with the provider?

https://docs.konghq.com/hub/kong-inc/oauth2/

I'm trying to configure mi kong with a service with oauth2 plugin enabled, and I can without problem, create the service, the corresponding routes, and apply the oauth2 plugin for the service that I want, but... How to I can create and oauth2 application for a consumer?

On the linked docs appear the endpoint that kong uses for create and manage these oauth2 applications.

Thanks for all!

Setting path from non-empty to an empty string broken

Hello,

When applying a change to a service path that contains a valid path to an empty string, terraform reports success but doesn't actually apply the change.

Example:
A service has a path set to /corp. As I apply the configuration that changes /corp to "", terraform reports the change was successfully applied but it actually was not.

Terraform will perform the following actions:

  ~ kong_service.service
      path: "/corp" => ""

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

kong_service.service: Modifying... (ID: 301f1020-6fa2-425f-b883-a77d47fbb892)
  path: "/corp" => ""
kong_service.service: Modifications complete after 0s (ID: 301f1020-6fa2-425f-b883-a77d47fbb892)

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

Terraform version: 0.11.8
Kong 0.14.1
Affected Resources(s)

  • kong_service (confirmed)
  • kong_route (possibly)

EDIT: this may actually be a bug with kong

JWT Resource

Looking at the current state, I don't see a way to have this provider instruct Kong to create a JWT token for a consumer. I think it would be very useful(at least in my use case) to have a resource that can create a JWT token for a consumer. I was thinking it would look something like this:

resource "kong_consumer_jwt" "consumer_token" {
  consumer_id = "${kong_consumer.consumer.id}"
}

Then have the outputs be each of the fields of the returned message.

EDIT: I'm basing this off the docs here:
https://getkong.org/plugins/jwt/#create-a-jwt-credential

Target refresh fails if upstream has been deleted

Expected Behavior

Terraform should be able to refresh the state of a target without any error even if that target no longer exists.

Actual Behavior

If an upstream is deleted then any targets for that upstream are also deleted. However, when Terraform tries to refresh the state of the target, the provider throws the following error causing terraform to fail:

kong_target.target: could not find kong target: non existent upstream: 5ce85d25-1c7a-4b06-b0fa-d8ec7d1d8eda

To get around this you need to manually remove the target from terraform state.

Steps to Reproduce

  1. Create upstream and target using terraform
  2. Manually delete upstream (and target) from Kong
  3. Attempt to run terraform plan again

Notes

Will submit PR to fix

Provider doesn't work inside terraform docker image

Hi Kev,

Looks like the released binaries do not work within the released terraform docker images. It appears to be because the terraform docker images are run on alpine.

Expected Behavior

The provider should work on the official terraform docker image

Actual Behavior

Provider errors with terraform-provider-kong_v1.2.0: not found

Steps to Reproduce

$ docker run -it -v "$(pwd):/providers" --entrypoint="/providers/terraform-provider-kong_v1.2.0" hashicorp/terraform
standard_init_linux.go:190: exec user process caused "no such file or directory"

You can see it executes on other non-alpine distros:

$ docker run -it -v "$(pwd):/providers" --entrypoint="/providers/terraform-provider-kong_v1.2.0" ubuntu

This binary is a plugin. These are not meant to be executed directly.
Please execute the program that consumes these plugins, which will
load any plugins automatically

Consumer Plugin refresh fails if consumer has been deleted

Expected Behavior
Terraform should be able to refresh the state of a consumer plugin without any error even if that plugin no longer exists.

Actual Behavior
If a consumer is deleted then any plugins for that consumer are also deleted. However, when Terraform tries to refresh the state of the copnsumer plugin, the provider throws an error causing terraform to fail

Steps to Reproduce
Create consumer and consumer plugin using terraform
Manually delete consumer (and by association consumer plugin) from Kong
Attempt to run terraform plan again

Notes
Will submit PR to fix

Add routes based on OpenAPI

I'm using Kong with a Grafana Dashboard. The dashboard shows information exported in Prometheus Export format. I would love to see the status code of every route (endpoint) of a service so that we can measure endpoint reliability.

The feature request is:
Adding routes/services based on the OpenAPI specification.

The feature is available with Kong Enterprise.

kong_api unexpected EOF

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.11.7

Affected Resource(s)

  • kong_api

Terraform Configuration Files

resource "kong_api" "player" {
  name = "${var.account}-${var.service_name}"

  uris = ["/xxxxxxx(/\\d+)*/?"]

  methods                  = ["GET"]
  upstream_url             = "http://${aws_s3_bucket.xxxxxx.website_endpoint}/"
  strip_uri                = true
  preserve_host            = false
  retries                  = 3
  upstream_connect_timeout = 60000
  upstream_send_timeout    = 30000
  upstream_read_timeout    = 10000
  https_only               = false
  http_if_terminated       = false
}

Debug Output

2018/08/06 10:33:35 [DEBUG] Starting graph walk: walkApply
kong_api.player: Creating...
  http_if_terminated:       "" => "false"
  https_only:               "" => "false"
  methods.#:                "0" => "1"
  methods.0:                "" => "GET"
  name:                     "" => "xxxxxxx"
  preserve_host:            "" => "false"
  retries:                  "" => "3"
  strip_uri:                "" => "true"
  upstream_connect_timeout: "" => "60000"
  upstream_read_timeout:    "" => "10000"
  upstream_send_timeout:    "" => "30000"
  upstream_url:             "" => "xxxxxx"
  uris.#:                   "0" => "1"
  uris.0:                   "" => "/xxxxxx(/\\d+)*/?"
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: panic: runtime error: invalid memory address or nil pointer dereference
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x993aa9]
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: goroutine 42 [running]:
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: github.com/kevholditch/terraform-provider-kong/kong.resourceKongApiCreate(0xc4203e6770, 0xabbd00, 0xc420169110, 0x24, 0xf5ea20)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/gopath/src/github.com/kevholditch/terraform-provider-kong/kong/resource_kong_api.go:109 +0x139
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc4203ec3c0, 0xc420266320, 0xc42029cea0, 0xabbd00, 0xc420169110, 0xc42026cd01, 0xc420289b88, 0x4bbe7c)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/gopath/src/github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:193 +0x372
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc4202cf7a0, 0xc4202662d0, 0xc420266320, 0xc42029cea0, 0x18, 0x18, 0xc42029cee0)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/gopath/src/github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:259 +0xa4
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc420406ac0, 0xc42029ca80, 0xc42042e250, 0x0, 0x0)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/gopath/src/github.com/kevholditch/terraform-provider-kong/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:488 +0x57
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: reflect.Value.call(0xc420150420, 0xc420168de8, 0x13, 0xb11859, 0x4, 0xc420289f18, 0x3, 0x3, 0xc42016e080, 0xc4202826e8, ...)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/reflect/value.go:447 +0x969
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: reflect.Value.Call(0xc420150420, 0xc420168de8, 0x13, 0xc420282718, 0x3, 0x3, 0xc42020ef60, 0xc400000005, 0x0)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/reflect/value.go:308 +0xa4
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: net/rpc.(*service).call(0xc420414340, 0xc420162b40, 0xc42037b240, 0xc42037b250, 0xc4203a1000, 0xc420407020, 0x9ea400, 0xc42029ca80, 0x16, 0x9ea440, ...)
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/net/rpc/server.go:384 +0x14e
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: created by net/rpc.(*Server).ServeCodec
2018-08-06T10:33:35.627-0600 [DEBUG] plugin.terraform-provider-kong: 	/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/net/rpc/server.go:480 +0x43a

Panic Output

Expected Behavior

I would expect a meaningful error if there is an issue creating the api

Actual Behavior

nondescript EOF error which I believe stems from a nil pointer dereference caused by this line. Should it not be if err != nil || api == nil instead of if err != nil && api != nil?

Steps to Reproduce

  1. terraform apply

Important Factoids

References

Kong fails when Route `regex_priority` is nil but it cannot be set in provider

For Kong version 1.0.0-1.0.2 that have a route configured via this Terraform provider, Kong throws a 500 error when receiving any request, logging the error (formatted for readability):

2019/01/28 22:47:06 [error] 54#0: *33046 [kong] handler.lua:687
  no router to route request (reason:
    /app/kong-runtime/share/lua/5.1/kong/runloop/handler.lua:116:
      attempt to compare nil with number), 
  client: x.x.x.x, 
  server: kong, 
  request: "GET /favicon.ico HTTP/1.1", 
  host: "xxxxx.example.com", 
  referrer: "https://xxxxx.example.com/"

Looking at Kong source location referenced in that error:

    sort(routes, function(r1, r2)
      r1, r2 = r1.route, r2.route
      if r1.regex_priority == r2.regex_priority then
        return r1.created_at < r2.created_at
      end
      return r1.regex_priority > r2.regex_priority  -- โ† THIS IS LINE #116
    end)

So it seems to be routing code comparing route priorities.

I check the Postgres database to see what the route contains for that field:

-[ RECORD 2 ]--+-------------------------------------
id             | b4e8ae92-8e4c-40a4-87d9-98af04969da0
created_at     | 2019-01-28 23:07:05+00
updated_at     | 2019-01-28 23:07:05+00
service_id     | 36a43882-84ba-4fc8-aa2a-94569c4bf2b7
protocols      | {https}
methods        | 
hosts          | {mars-micro-wasabi.happ.host}
paths          | 
regex_priority |                                      โ† THIS FIELD IS NULL
strip_path     | t
preserve_host  | f
name           | 
snis           | 
sources        | 
destinations   | 

The field is null.

So I try to set regex_priority in the Terraform config:

resource "kong_route" "wasabi_hostname" {
  protocols      = ["https"]
  hosts          = [ "${heroku_app.wasabi.name}.${var.dns_zone}" ]
  strip_path     = true
  regex_priority = 0
  service_id     = "${kong_service.wasabi.id}"
}

โ€ฆbut applying that config Terraform throws the error:

Error: kong_route.wasabi_hostname: : invalid or unknown key: regex_priority

Potential solution

Setting the route's regex_priority = 0 manually via SQL in the database resolves the error, and then Kong functionals correctly. So the fix seems as simple as setting this attribute correctly.

I propose adding regex_priority to the Route Schema with a default of 0. The regex_priority attribute already appears to be present in the API client.

Other context

I found regex_priority was already requested, but this seems to be a more critical issue because leaving it unset seems to render Kong non-functional.

I've opened an issue on Kong itself to illuminate the fact that it accepts this null config value, and then proceeds to fail, no longer proxying requests.

Cannot create HTTP/HTTPS route using provider ver. 4.5

I use Kong EE v0.34

I use https://github.com/kevholditch/terraform-provider-kong/releases/tag/v4.5.0.

I tried to create HTTP/HTTPS route as in readme:

resource "kong_route" "route" {
    name            = "MyRoute"
	protocols 	    = [ "http", "https" ]
	methods 	    = [ "GET", "POST" ]
	hosts 		    = [ "example2.com" ]
	paths 		    = [ "/test" ]
	strip_path 	    = false
	preserve_host 	= true
	regex_priority 	= 1
	service_id 	    = "${kong_service.service.id}"
}

I get the following error:

error: could not register the route, error: {"fields":{"destinations":"unknown field","name":"unknown field","snis":"unknown field","sources":"unknown field"},"name":"schema violation","code":2,"message":"4 schema violations (destinations: unknown field; name: unknown field; snis: unknown field; sources: unknown field)"}

It means that parameters for TCP route are sent.

#59 here was the same problem but issue is closed.

EDIT.
I used provider version 1.9.2 and it works. Does admin api in enterprise edition is far behind the community edition?

Empty Hosts Array stopping API resource apply

Terraform Version

Terraform v0.11.13

  • provider.aws v2.6.0
  • provider.kong v1.9.2

Not on 4.5.0 due to older version of Kong (0.10.2)

Affected Resource(s)

API Resource.

Terraform Configuration Files

resource "kong_api" "terraform-test-api" {
    name                     = "terraform-test-api"
    hosts                    =  []
    uris                     = [ "/v3/terraform-test-api" ]
    methods                  = [ "GET", "POST" ]
    upstream_url             = "http://UPSTREAM-URL"
    strip_uri                = true
    preserve_host            = false
    retries                  = 3
    upstream_connect_timeout = 60000
    upstream_send_timeout    = 60000
    upstream_read_timeout    = 60000
    https_only               = false
    http_if_terminated       = true
}

Debug Output

* kong_api.terraform-test-api: failed to create kong api: &{0xc420394da0 [] [0xc420394eb0] [0xc4203a6520 0xc4203a6530] 0xc420394ff0 0xc42009dc28 0xc42009dc29 0xc42009dcb0 0xc42009dcc0 0xc42009dcd0 0xc42009dce0 0xc42009dcf0 0xc42009dcf1} error: could not parse api creation response, error: json: cannot unmarshal string into Go struct field .hosts of type []*string {"hosts":"hosts is not an array"}

Expected Behavior

Resource created with an empty hosts value

Actual Behavior

Will not actually create it.

Steps to Reproduce

terraform apply

Important Factoids

I am guessing this is happening because Terraform does not appear to be sending the "hosts" value to the plugin, as it is viewing it as empty, or it is supplying it incorrectly.

Cannot set "retries" on kong_service to 0

Terraform Version

$ terraform -v
Terraform v0.12.18
+ provider.kong v5.0.0

Affected Resource(s)

  • kong_service

Terraform Configuration Files

provider "kong" {
    kong_admin_uri = "http://localhost:8001"
}
resource "kong_service" "health_service" {
    name        = "kong-health"
    protocol    = "http"
    host        = "localhost" // stub
    port        = 80
    path        = "/health"
    retries     = 0
}
resource "kong_route" "health_route" {
    name            = "health_route"
    protocols       = [ "http" ]
    methods         = [ "GET" ]
        paths           = [ "/health" ]
    regex_priority  = 1
    service_id      = kong_service.health_service.id
}
resource "kong_plugin" "request-termination" {
    name        = "request-termination"
    service_id = kong_service.health_service.id
    config_json = <<EOT
    {
           "status_code": 200,
           "message": "OK"
    }
EOT
}

Output

kong_service.health_service: Refreshing state... [id=8f14320d-de48-4c6e-883e-d58c27140613]
kong_plugin.request-termination: Refreshing state... [id=b368554c-fe92-494f-9be7-e8b36937a2af]
kong_route.health_route: Refreshing state... [id=3fedac44-d5ce-4d29-b941-ad5277d0c83a]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # kong_service.health_service will be updated in-place
  ~ resource "kong_service" "health_service" {
        connect_timeout = 60000
        host            = "localhost"
        id              = "8f14320d-de48-4c6e-883e-d58c27140613"
        name            = "kong-health"
        path            = "/health"
        port            = 80
        protocol        = "http"
        read_timeout    = 60000
      ~ retries         = 5 -> 0
        write_timeout   = 60000
    }

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

kong_service.health_service: Modifying... [id=8f14320d-de48-4c6e-883e-d58c27140613]
kong_service.health_service: Modifications complete after 0s [id=8f14320d-de48-4c6e-883e-d58c27140613]

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

Expected Behavior

This update of the service's retries should have succeeded; a subsequent run of terraform should have no updates to perform. If I query the Kong API directly, I should see the retries set to 0.

Actual Behavior

Subsequent runs of the same Terraform manifest see the retries field as still set to the default (5) and try to update it again. Querying the Kong API with curl localhost:8001/services/kong-health shows a value of 5 for retries.

Steps to Reproduce

Applying the above Terraform manifest to the stock docker-compose setup for Kong from

Adding upstream and tarjet shows error version=4.4

Hi there,

I have a problem adding usptreams and targets on my actual configuration, I updated to the 4.4 but it shows an error when I try to apply

Terraform Version

terraform: 0.11.13
provider kong: 4.4.0
kong: 0.33

Terraform Configuration Files

docker_cluster_machines = ["10.245.132.10", "10.245.132.11", "10.245.132.12"]

resource "kong_service" "s-commercial-platform" {
  name            = "s-commercial-platform"
  protocol        = "http"
  host     	      = "${kong_upstream.u-commercial-platform.name}"
  path            = "/"
  retries         = 5
  connect_timeout = 1000
  write_timeout   = 2000
  read_timeout    = 3000
}
resource "kong_upstream" "u-commercial-platform" {
  name  = "commercial_platform.upstream"
  slots = 100
}
resource "kong_target" "target" {
  count       = "${length(var.docker_cluster_machines)}"
  target      = "${var.docker_cluster_machines[count.index]}:8004"
  weight      = 10
  upstream_id = "${kong_upstream.u-commercial-platform.id}"
}

Terraform plan

The terraform plan shows this:

~ kong_service.s-commercial-platform
      host:                "10.245.132.10" => "commercial_platform.upstream"
      port:                "8004" => "80"

  + kong_target.target[0]
      id:                  <computed>
      target:              "10.245.132.10:8004"
      upstream_id:         "${kong_upstream.u-commercial-platform.id}"
      weight:              "10"

  + kong_target.target[1]
      id:                  <computed>
      target:              "10.245.132.11:8004"
      upstream_id:         "${kong_upstream.u-commercial-platform.id}"
      weight:              "10"

  + kong_target.target[2]
      id:                  <computed>
      target:              "10.245.132.12:8004"
      upstream_id:         "${kong_upstream.u-commercial-platform.id}"
      weight:              "10"

  + kong_upstream.u-commercial-platform
      id:                  <computed>
      hash_fallback:       "none"
      hash_on:             "none"
      hash_on_cookie_path: "/"
      healthchecks.#:      <computed>
      name:                "commercial_platform.upstream"
      slots:               "100"
Plan: 4 to add, 1 to change, 0 to destroy.

Terraform Apply

The terraform apply shows this

+ terraform apply -no-color '-lock=false' '-input=false' tfplan
kong_upstream.u-commercial-platform: Creating...
  hash_fallback:       "" => "none"
  hash_on:             "" => "none"
  hash_on_cookie_path: "" => "/"
  healthchecks.#:      "" => "<computed>"
  name:                "" => "commercial_platform.upstream"
  slots:               "" => "100"

Error: Error applying plan:

1 error(s) occurred:

* kong_upstream.u-commercial-platform: 1 error(s) occurred:

* kong_upstream.u-commercial-platform: failed to create kong upstream: &{commercial_platform.upstream 100 none none    / <nil>} error: could not create update, error: {"hash_on_cookie_path":"hash_on_cookie_path is an unknown field"}


Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.


kong_service disappears from tfstate file after terraform refresh

Hi there,

When using the plugin, the service disappears after 'terraform refresh'. If I have multiple kong_service, sometimes 1 or 2 will disappear until there is only 1 kong_service left.

Terraform Version

0.11.8

Affected Resource(s)

Please list the resources as a list, for example:

  • kong_service

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
<script src="https://gist.github.com/hapialex/ccdecbc6609f6de4b16afe7250d7182d.js"></script>

Expected Behavior

terraform refresh should have the same states for all resources given kong itself has not changed.

Actual Behavior

The kong_service disappears from the tfstate file until there is only one service left.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Usage instructions do not work

Thanks for sharing this provider. I'm hopeful it will solve some big challenges here ๐Ÿ™๐Ÿ˜„

When following this provider's Usage docs, terraform init returns an error:

Provider "kong" not available for installation.

The error goes on to describe how to install manually:

โ€ฆthe plugin must be installed manually by locating and downloading a suitable distribution package and placing the plugin's executable file in the following directory:
ย ย ย ย terraform.d/plugins/darwin_amd64

Yet, I cannot find a distribution package for this provider.

Would you please give some guidance for how to get this installed? Clearly other folks have accomplished this, so I'm probably just missing something obvious?

plugin works unstable via loop-back route and api-key auth

Hi @kevholditch ,

Terraform Version

terraform -v
Terraform v0.11.8

Affected Resource(s)

kong_service

Expected Behavior

It should create a service only once.

Actual Behavior

terrafrom plan shows randomly that kongs service has to be created even it's done.
It may affect any service or may not, occurs randomly.

Steps to Reproduce

  1. configure loop-back route to kong admin api with api-key
  2. terraform plan -> works good
  3. terrafrom apply -> works good
  4. terrafrom plan multiple times -> will show that a service has to be created even it's created on step 3.
  5. some terraform plan execution may show correct status.

Let me know if some additional information is required. Thanks

Create releases v5.0.2, v5.1.0, v5.2.0

Hello. could you make releases of those versions?

  • v5.0.2
  • v5.1.0
  • v5.2.0

As I've noticed the goreleaser doesn't work because make deps and make test downloads dependencies which are modifying go.mod and go.sum files.

Adding upstreams and targets

Hi all,
This provider supports targerts' upstream?
I tried adding a upstream, but i don't know how add targets for this upstream.

Regards.
David

Create new route issue in terraform provider kong > v1.9.1

The last releases of terraform-provider-kong doesn't create routes when you don't have snis,sources and destinations

using tcpdump the POST request to Kong shows this data (v3.0.1):

{"destinations":null,"hosts":["example.com"],"methods":["GET","POST"],"name":null,"paths":["/foo/bar"],"preserve_host":true,"protocols":["http","https"],"regex_priority":null,"service":{"id":"397124ee-a20c-4b63-ab1e-f76932094d6f"},"snis":null,"sources":null,"strip_path":false}

using tcpdump the POST request to Kong shows this data (v1.9.1):

{"hosts":["example.com"],"methods":["GET","POST"],"paths":["/foo/bar"],"preserve_host":true,"protocols":["http","https"],"service":{"id":"397124ee-a20c-4b63-ab1e-f76932094d6f"},"strip_path":false}

https://golang.org/pkg/encoding/json/#Marshal

// Field appears in JSON as key "myName" and
// the field is omitted from the object if its value is empty,
// as defined above.
Field int `json:"myName,omitempty"`

in https://github.com/kevholditch/gokong

diff --git a/routes.go b/routes.go
index ed35434..0f623fe 100644
--- a/routes.go
+++ b/routes.go
@@ -18,9 +18,9 @@ type RouteRequest struct {
        RegexPriority *int      `json:"regex_priority"`
        StripPath     *bool     `json:"strip_path"`
        PreserveHost  *bool     `json:"preserve_host"`
-       Snis          []*string `json:"snis"`
-       Sources       []*string `json:"sources"`
-       Destinations  []*string `json:"destinations"`
+       Snis          []*string `json:"snis,omitempty"`
+       Sources       []*string `json:"sources,omitempty"`
+       Destinations  []*string `json:"destinations,omitempty"`
        Service       *Id       `json:"service"`
 }

in this repo:

diff --git a/kong/resource_kong_route.go b/kong/resource_kong_route.go
index 1d43556..b602b98 100644
--- a/kong/resource_kong_route.go
+++ b/kong/resource_kong_route.go
@@ -36,6 +36,24 @@ func resourceKongRoute() *schema.Resource {
                                ForceNew: false,
                                Elem:     &schema.Schema{Type: schema.TypeString},
                        },
+                       "destinations": &schema.Schema{
+                               Type:     schema.TypeList,
+                               Optional: true,
+                               ForceNew: false,
+                               Elem:     &schema.Schema{Type: schema.TypeString},
+                       },
+                       "sources": &schema.Schema{
+                               Type:     schema.TypeList,
+                               Optional: true,
+                               ForceNew: false,
+                               Elem:     &schema.Schema{Type: schema.TypeString},
+                       },
+                       "snis": &schema.Schema{
+                               Type:     schema.TypeList,
+                               Optional: true,
+                               ForceNew: false,
+                               Elem:     &schema.Schema{Type: schema.TypeString},
+                       },
                        "paths": &schema.Schema{
                                Type:     schema.TypeList,
                                Optional: true,
@@ -138,6 +156,18 @@ func resourceKongRouteRead(d *schema.ResourceData, meta interface{}) error {
                        d.Set("service_id", route.Service)
                }

+               if &route.Snis != nil {
+                       d.Set("snis", route.Snis)
+               }
+
+               if &route.Sources != nil {
+                       d.Set("sources", route.Sources)
+               }
+
+               if &route.Destinations != nil {
+                       d.Set("destinations", route.Destinations)
+               }
+
        }

        return nil
@@ -161,6 +191,9 @@ func createKongRouteRequestFromResourceData(d *schema.ResourceData) *gokong.Rout
                Methods:       readStringArrayPtrFromResource(d, "methods"),
                Hosts:         readStringArrayPtrFromResource(d, "hosts"),
                Paths:         readStringArrayPtrFromResource(d, "paths"),
+               Snis:          readStringArrayPtrFromResource(d, "snis"),
+               Sources:       readStringArrayPtrFromResource(d, "sources"),
+               Destinations:  readStringArrayPtrFromResource(d, "destinations"),
                StripPath:     readBoolPtrFromResource(d, "strip_path"),
                PreserveHost:  readBoolPtrFromResource(d, "preserve_host"),
                RegexPriority: readIntPtrFromResource(d, "regex_priority"),

However this patches will not fix the problem, I still not sure why is sending the fields (snis,sources,destinations) with null value, I'm not very familiar with GO but maybe this information can help you to fix the problem

When removing config_json from a kong_plugin resource Terraform does not catches the change and says nothing is Changing

Bug Kong_plugin

When removing a config_json from the resource terraform plan does not show any changes.

Before:
resource "kong_plugin" "tokenhelper_salesforce" { name = "tokenhelper" route_id = "${kong_route.salesforce.id}" config_json = <<EOT { "path_prefix": "${local.path_prefix}" } EOT }

After
resource "kong_plugin" "tokenhelper_salesforce" { name = "tokenhelper" route_id = "${kong_route.salesforce.id}" }

Terraform Version 0.11 - Kong Provider Version: "5.0.0"

After terraform plan I get:
Plan: 0 to add, 0 to change, 0 to destroy.

No errors thrown on 401, 403 response from admin API

Hi, I've been using Kong + terraform-provider-kong on an existing Kong installation that already has APIs with pre-existing configuration. I've been importing lots of the resources which has worked brilliantly, many thanks for a great provider!

However, I ran into an issue with the admin API configured as a Kong API with IP whitelisting and HTTP auth. When the terraform provider checks the existing API objects and is either unauthorized (401) or not IP whitelisted (403) the provider assumes the objects don't exist and plans to create them.

Expected Behavior

The provider would throw an error for unauthorized or not whitelisted instead of planning to create resources when checking for existing objects against the admin API.

Actual Behavior

HTTP 401 and 403 responses from the admin API do not cause errors and the provider appears to assume that the API objects do not exist, so plans to create them.

Steps to Reproduce

  1. Configure API objects on a Kong instance successfully in Terraform so the state is populated.
  2. Put the admin API behind HTTP auth and IP whitelisting as per Kong docs that does not allow the terraform client to connect (401, 403 etc)
  3. Re-run terraform apply
  4. Terraform will report that the existing objects need to be created again.

Update README.md to reflect the removal of "config" from resource_kong_consumer_plugin_config

First of all, thanks for the provider, once I get to know the ropes hopefully I can contribute some PR's. I believe the README.md around kong/resource_kong_consumer_plugin_config.go is out of date. For me configuring a consumer with the acl plugin (tf 0.11.14, kong 1.1) using config_json with the "acl" plugin works just fine. The README.md says you must use "config" but that doesn't work, which I think you can see why, it was removed here:

e89326a#diff-6c4ac886194357f39f8e55ebddfdc86b

e.g. this worked fine

resource "kong_consumer_plugin_config" "consumer_acl" {
consumer_id = "${kong_consumer.test.id}"
plugin_name = "acls"
config_json = <<EOT
{
"group": "group1"
}
EOT
}

while what is indicated in the README.md does not
Error: kong_consumer_plugin_config.consumer_acl: : invalid or unknown key: config

Thank you

Just letting you know thx for putting the terraform provider together it works like a treat

currently using it for work all is well.

kong_service default port is 0 not 80

kong_service default port is 0 not 80

kong version tested: 0.13.1 CE

provider "kong" {
    kong_admin_uri = "http://0.0.0.0:8001"
}

resource "kong_service" "service_example" {
        name     = "example"
        protocol = "http"
        host     = "example.com"
}

resource "kong_route" "route_example" {
        protocols    = ["http","https"]
        paths        = ["/example"]
        service_id   = "${kong_service.service_example.id}"
}
curl 0.0.0.0:8001/services/example |jq
{
  "host": "example.com",
  "created_at": 1543462147,
  "connect_timeout": 60000,
  "id": "aa8aa6ac-0b1b-4a45-af4f-663c85806595",
  "protocol": "http",
  "name": "example",
  "read_timeout": 60000,
  "port": 0,
  "path": null,
  "updated_at": 1543462147,
  "retries": 5,
  "write_timeout": 60000
}
curl 0.0.0.0:8001/services/example/routes |jq
{
  "host": "example.com",
  "created_at": 1543462147,
  "connect_timeout": 60000,
  "id": "aa8aa6ac-0b1b-4a45-af4f-663c85806595",
  "protocol": "http",
  "name": "example",
  "read_timeout": 60000,
  "port": 0,
  "path": null,
  "updated_at": 1543462147,
  "retries": 5,
  "write_timeout": 60000
}

is necessary to specify port 80 in the kong_service to avoid this issue

https://docs.konghq.com/0.13.x/admin-api/#request-body

unmarshal error of type []*string

I'm using kong v0.10.2, I'm using apis as Resource and I'm facing an unmarshal error.
It looks like that if a list field like hosts is empty this will set to an actual empty object {}
rather than empty list [].

After running PATCH on an apis resources:
{ "hosts": [] }

The GET will return:
{ ..., "upstream_read_timeout": 60000, "upstream_send_timeout": 60000, "https_only": false, "hosts": {} }
As you can see hosts is not an empty list but an empty object and terraform throw this during the import:
could not find kong api: could not parse api get response, error: json: cannot unmarshal object into Go struct field Api.hosts of type []*string

Also, I have the same error during a plan.

Terraform Version

v0.11.0

Expected Behavior

be able to import a resource with empty hosts list

Actual Behavior

unmarshal error: could not find kong api: could not parse api get response, error: json: cannot unmarshal object into Go struct field Api.hosts of type []*string

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. run PATCH to an api resources with body { "hosts": [] }
  2. run import of the api: `terraform import module.proxy.kong_api.test-service e9da8a938-355b-4c69-ab26-2f507c688d02

Support for Terraform 0.12

Now that Terraform 0.12 seems to be imminent. I wanted to add this to track support for Terraform 0.12 so we don't fall too far behind.

Incompatible with Kong 1.0 (kong_plugin cannot create with service_id or route_id)

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:

  1. terraform apply

Important Factoids

(None)

References

(None)

Arrays in plugin configuration

Hi,
I ran into an issue when configuring kong with your provider. I'm trying to configure request-transformer plugin and I cannot use the array notation of the configuration. I cannot use comma-separated values, since my Header value contains comma, and kong doc says:

Note: if the value contains a , then the comma separated format cannot be used. The array notation must be used instead.

So, here's what I want to achieve, note that config.add.headers is an array:

curl -X POST http://localhost:8001/apis/mockbin/plugins \
  --header 'content-type: application/json' \
  --data '{"name": "request-transformer", "config": {"add": {"headers": ["h1:v2", "h2:v1"]}}}'

I could not find a way to do this with your provider, could you add possibility to configure arrays?

Plugin documentation can be found here: https://getkong.org/plugins/request-transformer/?_ga=2.107772418.1474587009.1519637315-1381908740.1518784690

Tests failing on newer versions of Kong (>= 1.2.0)

Test TestAccKongRouteWithSourcesAndDestinations is currently failing on Kong version >= 1.2.0 due to schema validation adjustments where SNIs can now only be applied to secure routes (i.e. TLS/HTTPS).

Error:

Error: failed to create kong route: &{<nil> [0xc009d9b720] [] [] [] <nil> 0xc009f3d5d7 0xc009f3d6b0 [0xc009d9bbf0] [0xc009d9b990 0xc009d9b9b0] [0xc009d9baf0] 0xc009d9bc30} error: could not register the route, error: {"message":"2 schema violations ('snis' can only be set when 'protocols' is 'https' or 'tls'; snis: length must be 0)","name":"schema violation","fields":{"snis":"length must be 0","@entity":["'snis' can only be set when 'protocols' is 'https' or 'tls'"]},"code":2}

Will submit PR to fix.

Support for v0.14.x

I have a question. I'm using the latest version of Kong.
Is it support kong v0.14.x?

Provider URL problem

I'm wondering if anyone has ideas on this. I'm trying to use configure the provider block to use a secure endpoint secured with an API token. If I run curl against this endpoint using the same values it works, but the when configured in the provider it does not work.

provider "kong" {
  kong_admin_uri = "https://${var.kong_url}?function=${var.kong_api_key}"
}

The only error I get is something about an EOF.

`enabled` parameter for Plugin API

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

$ terraform -v
Terraform v0.11.8
+ provider.kong v1.7.0

Affected Resource(s)

Please list the resources as a list, for example:

  • kong_plugin

Terraform Configuration Files

resource "kong_plugin" "plugin-bot-detection" {
  name = "bot-detection"
  enabled = true
  config = {
    # A comma separated array of regular expressions
    # The regular expressions will be checked against the User-Agent header
    whitelist = ""
    blacklist = ""
  }
}

Expected Behavior

enabled parameter exists in the official documentation.

Actual Behavior

$ terraform apply

Error: kong_plugin.plugin-bot-detection: : invalid or unknown key: enabled

Kong provider v5.0.0 unable to modify route

Hello. I'm facing this problem with 5.0.0 with Kong Enterprise 0.34

Terraform apply output:

Terraform will perform the following actions:

  # kong_route.route1 will be updated in-place
  ~ resource "kong_route" "route1" {
      ~ hosts          = [
          - "30.131.16.190",
          - "dev.public.com",
          + "30.131.19.228",
          + "test.secret.com",
        ]
        id             = "0131ffb4-0646-48a4-af88-5fc96b0cb305"
        methods        = []
        paths          = [
            "/secret-demo",
        ]
        preserve_host  = false
        protocols      = [
            "http",
            "https",
        ]
        regex_priority = 0
        service_id     = "621d9809-0898-46d3-b99a-94893320a465"
        strip_path     = true
    }

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

kong_route.route1: Modifying... [id=0131ffb4-0646-48a4-af88-5fc96b0cb305]

Error: error updating kong route: could not update route, error: {"fields":{"destinations":"unknown field","name":"unknown field","snis":"unknown field","sources":"unknown field"},"name":"schema violation","code":2,"message":"4 schema violations (destinations: unknown field; name: unknown field; snis: unknown field; sources: unknown field)"}


  on routes.tf line 1, in resource "kong_route" "route1":
   1: resource "kong_route" "route1" {

Terraform Version

$ terraform -v
Terraform v0.12.6
+ provider.kong v5.0.0

Affected Resource(s)

  • kong_route

Terraform Configuration Files

resource "kong_route" "route1" {
  hosts          = ["30.131.16.190", "dev.secret.com"]
  methods        = []
  paths          = ["/secret-demo"]
  preserve_host  = false
  protocols      = ["http", "https"]
  regex_priority = 0
  service_id     = "621d9809-0898-46d3-b99a-94893320a465"
  strip_path     = true
}

Debug Output

https://gist.github.com/yusmadi/5e5825eec3f07ea828826b7b4b882fa7

Panic Output

N/A

Expected Behavior

Route is modified

Actual Behavior

kong_route.route1: Modifying... [id=0131ffb4-0646-48a4-af88-5fc96b0cb305]

Error: error updating kong route: could not update route, error: {"fields":{"destinations":"unknown field","name":"unknown field","snis":"unknown field","sources":"unknown field"},"name":"schema violation","code":2,"message":"4 schema violations (destinations: unknown field; name: unknown field; snis: unknown field; sources: unknown field)"}


  on routes.tf line 1, in resource "kong_route" "route1":
   1: resource "kong_route" "route1" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply -target kong_route.route1

Important Factoids

Nothing special

References

Nope

Regex in URI

So, ran into something else. Curious to know if you think this is something that can be fixed. I'm trying to add a route that contains a regular expression, but I can't seem to get it to take in terraform. When I try to run it, kong tries to inject additional escapes. If I don't add the escapes, terraform blows up with illegal characters:

resource "kong_api" "mf-public-web" {
  name = "mf-public-web"

  uris = [
    "\\^\\/certificates\\/\\w+.aspx",
  ]

  methods                  = ["GET", "POST", "UPDATE", "PATCH", "DELETE"]
  upstream_url             = "${lookup(var.mf-public-web, var.env)}"
  strip_uri                = false
  preserve_host            = false
  retries                  = 3
  upstream_connect_timeout = 60000
  upstream_send_timeout    = 30000
  upstream_read_timeout    = 10000
  https_only               = false
  http_if_terminated       = false
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.