Last active
February 14, 2020 06:42
-
-
Save nghnam/6b49f18c01c5d0468c7dff7ccfe607f1 to your computer and use it in GitHub Desktop.
Revisions
-
nghnam revised this gist
Feb 14, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ provider "kong" { variable "kong_admin_url" { description = "Kong admin api" default = "http://192.168.1.100:8001" } variable "example-user" { -
nghnam revised this gist
Feb 14, 2020 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,8 +39,14 @@ resource "kong_upstream" "example" { slots = 1000 } resource "kong_target" "example-target1" { target = "192.168.1.150:6555" weight = 10 upstream_id = kong_upstream.example.id } resource "kong_target" "example-target2" { target = "192.168.1.151:6555" weight = 10 upstream_id = kong_upstream.example.id } -
nghnam created this gist
Feb 13, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ provider "kong" { kong_admin_uri = "http://192.168.1.100:8001" } variable "kong_admin_url" { description = "Kong admin api" default = "http://192.168.8.100:8001" } variable "example-user" { default = "admin" } variable "example-password" { default = "admin" } resource "kong_service" "example" { name = "example" protocol = "http" host = "example" port = 6555 retries = 5 } resource "kong_route" "example-route" { name = "example-route" protocols = ["https"] hosts = ["api.example.com"] paths = ["/"] https_redirect_status_code = 301 strip_path = false preserve_host = true service_id = kong_service.example.id } resource "kong_upstream" "example" { name = "example" slots = 1000 } resource "kong_target" "example-target" { target = "192.168.1.100:6555" weight = 10 upstream_id = kong_upstream.example.id } resource "kong_consumer" "example" { username = "example" custom_id = "123" provisioner "local-exec" { command = <<EOT curl -X POST ${var.kong_admin_url}/consumers/${kong_consumer.example.id}/basic-auth \ --data username=${var.example-user} \ --data password=${var.example-password} EOT } } resource "kong_plugin" "example-basic-auth" { name = "basic-auth" route_id = kong_route.example-route.id enabled = true config_json = <<EOT { "hide_credentials": true } EOT } resource "kong_certificate" "example" { certificate = file("certificates/example.com/fullchain.pem") private_key = file("certificates/example.com/privkey.pem") } resource "kong_sni" "example" { name = "api.example.com" certificate_id = kong_certificate.example.id }