Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 2992f34

Browse files
committed
Setup Admin API using kong import declarative config
1 parent 5e1b08a commit 2992f34

File tree

4 files changed

+65
-25
lines changed

4 files changed

+65
-25
lines changed

bin/postrelease

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
# Admin key is empty when the var is unset.
5+
KONG_HEROKU_ADMIN_KEY="${KONG_HEROKU_ADMIN_KEY:-}"
6+
7+
if [ -n "$KONG_HEROKU_ADMIN_KEY" ]
8+
then
9+
echo "Setting up external Admin API secured by KONG_HEROKU_ADMIN_KEY"
10+
11+
# Replace environment variables with their values.
12+
# Example: `$VAR` or `${VAR}` will be replaced with value of `VAR`.
13+
eval "cat <<EOF
14+
$(<config/secure-admin-api.yml)
15+
EOF
16+
" > config/secure-admin-api-rendered.yml
17+
18+
# Kong needs to be running for import.
19+
bin/background-start
20+
sleep 5
21+
# Import config to Kong 1.1+
22+
kong config db_import \
23+
-c "${KONG_CONF:-config/kong.conf}" \
24+
"config/secure-admin-api-rendered.yml"
25+
fi

bin/prerelease

Lines changed: 0 additions & 25 deletions
This file was deleted.

config/pg-heroku-admin.dump

-59.4 KB
Binary file not shown.

config/secure-admin-api.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Kong declarative config
2+
# https://discuss.konghq.com/t/rfc-kong-native-declarative-config-format/2719
3+
4+
# Metadata fields start with an underscore (_)
5+
# Fields that do not start with an underscore represent Kong entities and attributes
6+
7+
# Matches Kong minimum version that supports the format
8+
_format_version: "1.1"
9+
_comment: This configures a protected, external-facing loopback proxy to Kong's Admin API, secured by the KONG_HEROKU_ADMIN_KEY config var. This config is preprocessed by the bin/prerelease script to expand shell-style interpolations, such as variables.
10+
11+
services:
12+
- name: kong-admin
13+
url: http://localhost:8001
14+
routes:
15+
- name: kong-admin
16+
protocols:
17+
- https
18+
paths:
19+
- /kong-admin
20+
plugins:
21+
- name: request-size-limiting
22+
config:
23+
allowed_payload_size: 8
24+
- name: rate-limiting
25+
config:
26+
minute: 1000
27+
- name: key-auth
28+
config:
29+
hide_credentials: true
30+
- name: acl
31+
config:
32+
whitelist:
33+
- kong-admin
34+
35+
consumers:
36+
- username: heroku-admin
37+
acls:
38+
- group: kong-admin
39+
keyauth_credentials:
40+
- key: ${KONG_HEROKU_ADMIN_KEY}

0 commit comments

Comments
 (0)