-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
68 lines (57 loc) · 1.51 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
provider "kong" {
admin_api_url = "http://localhost:8001"
}
resource "kong_service" "mockbin" {
name = "mockbin"
url = "https://mockbin.org/request"
}
resource "kong_route" "mock" {
service_id = "${kong_service.mockbin.id}"
paths = [
"/mock"]
}
resource "kong_plugin_request_transformer_advanced" "request-transformer-plugin-service" {
service_id = "${kong_service.mockbin.id}"
add_headers = [
"x-parent-resource:service"]
http_method = "GET",
replace_uri = "/foobar"
}
variable "test-count-enabled" {
default = "no"
type = "string"
}
resource "kong_service" "test-count-service" {
count = "${var.test-count-enabled == "yes" ? 1 : 0}"
name = "foo"
url = "http://foo.bar.org"
}
resource "kong_route" "child-route-test-count" {
/*
Need to set count for dependent resources of a conditional resource,
otherwise TF will error:
Resource 'kong_service.test-count-service' not found for variable 'kong_service.test-count-service.id'
*/
count = "${var.test-count-enabled == "yes" ? 1 : 0}"
service_id = "${kong_service.test-count-service.id}"
}
variable basic-auth-foo-config {
type = "string"
default = <<EOF
{
"anonymous": "",
"hide_credentials": true
}
EOF
}
resource "kong_plugin" "basic-auth-foo" {
route_id = "${kong_route.mock.id}"
name = "basic-auth"
config_json = "${var.basic-auth-foo-config}"
}
resource "kong_plugin_openid_connect" "oidc-route" {
route_id = "${kong_route.mock.id}"
auth_methods = [
"bearer"]
issuer = "https://oidc.example.com/auth/"
}